aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Breakpoint
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Breakpoint')
-rw-r--r--lldb/source/Breakpoint/Breakpoint.cpp17
-rw-r--r--lldb/source/Breakpoint/BreakpointList.cpp8
-rw-r--r--lldb/source/Breakpoint/BreakpointLocation.cpp8
-rw-r--r--lldb/source/Breakpoint/BreakpointLocationCollection.cpp20
-rw-r--r--lldb/source/Breakpoint/BreakpointResolverFileLine.cpp2
-rw-r--r--lldb/source/Breakpoint/BreakpointResolverName.cpp33
-rw-r--r--lldb/source/Breakpoint/BreakpointSite.cpp16
7 files changed, 59 insertions, 45 deletions
diff --git a/lldb/source/Breakpoint/Breakpoint.cpp b/lldb/source/Breakpoint/Breakpoint.cpp
index b23d114..201d8d2 100644
--- a/lldb/source/Breakpoint/Breakpoint.cpp
+++ b/lldb/source/Breakpoint/Breakpoint.cpp
@@ -1098,14 +1098,9 @@ bool Breakpoint::EvaluatePrecondition(StoppointCallbackContext &context) {
}
void Breakpoint::SendBreakpointChangedEvent(
- lldb::BreakpointEventType eventKind) {
- if (!IsInternal() && GetTarget().EventTypeHasListeners(
- Target::eBroadcastBitBreakpointChanged)) {
- std::shared_ptr<BreakpointEventData> data =
- std::make_shared<BreakpointEventData>(eventKind, shared_from_this());
-
- GetTarget().BroadcastEvent(Target::eBroadcastBitBreakpointChanged, data);
- }
+ lldb::BreakpointEventType event_kind) {
+ if (!IsInternal())
+ GetTarget().NotifyBreakpointChanged(*this, event_kind);
}
void Breakpoint::SendBreakpointChangedEvent(
@@ -1113,10 +1108,8 @@ void Breakpoint::SendBreakpointChangedEvent(
if (!breakpoint_data_sp)
return;
- if (!IsInternal() &&
- GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged))
- GetTarget().BroadcastEvent(Target::eBroadcastBitBreakpointChanged,
- breakpoint_data_sp);
+ if (!IsInternal())
+ GetTarget().NotifyBreakpointChanged(*this, breakpoint_data_sp);
}
const char *Breakpoint::BreakpointEventTypeAsCString(BreakpointEventType type) {
diff --git a/lldb/source/Breakpoint/BreakpointList.cpp b/lldb/source/Breakpoint/BreakpointList.cpp
index 779490a..e3dd62b 100644
--- a/lldb/source/Breakpoint/BreakpointList.cpp
+++ b/lldb/source/Breakpoint/BreakpointList.cpp
@@ -16,13 +16,7 @@ using namespace lldb;
using namespace lldb_private;
static void NotifyChange(const BreakpointSP &bp, BreakpointEventType event) {
- Target &target = bp->GetTarget();
- if (target.EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged)) {
- auto event_data_sp =
- std::make_shared<Breakpoint::BreakpointEventData>(event, bp);
- target.BroadcastEvent(Target::eBroadcastBitBreakpointChanged,
- event_data_sp);
- }
+ bp->GetTarget().NotifyBreakpointChanged(*bp, event);
}
BreakpointList::BreakpointList(bool is_internal)
diff --git a/lldb/source/Breakpoint/BreakpointLocation.cpp b/lldb/source/Breakpoint/BreakpointLocation.cpp
index 22c98ac..25285be 100644
--- a/lldb/source/Breakpoint/BreakpointLocation.cpp
+++ b/lldb/source/Breakpoint/BreakpointLocation.cpp
@@ -251,7 +251,7 @@ bool BreakpointLocation::ConditionSaysStop(ExecutionContext &exe_ctx,
}
m_user_expression_sp.reset(GetTarget().GetUserExpressionForLanguage(
- condition.GetText(), llvm::StringRef(), language,
+ condition.GetText(), llvm::StringRef(), SourceLanguage{language},
Expression::eResultTypeAny, EvaluateExpressionOptions(), nullptr,
error));
if (error.Fail()) {
@@ -749,13 +749,11 @@ void BreakpointLocation::Dump(Stream *s) const {
void BreakpointLocation::SendBreakpointLocationChangedEvent(
lldb::BreakpointEventType eventKind) {
- if (!m_owner.IsInternal() && m_owner.GetTarget().EventTypeHasListeners(
- Target::eBroadcastBitBreakpointChanged)) {
+ if (!m_owner.IsInternal()) {
auto data_sp = std::make_shared<Breakpoint::BreakpointEventData>(
eventKind, m_owner.shared_from_this());
data_sp->GetBreakpointLocationCollection().Add(shared_from_this());
- m_owner.GetTarget().BroadcastEvent(Target::eBroadcastBitBreakpointChanged,
- data_sp);
+ m_owner.GetTarget().NotifyBreakpointChanged(m_owner, data_sp);
}
}
diff --git a/lldb/source/Breakpoint/BreakpointLocationCollection.cpp b/lldb/source/Breakpoint/BreakpointLocationCollection.cpp
index 9771583..adff429 100644
--- a/lldb/source/Breakpoint/BreakpointLocationCollection.cpp
+++ b/lldb/source/Breakpoint/BreakpointLocationCollection.cpp
@@ -24,7 +24,7 @@ BreakpointLocationCollection::BreakpointLocationCollection(bool preserving)
BreakpointLocationCollection::~BreakpointLocationCollection() = default;
void BreakpointLocationCollection::Add(const BreakpointLocationSP &bp_loc) {
- std::lock_guard<std::mutex> guard(m_collection_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_collection_mutex);
BreakpointLocationSP old_bp_loc =
FindByIDPair(bp_loc->GetBreakpoint().GetID(), bp_loc->GetID());
if (!old_bp_loc.get()) {
@@ -44,7 +44,7 @@ void BreakpointLocationCollection::Add(const BreakpointLocationSP &bp_loc) {
bool BreakpointLocationCollection::Remove(lldb::break_id_t bp_id,
lldb::break_id_t bp_loc_id) {
- std::lock_guard<std::mutex> guard(m_collection_mutex);
+ std::lock_guard<std::recursive_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) {
@@ -117,7 +117,7 @@ const BreakpointLocationSP BreakpointLocationCollection::FindByIDPair(
}
BreakpointLocationSP BreakpointLocationCollection::GetByIndex(size_t i) {
- std::lock_guard<std::mutex> guard(m_collection_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_collection_mutex);
BreakpointLocationSP stop_sp;
if (i < m_break_loc_collection.size())
stop_sp = m_break_loc_collection[i];
@@ -127,7 +127,7 @@ BreakpointLocationSP BreakpointLocationCollection::GetByIndex(size_t i) {
const BreakpointLocationSP
BreakpointLocationCollection::GetByIndex(size_t i) const {
- std::lock_guard<std::mutex> guard(m_collection_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_collection_mutex);
BreakpointLocationSP stop_sp;
if (i < m_break_loc_collection.size())
stop_sp = m_break_loc_collection[i];
@@ -168,7 +168,7 @@ bool BreakpointLocationCollection::ShouldStop(
}
bool BreakpointLocationCollection::ValidForThisThread(Thread &thread) {
- std::lock_guard<std::mutex> guard(m_collection_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_collection_mutex);
collection::iterator pos, begin = m_break_loc_collection.begin(),
end = m_break_loc_collection.end();
@@ -180,7 +180,7 @@ bool BreakpointLocationCollection::ValidForThisThread(Thread &thread) {
}
bool BreakpointLocationCollection::IsInternal() const {
- std::lock_guard<std::mutex> guard(m_collection_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_collection_mutex);
collection::const_iterator pos, begin = m_break_loc_collection.begin(),
end = m_break_loc_collection.end();
@@ -197,7 +197,7 @@ bool BreakpointLocationCollection::IsInternal() const {
void BreakpointLocationCollection::GetDescription(
Stream *s, lldb::DescriptionLevel level) {
- std::lock_guard<std::mutex> guard(m_collection_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_collection_mutex);
collection::iterator pos, begin = m_break_loc_collection.begin(),
end = m_break_loc_collection.end();
@@ -212,8 +212,10 @@ BreakpointLocationCollection &BreakpointLocationCollection::operator=(
const BreakpointLocationCollection &rhs) {
if (this != &rhs) {
std::lock(m_collection_mutex, rhs.m_collection_mutex);
- std::lock_guard<std::mutex> lhs_guard(m_collection_mutex, std::adopt_lock);
- std::lock_guard<std::mutex> rhs_guard(rhs.m_collection_mutex, std::adopt_lock);
+ std::lock_guard<std::recursive_mutex> lhs_guard(m_collection_mutex,
+ std::adopt_lock);
+ std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_collection_mutex,
+ std::adopt_lock);
m_break_loc_collection = rhs.m_break_loc_collection;
}
return *this;
diff --git a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
index a94e9e2..cef1ef1 100644
--- a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
@@ -139,7 +139,7 @@ void BreakpointResolverFileLine::FilterContexts(SymbolContextList &sc_list) {
if (!sc.block)
continue;
- SupportFileSP file_sp;
+ SupportFileNSP file_sp = std::make_shared<SupportFile>();
uint32_t line;
const Block *inline_block = sc.block->GetContainingInlinedBlock();
if (inline_block) {
diff --git a/lldb/source/Breakpoint/BreakpointResolverName.cpp b/lldb/source/Breakpoint/BreakpointResolverName.cpp
index 4f252f9..2025f59 100644
--- a/lldb/source/Breakpoint/BreakpointResolverName.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverName.cpp
@@ -218,19 +218,22 @@ StructuredData::ObjectSP BreakpointResolverName::SerializeToStructuredData() {
void BreakpointResolverName::AddNameLookup(ConstString name,
FunctionNameType name_type_mask) {
-
- Module::LookupInfo lookup(name, name_type_mask, m_language);
- m_lookups.emplace_back(lookup);
+ std::vector<Module::LookupInfo> infos =
+ Module::LookupInfo::MakeLookupInfos(name, name_type_mask, m_language);
+ llvm::append_range(m_lookups, infos);
auto add_variant_funcs = [&](Language *lang) {
for (Language::MethodNameVariant variant :
lang->GetMethodNameVariants(name)) {
// FIXME: Should we be adding variants that aren't of type Full?
if (variant.GetType() & lldb::eFunctionNameTypeFull) {
- Module::LookupInfo variant_lookup(name, variant.GetType(),
- lang->GetLanguageType());
- variant_lookup.SetLookupName(variant.GetName());
- m_lookups.emplace_back(variant_lookup);
+ std::vector<Module::LookupInfo> variant_lookups =
+ Module::LookupInfo::MakeLookupInfos(name, variant.GetType(),
+ lang->GetLanguageType());
+ llvm::for_each(variant_lookups, [&](auto &variant_lookup) {
+ variant_lookup.SetLookupName(variant.GetName());
+ });
+ llvm::append_range(m_lookups, variant_lookups);
}
}
return IterationAction::Continue;
@@ -401,14 +404,22 @@ void BreakpointResolverName::GetDescription(Stream *s) {
if (m_match_type == Breakpoint::Regexp)
s->Printf("regex = '%s'", m_regex.GetText().str().c_str());
else {
- size_t num_names = m_lookups.size();
- if (num_names == 1)
- s->Printf("name = '%s'", m_lookups[0].GetName().GetCString());
+ // Since there may be many lookups objects for the same name breakpoint (one
+ // per language available), unique them by name, and operate on those unique
+ // names.
+ std::vector<ConstString> unique_lookups;
+ for (auto &lookup : m_lookups) {
+ if (!llvm::is_contained(unique_lookups, lookup.GetName()))
+ unique_lookups.push_back(lookup.GetName());
+ }
+ if (unique_lookups.size() == 1)
+ s->Printf("name = '%s'", unique_lookups[0].GetCString());
else {
+ size_t num_names = unique_lookups.size();
s->Printf("names = {");
for (size_t i = 0; i < num_names; i++) {
s->Printf("%s'%s'", (i == 0 ? "" : ", "),
- m_lookups[i].GetName().GetCString());
+ unique_lookups[i].GetCString());
}
s->Printf("}");
}
diff --git a/lldb/source/Breakpoint/BreakpointSite.cpp b/lldb/source/Breakpoint/BreakpointSite.cpp
index fd7666b..8639379 100644
--- a/lldb/source/Breakpoint/BreakpointSite.cpp
+++ b/lldb/source/Breakpoint/BreakpointSite.cpp
@@ -168,6 +168,22 @@ bool BreakpointSite::ValidForThisThread(Thread &thread) {
return m_constituents.ValidForThisThread(thread);
}
+bool BreakpointSite::ContainsUserBreakpointForThread(Thread &thread) {
+ if (ThreadSP backed_thread = thread.GetBackedThread())
+ return ContainsUserBreakpointForThread(*backed_thread);
+
+ std::lock_guard<std::recursive_mutex> guard(m_constituents_mutex);
+ for (const BreakpointLocationSP &bp_loc :
+ m_constituents.BreakpointLocations()) {
+ const Breakpoint &bp = bp_loc->GetBreakpoint();
+ if (bp.IsInternal())
+ continue;
+ if (bp_loc->ValidForThisThread(thread))
+ return true;
+ }
+ return false;
+}
+
void BreakpointSite::BumpHitCounts() {
std::lock_guard<std::recursive_mutex> guard(m_constituents_mutex);
for (BreakpointLocationSP loc_sp : m_constituents.BreakpointLocations()) {