Skip to content

[lldb] Remove UnwindPlan::Row shared_ptrs, lite #134081

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lldb/include/lldb/Symbol/UnwindPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ class UnwindPlan {
bool m_unspecified_registers_are_undefined = false;
}; // class Row

typedef std::shared_ptr<Row> RowSP;
typedef std::unique_ptr<Row> RowUP;

UnwindPlan(lldb::RegisterKind reg_kind)
: m_register_kind(reg_kind), m_return_addr_register(LLDB_INVALID_REGNUM),
Expand All @@ -449,8 +449,8 @@ class UnwindPlan {
m_lsda_address(rhs.m_lsda_address),
m_personality_func_addr(rhs.m_personality_func_addr) {
m_row_list.reserve(rhs.m_row_list.size());
for (const RowSP &row_sp : rhs.m_row_list)
m_row_list.emplace_back(new Row(*row_sp));
for (const RowUP &row_up : rhs.m_row_list)
m_row_list.emplace_back(new Row(*row_up));
}
UnwindPlan(UnwindPlan &&rhs) = default;
UnwindPlan &operator=(const UnwindPlan &rhs) {
Expand Down Expand Up @@ -570,7 +570,7 @@ class UnwindPlan {
}

private:
std::vector<RowSP> m_row_list;
std::vector<RowUP> m_row_list;
std::vector<AddressRange> m_plan_valid_ranges;
lldb::RegisterKind m_register_kind; // The RegisterKind these register numbers
// are in terms of - will need to be
Expand Down
12 changes: 6 additions & 6 deletions lldb/source/Symbol/UnwindPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,24 +392,24 @@ bool UnwindPlan::Row::operator==(const UnwindPlan::Row &rhs) const {

void UnwindPlan::AppendRow(Row row) {
if (m_row_list.empty() || m_row_list.back()->GetOffset() != row.GetOffset())
m_row_list.push_back(std::make_shared<Row>(std::move(row)));
m_row_list.push_back(std::make_unique<Row>(std::move(row)));
else
*m_row_list.back() = std::move(row);
}

struct RowLess {
bool operator()(addr_t a, const UnwindPlan::RowSP &b) const {
bool operator()(addr_t a, const UnwindPlan::RowUP &b) const {
return a < b->GetOffset();
}
bool operator()(const UnwindPlan::RowSP &a, addr_t b) const {
bool operator()(const UnwindPlan::RowUP &a, addr_t b) const {
return a->GetOffset() < b;
}
};

void UnwindPlan::InsertRow(Row row, bool replace_existing) {
auto it = llvm::lower_bound(m_row_list, row.GetOffset(), RowLess());
if (it == m_row_list.end() || it->get()->GetOffset() > row.GetOffset())
m_row_list.insert(it, std::make_shared<Row>(std::move(row)));
m_row_list.insert(it, std::make_unique<Row>(std::move(row)));
else {
assert(it->get()->GetOffset() == row.GetOffset());
if (replace_existing)
Expand Down Expand Up @@ -567,9 +567,9 @@ void UnwindPlan::Dump(Stream &s, Thread *thread, lldb::addr_t base_addr) const {
range.Dump(&s, target_sp.get(), Address::DumpStyleSectionNameOffset);
s.EOL();
}
for (const auto &[index, row_sp] : llvm::enumerate(m_row_list)) {
for (const auto &[index, row_up] : llvm::enumerate(m_row_list)) {
s.Format("row[{0}]: ", index);
row_sp->Dump(s, this, thread, base_addr);
row_up->Dump(s, this, thread, base_addr);
s << "\n";
}
}
Expand Down