aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Breakpoint
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Breakpoint')
-rw-r--r--lldb/source/Breakpoint/BreakpointLocationCollection.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/lldb/source/Breakpoint/BreakpointLocationCollection.cpp b/lldb/source/Breakpoint/BreakpointLocationCollection.cpp
index 1d052c5..9771583 100644
--- a/lldb/source/Breakpoint/BreakpointLocationCollection.cpp
+++ b/lldb/source/Breakpoint/BreakpointLocationCollection.cpp
@@ -17,7 +17,8 @@ using namespace lldb;
using namespace lldb_private;
// BreakpointLocationCollection constructor
-BreakpointLocationCollection::BreakpointLocationCollection() = default;
+BreakpointLocationCollection::BreakpointLocationCollection(bool preserving)
+ : m_preserving_bkpts(preserving) {}
// Destructor
BreakpointLocationCollection::~BreakpointLocationCollection() = default;
@@ -26,8 +27,19 @@ void BreakpointLocationCollection::Add(const BreakpointLocationSP &bp_loc) {
std::lock_guard<std::mutex> guard(m_collection_mutex);
BreakpointLocationSP old_bp_loc =
FindByIDPair(bp_loc->GetBreakpoint().GetID(), bp_loc->GetID());
- if (!old_bp_loc.get())
+ if (!old_bp_loc.get()) {
m_break_loc_collection.push_back(bp_loc);
+ if (m_preserving_bkpts) {
+ lldb::break_id_t bp_loc_id = bp_loc->GetID();
+ Breakpoint &bkpt = bp_loc->GetBreakpoint();
+ lldb::break_id_t bp_id = bkpt.GetID();
+ std::pair<lldb::break_id_t, lldb::break_id_t> key =
+ std::make_pair(bp_id, bp_loc_id);
+ auto entry = m_preserved_bps.find(key);
+ if (entry == m_preserved_bps.end())
+ m_preserved_bps.emplace(key, bkpt.shared_from_this());
+ }
+ }
}
bool BreakpointLocationCollection::Remove(lldb::break_id_t bp_id,
@@ -35,6 +47,15 @@ bool BreakpointLocationCollection::Remove(lldb::break_id_t bp_id,
std::lock_guard<std::mutex> guard(m_collection_mutex);
collection::iterator pos = GetIDPairIterator(bp_id, bp_loc_id); // Predicate
if (pos != m_break_loc_collection.end()) {
+ if (m_preserving_bkpts) {
+ std::pair<lldb::break_id_t, lldb::break_id_t> key =
+ std::make_pair(bp_id, bp_loc_id);
+ auto entry = m_preserved_bps.find(key);
+ if (entry == m_preserved_bps.end())
+ assert(0 && "Breakpoint added to collection but not preserving map.");
+ else
+ m_preserved_bps.erase(entry);
+ }
m_break_loc_collection.erase(pos);
return true;
}