Skip to content

Commit 7de870c

Browse files
committed
Store a BreakpointSP per BreakpointLocation, rather than manually refcounting.
1 parent 2925924 commit 7de870c

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

lldb/include/lldb/Breakpoint/BreakpointLocationCollection.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,7 @@ class BreakpointLocationCollection {
175175
mutable std::mutex m_collection_mutex;
176176
/// These are used if we're preserving breakpoints in this list:
177177
const bool m_preserving_bkpts = false;
178-
struct RefCountedBPSP {
179-
RefCountedBPSP(lldb::BreakpointSP in_bp_sp) : ref_cnt(1), bp_sp(in_bp_sp) {}
180-
uint64_t ref_cnt;
181-
lldb::BreakpointSP bp_sp;
182-
};
183-
std::map<lldb::break_id_t, RefCountedBPSP> m_preserved_bps;
178+
std::map<std::pair<lldb::break_id_t, lldb::break_id_t>, lldb::BreakpointSP> m_preserved_bps;
184179

185180
public:
186181
typedef llvm::iterator_range<collection::const_iterator>

lldb/source/Breakpoint/BreakpointLocationCollection.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ void BreakpointLocationCollection::Add(const BreakpointLocationSP &bp_loc) {
3030
if (!old_bp_loc.get()) {
3131
m_break_loc_collection.push_back(bp_loc);
3232
if (m_preserving_bkpts) {
33+
lldb::break_id_t bp_loc_id = bp_loc->GetID();
3334
Breakpoint &bkpt = bp_loc->GetBreakpoint();
3435
lldb::break_id_t bp_id = bkpt.GetID();
35-
auto entry = m_preserved_bps.find(bp_id);
36+
std::pair<lldb::break_id_t, lldb::break_id_t> key
37+
= std::make_pair(bp_id, bp_loc_id);
38+
auto entry = m_preserved_bps.find(key);
3639
if (entry == m_preserved_bps.end())
37-
m_preserved_bps.emplace(bp_id, RefCountedBPSP(bkpt.shared_from_this()));
38-
else
39-
entry->second.ref_cnt++;
40+
m_preserved_bps.emplace(key, bkpt.shared_from_this());
4041
}
4142
}
4243
}
@@ -47,10 +48,12 @@ bool BreakpointLocationCollection::Remove(lldb::break_id_t bp_id,
4748
collection::iterator pos = GetIDPairIterator(bp_id, bp_loc_id); // Predicate
4849
if (pos != m_break_loc_collection.end()) {
4950
if (m_preserving_bkpts) {
50-
auto entry = m_preserved_bps.find(bp_id);
51-
assert(entry != m_preserved_bps.end() &&
52-
"Breakpoint added to base but not preserving map.");
53-
if (--entry->second.ref_cnt == 0)
51+
std::pair<lldb::break_id_t, lldb::break_id_t> key
52+
= std::make_pair(bp_id, bp_loc_id);
53+
auto entry = m_preserved_bps.find(key);
54+
if (entry == m_preserved_bps.end())
55+
assert(0 && "Breakpoint added to collection but not preserving map.");
56+
else
5457
m_preserved_bps.erase(entry);
5558
}
5659
m_break_loc_collection.erase(pos);

0 commit comments

Comments
 (0)