aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Breakpoint
diff options
context:
space:
mode:
authorKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
committerKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
commitb9c1b51e45b845debb76d8658edabca70ca56079 (patch)
treedfcb5a13ef2b014202340f47036da383eaee74aa /lldb/source/Breakpoint
parentd5aa73376966339caad04013510626ec2e42c760 (diff)
downloadllvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip
llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz
llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.bz2
*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has *** two obvious implications: Firstly, merging this particular commit into a downstream fork may be a huge effort. Alternatively, it may be worth merging all changes up to this commit, performing the same reformatting operation locally, and then discarding the merge for this particular commit. The commands used to accomplish this reformatting were as follows (with current working directory as the root of the repository): find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} + find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ; The version of clang-format used was 3.9.0, and autopep8 was 1.2.4. Secondly, “blame” style tools will generally point to this commit instead of a meaningful prior commit. There are alternatives available that will attempt to look through this change and find the appropriate prior commit. YMMV. llvm-svn: 280751
Diffstat (limited to 'lldb/source/Breakpoint')
-rw-r--r--lldb/source/Breakpoint/Breakpoint.cpp1599
-rw-r--r--lldb/source/Breakpoint/BreakpointID.cpp167
-rw-r--r--lldb/source/Breakpoint/BreakpointIDList.cpp678
-rw-r--r--lldb/source/Breakpoint/BreakpointList.cpp343
-rw-r--r--lldb/source/Breakpoint/BreakpointLocation.cpp1115
-rw-r--r--lldb/source/Breakpoint/BreakpointLocationCollection.cpp272
-rw-r--r--lldb/source/Breakpoint/BreakpointLocationList.cpp503
-rw-r--r--lldb/source/Breakpoint/BreakpointOptions.cpp373
-rw-r--r--lldb/source/Breakpoint/BreakpointResolver.cpp323
-rw-r--r--lldb/source/Breakpoint/BreakpointResolverAddress.cpp218
-rw-r--r--lldb/source/Breakpoint/BreakpointResolverFileLine.cpp145
-rw-r--r--lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp166
-rw-r--r--lldb/source/Breakpoint/BreakpointResolverName.cpp572
-rw-r--r--lldb/source/Breakpoint/BreakpointSite.cpp315
-rw-r--r--lldb/source/Breakpoint/BreakpointSiteList.cpp342
-rw-r--r--lldb/source/Breakpoint/Stoppoint.cpp23
-rw-r--r--lldb/source/Breakpoint/StoppointCallbackContext.cpp27
-rw-r--r--lldb/source/Breakpoint/StoppointLocation.cpp38
-rw-r--r--lldb/source/Breakpoint/Watchpoint.cpp655
-rw-r--r--lldb/source/Breakpoint/WatchpointList.cpp407
-rw-r--r--lldb/source/Breakpoint/WatchpointOptions.cpp282
21 files changed, 3758 insertions, 4805 deletions
diff --git a/lldb/source/Breakpoint/Breakpoint.cpp b/lldb/source/Breakpoint/Breakpoint.cpp
index 224f266..78354e2 100644
--- a/lldb/source/Breakpoint/Breakpoint.cpp
+++ b/lldb/source/Breakpoint/Breakpoint.cpp
@@ -13,12 +13,12 @@
#include "llvm/Support/Casting.h"
// Project includes
-#include "lldb/Core/Address.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Breakpoint/BreakpointLocationCollection.h"
#include "lldb/Breakpoint/BreakpointResolver.h"
#include "lldb/Breakpoint/BreakpointResolverFileLine.h"
+#include "lldb/Core/Address.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
@@ -36,47 +36,33 @@ using namespace lldb;
using namespace lldb_private;
using namespace llvm;
-const ConstString &
-Breakpoint::GetEventIdentifier ()
-{
- static ConstString g_identifier("event-identifier.breakpoint.changed");
- return g_identifier;
+const ConstString &Breakpoint::GetEventIdentifier() {
+ static ConstString g_identifier("event-identifier.breakpoint.changed");
+ return g_identifier;
}
//----------------------------------------------------------------------
// Breakpoint constructor
//----------------------------------------------------------------------
-Breakpoint::Breakpoint(Target &target,
- SearchFilterSP &filter_sp,
- BreakpointResolverSP &resolver_sp,
- bool hardware,
- bool resolve_indirect_symbols) :
- m_being_created(true),
- m_hardware(hardware),
- m_target (target),
- m_filter_sp (filter_sp),
- m_resolver_sp (resolver_sp),
- m_options (),
- m_locations (*this),
- m_resolve_indirect_symbols(resolve_indirect_symbols),
- m_hit_count(0)
-{
- m_being_created = false;
-}
-
-Breakpoint::Breakpoint (Target &new_target, Breakpoint &source_bp) :
- m_being_created(true),
- m_hardware(source_bp.m_hardware),
- m_target(new_target),
- m_name_list (source_bp.m_name_list),
- m_options (source_bp.m_options),
- m_locations(*this),
- m_resolve_indirect_symbols(source_bp.m_resolve_indirect_symbols),
- m_hit_count(0)
-{
- // Now go through and copy the filter & resolver:
- m_resolver_sp = source_bp.m_resolver_sp->CopyForBreakpoint(*this);
- m_filter_sp = source_bp.m_filter_sp->CopyForBreakpoint(*this);
+Breakpoint::Breakpoint(Target &target, SearchFilterSP &filter_sp,
+ BreakpointResolverSP &resolver_sp, bool hardware,
+ bool resolve_indirect_symbols)
+ : m_being_created(true), m_hardware(hardware), m_target(target),
+ m_filter_sp(filter_sp), m_resolver_sp(resolver_sp), m_options(),
+ m_locations(*this), m_resolve_indirect_symbols(resolve_indirect_symbols),
+ m_hit_count(0) {
+ m_being_created = false;
+}
+
+Breakpoint::Breakpoint(Target &new_target, Breakpoint &source_bp)
+ : m_being_created(true), m_hardware(source_bp.m_hardware),
+ m_target(new_target), m_name_list(source_bp.m_name_list),
+ m_options(source_bp.m_options), m_locations(*this),
+ m_resolve_indirect_symbols(source_bp.m_resolve_indirect_symbols),
+ m_hit_count(0) {
+ // Now go through and copy the filter & resolver:
+ m_resolver_sp = source_bp.m_resolver_sp->CopyForBreakpoint(*this);
+ m_filter_sp = source_bp.m_filter_sp->CopyForBreakpoint(*this);
}
//----------------------------------------------------------------------
@@ -84,52 +70,36 @@ Breakpoint::Breakpoint (Target &new_target, Breakpoint &source_bp) :
//----------------------------------------------------------------------
Breakpoint::~Breakpoint() = default;
-const lldb::TargetSP
-Breakpoint::GetTargetSP ()
-{
- return m_target.shared_from_this();
+const lldb::TargetSP Breakpoint::GetTargetSP() {
+ return m_target.shared_from_this();
}
-bool
-Breakpoint::IsInternal () const
-{
- return LLDB_BREAK_ID_IS_INTERNAL(m_bid);
-}
+bool Breakpoint::IsInternal() const { return LLDB_BREAK_ID_IS_INTERNAL(m_bid); }
-BreakpointLocationSP
-Breakpoint::AddLocation (const Address &addr, bool *new_location)
-{
- return m_locations.AddLocation (addr, m_resolve_indirect_symbols, new_location);
+BreakpointLocationSP Breakpoint::AddLocation(const Address &addr,
+ bool *new_location) {
+ return m_locations.AddLocation(addr, m_resolve_indirect_symbols,
+ new_location);
}
-BreakpointLocationSP
-Breakpoint::FindLocationByAddress (const Address &addr)
-{
- return m_locations.FindByAddress(addr);
+BreakpointLocationSP Breakpoint::FindLocationByAddress(const Address &addr) {
+ return m_locations.FindByAddress(addr);
}
-break_id_t
-Breakpoint::FindLocationIDByAddress (const Address &addr)
-{
- return m_locations.FindIDByAddress(addr);
+break_id_t Breakpoint::FindLocationIDByAddress(const Address &addr) {
+ return m_locations.FindIDByAddress(addr);
}
-BreakpointLocationSP
-Breakpoint::FindLocationByID (break_id_t bp_loc_id)
-{
- return m_locations.FindByID(bp_loc_id);
+BreakpointLocationSP Breakpoint::FindLocationByID(break_id_t bp_loc_id) {
+ return m_locations.FindByID(bp_loc_id);
}
-BreakpointLocationSP
-Breakpoint::GetLocationAtIndex (size_t index)
-{
- return m_locations.GetByIndex(index);
+BreakpointLocationSP Breakpoint::GetLocationAtIndex(size_t index) {
+ return m_locations.GetByIndex(index);
}
-void
-Breakpoint::RemoveInvalidLocations (const ArchSpec &arch)
-{
- m_locations.RemoveInvalidLocations(arch);
+void Breakpoint::RemoveInvalidLocations(const ArchSpec &arch) {
+ m_locations.RemoveInvalidLocations(arch);
}
// For each of the overall options we need to decide how they propagate to
@@ -140,962 +110,815 @@ Breakpoint::RemoveInvalidLocations (const ArchSpec &arch)
// That way you can conveniently turn off a whole breakpoint without messing
// up the individual settings.
-void
-Breakpoint::SetEnabled (bool enable)
-{
- if (enable == m_options.IsEnabled())
- return;
+void Breakpoint::SetEnabled(bool enable) {
+ if (enable == m_options.IsEnabled())
+ return;
- m_options.SetEnabled(enable);
- if (enable)
- m_locations.ResolveAllBreakpointSites();
- else
- m_locations.ClearAllBreakpointSites();
-
- SendBreakpointChangedEvent (enable ? eBreakpointEventTypeEnabled : eBreakpointEventTypeDisabled);
+ m_options.SetEnabled(enable);
+ if (enable)
+ m_locations.ResolveAllBreakpointSites();
+ else
+ m_locations.ClearAllBreakpointSites();
+ SendBreakpointChangedEvent(enable ? eBreakpointEventTypeEnabled
+ : eBreakpointEventTypeDisabled);
}
-bool
-Breakpoint::IsEnabled ()
-{
- return m_options.IsEnabled();
-}
+bool Breakpoint::IsEnabled() { return m_options.IsEnabled(); }
-void
-Breakpoint::SetIgnoreCount (uint32_t n)
-{
- if (m_options.GetIgnoreCount() == n)
- return;
-
- m_options.SetIgnoreCount(n);
- SendBreakpointChangedEvent (eBreakpointEventTypeIgnoreChanged);
-}
+void Breakpoint::SetIgnoreCount(uint32_t n) {
+ if (m_options.GetIgnoreCount() == n)
+ return;
-void
-Breakpoint::DecrementIgnoreCount ()
-{
- uint32_t ignore = m_options.GetIgnoreCount();
- if (ignore != 0)
- m_options.SetIgnoreCount(ignore - 1);
+ m_options.SetIgnoreCount(n);
+ SendBreakpointChangedEvent(eBreakpointEventTypeIgnoreChanged);
}
-uint32_t
-Breakpoint::GetIgnoreCount () const
-{
- return m_options.GetIgnoreCount();
+void Breakpoint::DecrementIgnoreCount() {
+ uint32_t ignore = m_options.GetIgnoreCount();
+ if (ignore != 0)
+ m_options.SetIgnoreCount(ignore - 1);
}
-bool
-Breakpoint::IgnoreCountShouldStop ()
-{
- uint32_t ignore = GetIgnoreCount();
- if (ignore != 0)
- {
- // When we get here we know the location that caused the stop doesn't have an ignore count,
- // since by contract we call it first... So we don't have to find & decrement it, we only have
- // to decrement our own ignore count.
- DecrementIgnoreCount();
- return false;
- }
- else
- return true;
+uint32_t Breakpoint::GetIgnoreCount() const {
+ return m_options.GetIgnoreCount();
}
-uint32_t
-Breakpoint::GetHitCount () const
-{
- return m_hit_count;
+bool Breakpoint::IgnoreCountShouldStop() {
+ uint32_t ignore = GetIgnoreCount();
+ if (ignore != 0) {
+ // When we get here we know the location that caused the stop doesn't have
+ // an ignore count,
+ // since by contract we call it first... So we don't have to find &
+ // decrement it, we only have
+ // to decrement our own ignore count.
+ DecrementIgnoreCount();
+ return false;
+ } else
+ return true;
}
-bool
-Breakpoint::IsOneShot () const
-{
- return m_options.IsOneShot();
-}
+uint32_t Breakpoint::GetHitCount() const { return m_hit_count; }
-void
-Breakpoint::SetOneShot (bool one_shot)
-{
- m_options.SetOneShot (one_shot);
-}
+bool Breakpoint::IsOneShot() const { return m_options.IsOneShot(); }
-void
-Breakpoint::SetThreadID (lldb::tid_t thread_id)
-{
- if (m_options.GetThreadSpec()->GetTID() == thread_id)
- return;
-
- m_options.GetThreadSpec()->SetTID(thread_id);
- SendBreakpointChangedEvent (eBreakpointEventTypeThreadChanged);
+void Breakpoint::SetOneShot(bool one_shot) { m_options.SetOneShot(one_shot); }
+
+void Breakpoint::SetThreadID(lldb::tid_t thread_id) {
+ if (m_options.GetThreadSpec()->GetTID() == thread_id)
+ return;
+
+ m_options.GetThreadSpec()->SetTID(thread_id);
+ SendBreakpointChangedEvent(eBreakpointEventTypeThreadChanged);
}
-lldb::tid_t
-Breakpoint::GetThreadID () const
-{
- if (m_options.GetThreadSpecNoCreate() == nullptr)
- return LLDB_INVALID_THREAD_ID;
- else
- return m_options.GetThreadSpecNoCreate()->GetTID();
+lldb::tid_t Breakpoint::GetThreadID() const {
+ if (m_options.GetThreadSpecNoCreate() == nullptr)
+ return LLDB_INVALID_THREAD_ID;
+ else
+ return m_options.GetThreadSpecNoCreate()->GetTID();
}
-void
-Breakpoint::SetThreadIndex (uint32_t index)
-{
- if (m_options.GetThreadSpec()->GetIndex() == index)
- return;
-
- m_options.GetThreadSpec()->SetIndex(index);
- SendBreakpointChangedEvent (eBreakpointEventTypeThreadChanged);
+void Breakpoint::SetThreadIndex(uint32_t index) {
+ if (m_options.GetThreadSpec()->GetIndex() == index)
+ return;
+
+ m_options.GetThreadSpec()->SetIndex(index);
+ SendBreakpointChangedEvent(eBreakpointEventTypeThreadChanged);
}
-uint32_t
-Breakpoint::GetThreadIndex() const
-{
- if (m_options.GetThreadSpecNoCreate() == nullptr)
- return 0;
- else
- return m_options.GetThreadSpecNoCreate()->GetIndex();
+uint32_t Breakpoint::GetThreadIndex() const {
+ if (m_options.GetThreadSpecNoCreate() == nullptr)
+ return 0;
+ else
+ return m_options.GetThreadSpecNoCreate()->GetIndex();
}
-void
-Breakpoint::SetThreadName (const char *thread_name)
-{
- if (m_options.GetThreadSpec()->GetName() != nullptr
- && ::strcmp (m_options.GetThreadSpec()->GetName(), thread_name) == 0)
- return;
-
- m_options.GetThreadSpec()->SetName (thread_name);
- SendBreakpointChangedEvent (eBreakpointEventTypeThreadChanged);
+void Breakpoint::SetThreadName(const char *thread_name) {
+ if (m_options.GetThreadSpec()->GetName() != nullptr &&
+ ::strcmp(m_options.GetThreadSpec()->GetName(), thread_name) == 0)
+ return;
+
+ m_options.GetThreadSpec()->SetName(thread_name);
+ SendBreakpointChangedEvent(eBreakpointEventTypeThreadChanged);
}
-const char *
-Breakpoint::GetThreadName () const
-{
- if (m_options.GetThreadSpecNoCreate() == nullptr)
- return nullptr;
- else
- return m_options.GetThreadSpecNoCreate()->GetName();
+const char *Breakpoint::GetThreadName() const {
+ if (m_options.GetThreadSpecNoCreate() == nullptr)
+ return nullptr;
+ else
+ return m_options.GetThreadSpecNoCreate()->GetName();
}
-void
-Breakpoint::SetQueueName (const char *queue_name)
-{
- if (m_options.GetThreadSpec()->GetQueueName() != nullptr
- && ::strcmp (m_options.GetThreadSpec()->GetQueueName(), queue_name) == 0)
- return;
-
- m_options.GetThreadSpec()->SetQueueName (queue_name);
- SendBreakpointChangedEvent (eBreakpointEventTypeThreadChanged);
+void Breakpoint::SetQueueName(const char *queue_name) {
+ if (m_options.GetThreadSpec()->GetQueueName() != nullptr &&
+ ::strcmp(m_options.GetThreadSpec()->GetQueueName(), queue_name) == 0)
+ return;
+
+ m_options.GetThreadSpec()->SetQueueName(queue_name);
+ SendBreakpointChangedEvent(eBreakpointEventTypeThreadChanged);
}
-const char *
-Breakpoint::GetQueueName () const
-{
- if (m_options.GetThreadSpecNoCreate() == nullptr)
- return nullptr;
- else
- return m_options.GetThreadSpecNoCreate()->GetQueueName();
+const char *Breakpoint::GetQueueName() const {
+ if (m_options.GetThreadSpecNoCreate() == nullptr)
+ return nullptr;
+ else
+ return m_options.GetThreadSpecNoCreate()->GetQueueName();
}
-void
-Breakpoint::SetCondition (const char *condition)
-{
- m_options.SetCondition (condition);
- SendBreakpointChangedEvent (eBreakpointEventTypeConditionChanged);
+void Breakpoint::SetCondition(const char *condition) {
+ m_options.SetCondition(condition);
+ SendBreakpointChangedEvent(eBreakpointEventTypeConditionChanged);
}
-const char *
-Breakpoint::GetConditionText () const
-{
- return m_options.GetConditionText();
+const char *Breakpoint::GetConditionText() const {
+ return m_options.GetConditionText();
}
// This function is used when "baton" doesn't need to be freed
-void
-Breakpoint::SetCallback (BreakpointHitCallback callback, void *baton, bool is_synchronous)
-{
- // The default "Baton" class will keep a copy of "baton" and won't free
- // or delete it when it goes goes out of scope.
- m_options.SetCallback(callback, BatonSP (new Baton(baton)), is_synchronous);
-
- SendBreakpointChangedEvent (eBreakpointEventTypeCommandChanged);
+void Breakpoint::SetCallback(BreakpointHitCallback callback, void *baton,
+ bool is_synchronous) {
+ // The default "Baton" class will keep a copy of "baton" and won't free
+ // or delete it when it goes goes out of scope.
+ m_options.SetCallback(callback, BatonSP(new Baton(baton)), is_synchronous);
+
+ SendBreakpointChangedEvent(eBreakpointEventTypeCommandChanged);
}
-// This function is used when a baton needs to be freed and therefore is
+// This function is used when a baton needs to be freed and therefore is
// contained in a "Baton" subclass.
-void
-Breakpoint::SetCallback (BreakpointHitCallback callback, const BatonSP &callback_baton_sp, bool is_synchronous)
-{
- m_options.SetCallback(callback, callback_baton_sp, is_synchronous);
+void Breakpoint::SetCallback(BreakpointHitCallback callback,
+ const BatonSP &callback_baton_sp,
+ bool is_synchronous) {
+ m_options.SetCallback(callback, callback_baton_sp, is_synchronous);
}
-void
-Breakpoint::ClearCallback ()
-{
- m_options.ClearCallback ();
-}
+void Breakpoint::ClearCallback() { m_options.ClearCallback(); }
-bool
-Breakpoint::InvokeCallback (StoppointCallbackContext *context, break_id_t bp_loc_id)
-{
- return m_options.InvokeCallback (context, GetID(), bp_loc_id);
+bool Breakpoint::InvokeCallback(StoppointCallbackContext *context,
+ break_id_t bp_loc_id) {
+ return m_options.InvokeCallback(context, GetID(), bp_loc_id);
}
-BreakpointOptions *
-Breakpoint::GetOptions ()
-{
- return &m_options;
-}
+BreakpointOptions *Breakpoint::GetOptions() { return &m_options; }
-void
-Breakpoint::ResolveBreakpoint ()
-{
- if (m_resolver_sp)
- m_resolver_sp->ResolveBreakpoint(*m_filter_sp);
+void Breakpoint::ResolveBreakpoint() {
+ if (m_resolver_sp)
+ m_resolver_sp->ResolveBreakpoint(*m_filter_sp);
}
-void
-Breakpoint::ResolveBreakpointInModules (ModuleList &module_list, BreakpointLocationCollection &new_locations)
-{
- m_locations.StartRecordingNewLocations(new_locations);
-
- m_resolver_sp->ResolveBreakpointInModules(*m_filter_sp, module_list);
+void Breakpoint::ResolveBreakpointInModules(
+ ModuleList &module_list, BreakpointLocationCollection &new_locations) {
+ m_locations.StartRecordingNewLocations(new_locations);
- m_locations.StopRecordingNewLocations();
+ m_resolver_sp->ResolveBreakpointInModules(*m_filter_sp, module_list);
+
+ m_locations.StopRecordingNewLocations();
}
-void
-Breakpoint::ResolveBreakpointInModules (ModuleList &module_list, bool send_event)
-{
- if (m_resolver_sp)
- {
- // If this is not an internal breakpoint, set up to record the new locations, then dispatch
- // an event with the new locations.
- if (!IsInternal() && send_event)
- {
- BreakpointEventData *new_locations_event = new BreakpointEventData (eBreakpointEventTypeLocationsAdded,
- shared_from_this());
-
- ResolveBreakpointInModules (module_list, new_locations_event->GetBreakpointLocationCollection());
-
- if (new_locations_event->GetBreakpointLocationCollection().GetSize() != 0)
- {
- SendBreakpointChangedEvent (new_locations_event);
- }
- else
- delete new_locations_event;
- }
- else
- {
- m_resolver_sp->ResolveBreakpointInModules(*m_filter_sp, module_list);
- }
+void Breakpoint::ResolveBreakpointInModules(ModuleList &module_list,
+ bool send_event) {
+ if (m_resolver_sp) {
+ // If this is not an internal breakpoint, set up to record the new
+ // locations, then dispatch
+ // an event with the new locations.
+ if (!IsInternal() && send_event) {
+ BreakpointEventData *new_locations_event = new BreakpointEventData(
+ eBreakpointEventTypeLocationsAdded, shared_from_this());
+
+ ResolveBreakpointInModules(
+ module_list, new_locations_event->GetBreakpointLocationCollection());
+
+ if (new_locations_event->GetBreakpointLocationCollection().GetSize() !=
+ 0) {
+ SendBreakpointChangedEvent(new_locations_event);
+ } else
+ delete new_locations_event;
+ } else {
+ m_resolver_sp->ResolveBreakpointInModules(*m_filter_sp, module_list);
}
+ }
}
-void
-Breakpoint::ClearAllBreakpointSites ()
-{
- m_locations.ClearAllBreakpointSites();
+void Breakpoint::ClearAllBreakpointSites() {
+ m_locations.ClearAllBreakpointSites();
}
//----------------------------------------------------------------------
// ModulesChanged: Pass in a list of new modules, and
//----------------------------------------------------------------------
-void
-Breakpoint::ModulesChanged (ModuleList &module_list, bool load, bool delete_locations)
-{
- Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
- if (log)
- log->Printf ("Breakpoint::ModulesChanged: num_modules: %zu load: %i delete_locations: %i\n",
- module_list.GetSize(), load, delete_locations);
-
- std::lock_guard<std::recursive_mutex> guard(module_list.GetMutex());
- if (load)
- {
- // The logic for handling new modules is:
- // 1) If the filter rejects this module, then skip it.
- // 2) Run through the current location list and if there are any locations
- // for that module, we mark the module as "seen" and we don't try to re-resolve
- // breakpoint locations for that module.
- // However, we do add breakpoint sites to these locations if needed.
- // 3) If we don't see this module in our breakpoint location list, call ResolveInModules.
-
- ModuleList new_modules; // We'll stuff the "unseen" modules in this list, and then resolve
- // them after the locations pass. Have to do it this way because
- // resolving breakpoints will add new locations potentially.
-
- for (ModuleSP module_sp : module_list.ModulesNoLocking())
- {
- bool seen = false;
- if (!m_filter_sp->ModulePasses (module_sp))
- continue;
-
- for (BreakpointLocationSP break_loc_sp : m_locations.BreakpointLocations())
- {
- if (!break_loc_sp->IsEnabled())
- continue;
- SectionSP section_sp (break_loc_sp->GetAddress().GetSection());
- if (!section_sp || section_sp->GetModule() == module_sp)
- {
- if (!seen)
- seen = true;
-
- if (!break_loc_sp->ResolveBreakpointSite())
- {
- if (log)
- log->Printf ("Warning: could not set breakpoint site for breakpoint location %d of breakpoint %d.\n",
- break_loc_sp->GetID(), GetID());
- }
- }
- }
-
- if (!seen)
- new_modules.AppendIfNeeded (module_sp);
- }
-
- if (new_modules.GetSize() > 0)
- {
- ResolveBreakpointInModules(new_modules);
+void Breakpoint::ModulesChanged(ModuleList &module_list, bool load,
+ bool delete_locations) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+ if (log)
+ log->Printf("Breakpoint::ModulesChanged: num_modules: %zu load: %i "
+ "delete_locations: %i\n",
+ module_list.GetSize(), load, delete_locations);
+
+ std::lock_guard<std::recursive_mutex> guard(module_list.GetMutex());
+ if (load) {
+ // The logic for handling new modules is:
+ // 1) If the filter rejects this module, then skip it.
+ // 2) Run through the current location list and if there are any locations
+ // for that module, we mark the module as "seen" and we don't try to
+ // re-resolve
+ // breakpoint locations for that module.
+ // However, we do add breakpoint sites to these locations if needed.
+ // 3) If we don't see this module in our breakpoint location list, call
+ // ResolveInModules.
+
+ ModuleList new_modules; // We'll stuff the "unseen" modules in this list,
+ // and then resolve
+ // them after the locations pass. Have to do it this way because
+ // resolving breakpoints will add new locations potentially.
+
+ for (ModuleSP module_sp : module_list.ModulesNoLocking()) {
+ bool seen = false;
+ if (!m_filter_sp->ModulePasses(module_sp))
+ continue;
+
+ for (BreakpointLocationSP break_loc_sp :
+ m_locations.BreakpointLocations()) {
+ if (!break_loc_sp->IsEnabled())
+ continue;
+ SectionSP section_sp(break_loc_sp->GetAddress().GetSection());
+ if (!section_sp || section_sp->GetModule() == module_sp) {
+ if (!seen)
+ seen = true;
+
+ if (!break_loc_sp->ResolveBreakpointSite()) {
+ if (log)
+ log->Printf("Warning: could not set breakpoint site for "
+ "breakpoint location %d of breakpoint %d.\n",
+ break_loc_sp->GetID(), GetID());
+ }
}
+ }
+
+ if (!seen)
+ new_modules.AppendIfNeeded(module_sp);
}
+
+ if (new_modules.GetSize() > 0) {
+ ResolveBreakpointInModules(new_modules);
+ }
+ } else {
+ // Go through the currently set locations and if any have breakpoints in
+ // the module list, then remove their breakpoint sites, and their locations
+ // if asked to.
+
+ BreakpointEventData *removed_locations_event;
+ if (!IsInternal())
+ removed_locations_event = new BreakpointEventData(
+ eBreakpointEventTypeLocationsRemoved, shared_from_this());
else
- {
- // Go through the currently set locations and if any have breakpoints in
- // the module list, then remove their breakpoint sites, and their locations if asked to.
-
- BreakpointEventData *removed_locations_event;
- if (!IsInternal())
- removed_locations_event = new BreakpointEventData (eBreakpointEventTypeLocationsRemoved,
- shared_from_this());
- else
- removed_locations_event = nullptr;
-
- size_t num_modules = module_list.GetSize();
- for (size_t i = 0; i < num_modules; i++)
- {
- ModuleSP module_sp (module_list.GetModuleAtIndexUnlocked (i));
- if (m_filter_sp->ModulePasses (module_sp))
- {
- size_t loc_idx = 0;
- size_t num_locations = m_locations.GetSize();
- BreakpointLocationCollection locations_to_remove;
- for (loc_idx = 0; loc_idx < num_locations; loc_idx++)
- {
- BreakpointLocationSP break_loc_sp (m_locations.GetByIndex(loc_idx));
- SectionSP section_sp (break_loc_sp->GetAddress().GetSection());
- if (section_sp && section_sp->GetModule() == module_sp)
- {
- // Remove this breakpoint since the shared library is
- // unloaded, but keep the breakpoint location around
- // so we always get complete hit count and breakpoint
- // lifetime info
- break_loc_sp->ClearBreakpointSite();
- if (removed_locations_event)
- {
- removed_locations_event->GetBreakpointLocationCollection().Add(break_loc_sp);
- }
- if (delete_locations)
- locations_to_remove.Add (break_loc_sp);
- }
- }
-
- if (delete_locations)
- {
- size_t num_locations_to_remove = locations_to_remove.GetSize();
- for (loc_idx = 0; loc_idx < num_locations_to_remove; loc_idx++)
- m_locations.RemoveLocation (locations_to_remove.GetByIndex(loc_idx));
- }
+ removed_locations_event = nullptr;
+
+ size_t num_modules = module_list.GetSize();
+ for (size_t i = 0; i < num_modules; i++) {
+ ModuleSP module_sp(module_list.GetModuleAtIndexUnlocked(i));
+ if (m_filter_sp->ModulePasses(module_sp)) {
+ size_t loc_idx = 0;
+ size_t num_locations = m_locations.GetSize();
+ BreakpointLocationCollection locations_to_remove;
+ for (loc_idx = 0; loc_idx < num_locations; loc_idx++) {
+ BreakpointLocationSP break_loc_sp(m_locations.GetByIndex(loc_idx));
+ SectionSP section_sp(break_loc_sp->GetAddress().GetSection());
+ if (section_sp && section_sp->GetModule() == module_sp) {
+ // Remove this breakpoint since the shared library is
+ // unloaded, but keep the breakpoint location around
+ // so we always get complete hit count and breakpoint
+ // lifetime info
+ break_loc_sp->ClearBreakpointSite();
+ if (removed_locations_event) {
+ removed_locations_event->GetBreakpointLocationCollection().Add(
+ break_loc_sp);
}
+ if (delete_locations)
+ locations_to_remove.Add(break_loc_sp);
+ }
}
- SendBreakpointChangedEvent (removed_locations_event);
- }
-}
-namespace
-{
-static bool
-SymbolContextsMightBeEquivalent(SymbolContext &old_sc, SymbolContext &new_sc)
-{
- bool equivalent_scs = false;
-
- if (old_sc.module_sp.get() == new_sc.module_sp.get())
- {
- // If these come from the same module, we can directly compare the pointers:
- if (old_sc.comp_unit && new_sc.comp_unit
- && (old_sc.comp_unit == new_sc.comp_unit))
- {
- if (old_sc.function && new_sc.function
- && (old_sc.function == new_sc.function))
- {
- equivalent_scs = true;
- }
- }
- else if (old_sc.symbol && new_sc.symbol
- && (old_sc.symbol == new_sc.symbol))
- {
- equivalent_scs = true;
+ if (delete_locations) {
+ size_t num_locations_to_remove = locations_to_remove.GetSize();
+ for (loc_idx = 0; loc_idx < num_locations_to_remove; loc_idx++)
+ m_locations.RemoveLocation(locations_to_remove.GetByIndex(loc_idx));
}
+ }
}
- else
- {
- // Otherwise we will compare by name...
- if (old_sc.comp_unit && new_sc.comp_unit)
- {
- if (FileSpec::Equal(*old_sc.comp_unit, *new_sc.comp_unit, true))
- {
- // Now check the functions:
- if (old_sc.function && new_sc.function
- && (old_sc.function->GetName() == new_sc.function->GetName()))
- {
- equivalent_scs = true;
- }
- }
- }
- else if (old_sc.symbol && new_sc.symbol)
- {
- if (Mangled::Compare(old_sc.symbol->GetMangled(), new_sc.symbol->GetMangled()) == 0)
- {
- equivalent_scs = true;
- }
+ SendBreakpointChangedEvent(removed_locations_event);
+ }
+}
+
+namespace {
+static bool SymbolContextsMightBeEquivalent(SymbolContext &old_sc,
+ SymbolContext &new_sc) {
+ bool equivalent_scs = false;
+
+ if (old_sc.module_sp.get() == new_sc.module_sp.get()) {
+ // If these come from the same module, we can directly compare the pointers:
+ if (old_sc.comp_unit && new_sc.comp_unit &&
+ (old_sc.comp_unit == new_sc.comp_unit)) {
+ if (old_sc.function && new_sc.function &&
+ (old_sc.function == new_sc.function)) {
+ equivalent_scs = true;
+ }
+ } else if (old_sc.symbol && new_sc.symbol &&
+ (old_sc.symbol == new_sc.symbol)) {
+ equivalent_scs = true;
+ }
+ } else {
+ // Otherwise we will compare by name...
+ if (old_sc.comp_unit && new_sc.comp_unit) {
+ if (FileSpec::Equal(*old_sc.comp_unit, *new_sc.comp_unit, true)) {
+ // Now check the functions:
+ if (old_sc.function && new_sc.function &&
+ (old_sc.function->GetName() == new_sc.function->GetName())) {
+ equivalent_scs = true;
}
+ }
+ } else if (old_sc.symbol && new_sc.symbol) {
+ if (Mangled::Compare(old_sc.symbol->GetMangled(),
+ new_sc.symbol->GetMangled()) == 0) {
+ equivalent_scs = true;
+ }
}
- return equivalent_scs;
+ }
+ return equivalent_scs;
}
} // anonymous namespace
-void
-Breakpoint::ModuleReplaced (ModuleSP old_module_sp, ModuleSP new_module_sp)
-{
- Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
- if (log)
- log->Printf ("Breakpoint::ModulesReplaced for %s\n",
- old_module_sp->GetSpecificationDescription().c_str());
- // First find all the locations that are in the old module
-
- BreakpointLocationCollection old_break_locs;
- for (BreakpointLocationSP break_loc_sp : m_locations.BreakpointLocations())
- {
- SectionSP section_sp = break_loc_sp->GetAddress().GetSection();
- if (section_sp && section_sp->GetModule() == old_module_sp)
- {
- old_break_locs.Add(break_loc_sp);
- }
- }
-
- size_t num_old_locations = old_break_locs.GetSize();
-
- if (num_old_locations == 0)
- {
- // There were no locations in the old module, so we just need to check if there were any in the new module.
- ModuleList temp_list;
- temp_list.Append (new_module_sp);
- ResolveBreakpointInModules(temp_list);
+void Breakpoint::ModuleReplaced(ModuleSP old_module_sp,
+ ModuleSP new_module_sp) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+ if (log)
+ log->Printf("Breakpoint::ModulesReplaced for %s\n",
+ old_module_sp->GetSpecificationDescription().c_str());
+ // First find all the locations that are in the old module
+
+ BreakpointLocationCollection old_break_locs;
+ for (BreakpointLocationSP break_loc_sp : m_locations.BreakpointLocations()) {
+ SectionSP section_sp = break_loc_sp->GetAddress().GetSection();
+ if (section_sp && section_sp->GetModule() == old_module_sp) {
+ old_break_locs.Add(break_loc_sp);
}
- else
- {
- // First search the new module for locations.
- // Then compare this with the old list, copy over locations that "look the same"
- // Then delete the old locations.
- // Finally remember to post the creation event.
- //
- // Two locations are the same if they have the same comp unit & function (by name) and there are the same number
- // of locations in the old function as in the new one.
-
- ModuleList temp_list;
- temp_list.Append (new_module_sp);
- BreakpointLocationCollection new_break_locs;
- ResolveBreakpointInModules(temp_list, new_break_locs);
- BreakpointLocationCollection locations_to_remove;
- BreakpointLocationCollection locations_to_announce;
-
- size_t num_new_locations = new_break_locs.GetSize();
-
- if (num_new_locations > 0)
- {
- // Break out the case of one location -> one location since that's the most common one, and there's no need
- // to build up the structures needed for the merge in that case.
- if (num_new_locations == 1 && num_old_locations == 1)
- {
- bool equivalent_locations = false;
- SymbolContext old_sc, new_sc;
- // The only way the old and new location can be equivalent is if they have the same amount of information:
- BreakpointLocationSP old_loc_sp = old_break_locs.GetByIndex(0);
- BreakpointLocationSP new_loc_sp = new_break_locs.GetByIndex(0);
-
- if (old_loc_sp->GetAddress().CalculateSymbolContext(&old_sc)
- == new_loc_sp->GetAddress().CalculateSymbolContext(&new_sc))
- {
- equivalent_locations = SymbolContextsMightBeEquivalent(old_sc, new_sc);
- }
-
- if (equivalent_locations)
- {
- m_locations.SwapLocation (old_loc_sp, new_loc_sp);
- }
- else
- {
- locations_to_remove.Add(old_loc_sp);
- locations_to_announce.Add(new_loc_sp);
- }
- }
- else
- {
- //We don't want to have to keep computing the SymbolContexts for these addresses over and over,
- // so lets get them up front:
-
- typedef std::map<lldb::break_id_t, SymbolContext> IDToSCMap;
- IDToSCMap old_sc_map;
- for (size_t idx = 0; idx < num_old_locations; idx++)
- {
- SymbolContext sc;
- BreakpointLocationSP bp_loc_sp = old_break_locs.GetByIndex(idx);
- lldb::break_id_t loc_id = bp_loc_sp->GetID();
- bp_loc_sp->GetAddress().CalculateSymbolContext(&old_sc_map[loc_id]);
- }
-
- std::map<lldb::break_id_t, SymbolContext> new_sc_map;
- for (size_t idx = 0; idx < num_new_locations; idx++)
- {
- SymbolContext sc;
- BreakpointLocationSP bp_loc_sp = new_break_locs.GetByIndex(idx);
- lldb::break_id_t loc_id = bp_loc_sp->GetID();
- bp_loc_sp->GetAddress().CalculateSymbolContext(&new_sc_map[loc_id]);
- }
- // Take an element from the old Symbol Contexts
- while (old_sc_map.size() > 0)
- {
- lldb::break_id_t old_id = old_sc_map.begin()->first;
- SymbolContext &old_sc = old_sc_map.begin()->second;
-
- // Count the number of entries equivalent to this SC for the old list:
- std::vector<lldb::break_id_t> old_id_vec;
- old_id_vec.push_back(old_id);
-
- IDToSCMap::iterator tmp_iter;
- for (tmp_iter = ++old_sc_map.begin(); tmp_iter != old_sc_map.end(); tmp_iter++)
- {
- if (SymbolContextsMightBeEquivalent (old_sc, tmp_iter->second))
- old_id_vec.push_back (tmp_iter->first);
- }
-
- // Now find all the equivalent locations in the new list.
- std::vector<lldb::break_id_t> new_id_vec;
- for (tmp_iter = new_sc_map.begin(); tmp_iter != new_sc_map.end(); tmp_iter++)
- {
- if (SymbolContextsMightBeEquivalent (old_sc, tmp_iter->second))
- new_id_vec.push_back(tmp_iter->first);
- }
-
- // Alright, if we have the same number of potentially equivalent locations in the old
- // and new modules, we'll just map them one to one in ascending ID order (assuming the
- // resolver's order would match the equivalent ones.
- // Otherwise, we'll dump all the old ones, and just take the new ones, erasing the elements
- // from both maps as we go.
-
- if (old_id_vec.size() == new_id_vec.size())
- {
- sort(old_id_vec.begin(), old_id_vec.end());
- sort(new_id_vec.begin(), new_id_vec.end());
- size_t num_elements = old_id_vec.size();
- for (size_t idx = 0; idx < num_elements; idx++)
- {
- BreakpointLocationSP old_loc_sp = old_break_locs.FindByIDPair(GetID(), old_id_vec[idx]);
- BreakpointLocationSP new_loc_sp = new_break_locs.FindByIDPair(GetID(), new_id_vec[idx]);
- m_locations.SwapLocation(old_loc_sp, new_loc_sp);
- old_sc_map.erase(old_id_vec[idx]);
- new_sc_map.erase(new_id_vec[idx]);
- }
- }
- else
- {
- for (lldb::break_id_t old_id : old_id_vec)
- {
- locations_to_remove.Add(old_break_locs.FindByIDPair(GetID(), old_id));
- old_sc_map.erase(old_id);
- }
- for (lldb::break_id_t new_id : new_id_vec)
- {
- locations_to_announce.Add(new_break_locs.FindByIDPair(GetID(), new_id));
- new_sc_map.erase(new_id);
- }
- }
- }
- }
+ }
+
+ size_t num_old_locations = old_break_locs.GetSize();
+
+ if (num_old_locations == 0) {
+ // There were no locations in the old module, so we just need to check if
+ // there were any in the new module.
+ ModuleList temp_list;
+ temp_list.Append(new_module_sp);
+ ResolveBreakpointInModules(temp_list);
+ } else {
+ // First search the new module for locations.
+ // Then compare this with the old list, copy over locations that "look the
+ // same"
+ // Then delete the old locations.
+ // Finally remember to post the creation event.
+ //
+ // Two locations are the same if they have the same comp unit & function (by
+ // name) and there are the same number
+ // of locations in the old function as in the new one.
+
+ ModuleList temp_list;
+ temp_list.Append(new_module_sp);
+ BreakpointLocationCollection new_break_locs;
+ ResolveBreakpointInModules(temp_list, new_break_locs);
+ BreakpointLocationCollection locations_to_remove;
+ BreakpointLocationCollection locations_to_announce;
+
+ size_t num_new_locations = new_break_locs.GetSize();
+
+ if (num_new_locations > 0) {
+ // Break out the case of one location -> one location since that's the
+ // most common one, and there's no need
+ // to build up the structures needed for the merge in that case.
+ if (num_new_locations == 1 && num_old_locations == 1) {
+ bool equivalent_locations = false;
+ SymbolContext old_sc, new_sc;
+ // The only way the old and new location can be equivalent is if they
+ // have the same amount of information:
+ BreakpointLocationSP old_loc_sp = old_break_locs.GetByIndex(0);
+ BreakpointLocationSP new_loc_sp = new_break_locs.GetByIndex(0);
+
+ if (old_loc_sp->GetAddress().CalculateSymbolContext(&old_sc) ==
+ new_loc_sp->GetAddress().CalculateSymbolContext(&new_sc)) {
+ equivalent_locations =
+ SymbolContextsMightBeEquivalent(old_sc, new_sc);
}
-
- // Now remove the remaining old locations, and cons up a removed locations event.
- // Note, we don't put the new locations that were swapped with an old location on the locations_to_remove
- // list, so we don't need to worry about telling the world about removing a location we didn't tell them
- // about adding.
-
- BreakpointEventData *locations_event;
- if (!IsInternal())
- locations_event = new BreakpointEventData (eBreakpointEventTypeLocationsRemoved,
- shared_from_this());
- else
- locations_event = nullptr;
-
- for (BreakpointLocationSP loc_sp : locations_to_remove.BreakpointLocations())
- {
- m_locations.RemoveLocation(loc_sp);
- if (locations_event)
- locations_event->GetBreakpointLocationCollection().Add(loc_sp);
+
+ if (equivalent_locations) {
+ m_locations.SwapLocation(old_loc_sp, new_loc_sp);
+ } else {
+ locations_to_remove.Add(old_loc_sp);
+ locations_to_announce.Add(new_loc_sp);
+ }
+ } else {
+ // We don't want to have to keep computing the SymbolContexts for these
+ // addresses over and over,
+ // so lets get them up front:
+
+ typedef std::map<lldb::break_id_t, SymbolContext> IDToSCMap;
+ IDToSCMap old_sc_map;
+ for (size_t idx = 0; idx < num_old_locations; idx++) {
+ SymbolContext sc;
+ BreakpointLocationSP bp_loc_sp = old_break_locs.GetByIndex(idx);
+ lldb::break_id_t loc_id = bp_loc_sp->GetID();
+ bp_loc_sp->GetAddress().CalculateSymbolContext(&old_sc_map[loc_id]);
+ }
+
+ std::map<lldb::break_id_t, SymbolContext> new_sc_map;
+ for (size_t idx = 0; idx < num_new_locations; idx++) {
+ SymbolContext sc;
+ BreakpointLocationSP bp_loc_sp = new_break_locs.GetByIndex(idx);
+ lldb::break_id_t loc_id = bp_loc_sp->GetID();
+ bp_loc_sp->GetAddress().CalculateSymbolContext(&new_sc_map[loc_id]);
}
- SendBreakpointChangedEvent (locations_event);
-
- // And announce the new ones.
-
- if (!IsInternal())
- {
- locations_event = new BreakpointEventData (eBreakpointEventTypeLocationsAdded,
- shared_from_this());
- for (BreakpointLocationSP loc_sp : locations_to_announce.BreakpointLocations())
- locations_event->GetBreakpointLocationCollection().Add(loc_sp);
-
- SendBreakpointChangedEvent (locations_event);
+ // Take an element from the old Symbol Contexts
+ while (old_sc_map.size() > 0) {
+ lldb::break_id_t old_id = old_sc_map.begin()->first;
+ SymbolContext &old_sc = old_sc_map.begin()->second;
+
+ // Count the number of entries equivalent to this SC for the old list:
+ std::vector<lldb::break_id_t> old_id_vec;
+ old_id_vec.push_back(old_id);
+
+ IDToSCMap::iterator tmp_iter;
+ for (tmp_iter = ++old_sc_map.begin(); tmp_iter != old_sc_map.end();
+ tmp_iter++) {
+ if (SymbolContextsMightBeEquivalent(old_sc, tmp_iter->second))
+ old_id_vec.push_back(tmp_iter->first);
+ }
+
+ // Now find all the equivalent locations in the new list.
+ std::vector<lldb::break_id_t> new_id_vec;
+ for (tmp_iter = new_sc_map.begin(); tmp_iter != new_sc_map.end();
+ tmp_iter++) {
+ if (SymbolContextsMightBeEquivalent(old_sc, tmp_iter->second))
+ new_id_vec.push_back(tmp_iter->first);
+ }
+
+ // Alright, if we have the same number of potentially equivalent
+ // locations in the old
+ // and new modules, we'll just map them one to one in ascending ID
+ // order (assuming the
+ // resolver's order would match the equivalent ones.
+ // Otherwise, we'll dump all the old ones, and just take the new ones,
+ // erasing the elements
+ // from both maps as we go.
+
+ if (old_id_vec.size() == new_id_vec.size()) {
+ sort(old_id_vec.begin(), old_id_vec.end());
+ sort(new_id_vec.begin(), new_id_vec.end());
+ size_t num_elements = old_id_vec.size();
+ for (size_t idx = 0; idx < num_elements; idx++) {
+ BreakpointLocationSP old_loc_sp =
+ old_break_locs.FindByIDPair(GetID(), old_id_vec[idx]);
+ BreakpointLocationSP new_loc_sp =
+ new_break_locs.FindByIDPair(GetID(), new_id_vec[idx]);
+ m_locations.SwapLocation(old_loc_sp, new_loc_sp);
+ old_sc_map.erase(old_id_vec[idx]);
+ new_sc_map.erase(new_id_vec[idx]);
+ }
+ } else {
+ for (lldb::break_id_t old_id : old_id_vec) {
+ locations_to_remove.Add(
+ old_break_locs.FindByIDPair(GetID(), old_id));
+ old_sc_map.erase(old_id);
+ }
+ for (lldb::break_id_t new_id : new_id_vec) {
+ locations_to_announce.Add(
+ new_break_locs.FindByIDPair(GetID(), new_id));
+ new_sc_map.erase(new_id);
+ }
+ }
}
- m_locations.Compact();
+ }
}
-}
-void
-Breakpoint::Dump (Stream *)
-{
-}
+ // Now remove the remaining old locations, and cons up a removed locations
+ // event.
+ // Note, we don't put the new locations that were swapped with an old
+ // location on the locations_to_remove
+ // list, so we don't need to worry about telling the world about removing a
+ // location we didn't tell them
+ // about adding.
+
+ BreakpointEventData *locations_event;
+ if (!IsInternal())
+ locations_event = new BreakpointEventData(
+ eBreakpointEventTypeLocationsRemoved, shared_from_this());
+ else
+ locations_event = nullptr;
-size_t
-Breakpoint::GetNumResolvedLocations() const
-{
- // Return the number of breakpoints that are actually resolved and set
- // down in the inferior process.
- return m_locations.GetNumResolvedLocations();
-}
+ for (BreakpointLocationSP loc_sp :
+ locations_to_remove.BreakpointLocations()) {
+ m_locations.RemoveLocation(loc_sp);
+ if (locations_event)
+ locations_event->GetBreakpointLocationCollection().Add(loc_sp);
+ }
+ SendBreakpointChangedEvent(locations_event);
-size_t
-Breakpoint::GetNumLocations() const
-{
- return m_locations.GetSize();
-}
+ // And announce the new ones.
+
+ if (!IsInternal()) {
+ locations_event = new BreakpointEventData(
+ eBreakpointEventTypeLocationsAdded, shared_from_this());
+ for (BreakpointLocationSP loc_sp :
+ locations_to_announce.BreakpointLocations())
+ locations_event->GetBreakpointLocationCollection().Add(loc_sp);
-bool
-Breakpoint::AddName (const char *new_name, Error &error)
-{
- if (!new_name)
- return false;
- if (!BreakpointID::StringIsBreakpointName(new_name, error))
- {
- error.SetErrorStringWithFormat("input name \"%s\" not a breakpoint name.", new_name);
- return false;
+ SendBreakpointChangedEvent(locations_event);
}
- if (!error.Success())
- return false;
+ m_locations.Compact();
+ }
+}
- m_name_list.insert(new_name);
- return true;
+void Breakpoint::Dump(Stream *) {}
+
+size_t Breakpoint::GetNumResolvedLocations() const {
+ // Return the number of breakpoints that are actually resolved and set
+ // down in the inferior process.
+ return m_locations.GetNumResolvedLocations();
}
-void
-Breakpoint::GetDescription (Stream *s, lldb::DescriptionLevel level, bool show_locations)
-{
- assert (s != nullptr);
-
- if (!m_kind_description.empty())
- {
- if (level == eDescriptionLevelBrief)
- {
- s->PutCString (GetBreakpointKind());
- return;
- }
- else
- s->Printf("Kind: %s\n", GetBreakpointKind ());
- }
-
- const size_t num_locations = GetNumLocations ();
- const size_t num_resolved_locations = GetNumResolvedLocations ();
-
- // They just made the breakpoint, they don't need to be told HOW they made it...
- // Also, we'll print the breakpoint number differently depending on whether there is 1 or more locations.
- if (level != eDescriptionLevelInitial)
- {
- s->Printf("%i: ", GetID());
- GetResolverDescription (s);
- GetFilterDescription (s);
- }
-
- switch (level)
- {
- case lldb::eDescriptionLevelBrief:
- case lldb::eDescriptionLevelFull:
- if (num_locations > 0)
- {
- s->Printf(", locations = %" PRIu64, (uint64_t)num_locations);
- if (num_resolved_locations > 0)
- s->Printf(", resolved = %" PRIu64 ", hit count = %d", (uint64_t)num_resolved_locations, GetHitCount());
- }
- else
- {
- // Don't print the pending notification for exception resolvers since we don't generally
- // know how to set them until the target is run.
- if (m_resolver_sp->getResolverID() != BreakpointResolver::ExceptionResolver)
- s->Printf(", locations = 0 (pending)");
- }
+size_t Breakpoint::GetNumLocations() const { return m_locations.GetSize(); }
- GetOptions()->GetDescription(s, level);
-
- if (m_precondition_sp)
- m_precondition_sp->GetDescription(*s, level);
-
- if (level == lldb::eDescriptionLevelFull)
- {
- if (!m_name_list.empty())
- {
- s->EOL();
- s->Indent();
- s->Printf ("Names:");
- s->EOL();
- s->IndentMore();
- for (std::string name : m_name_list)
- {
- s->Indent();
- s->Printf("%s\n", name.c_str());
- }
- s->IndentLess();
- }
- s->IndentLess();
- s->EOL();
- }
- break;
-
- case lldb::eDescriptionLevelInitial:
- s->Printf ("Breakpoint %i: ", GetID());
- if (num_locations == 0)
- {
- s->Printf ("no locations (pending).");
- }
- else if (num_locations == 1 && !show_locations)
- {
- // There is only one location, so we'll just print that location information.
- GetLocationAtIndex(0)->GetDescription(s, level);
- }
- else
- {
- s->Printf ("%" PRIu64 " locations.", static_cast<uint64_t>(num_locations));
- }
- s->EOL();
- break;
-
- case lldb::eDescriptionLevelVerbose:
- // Verbose mode does a debug dump of the breakpoint
- Dump (s);
- s->EOL ();
- //s->Indent();
- GetOptions()->GetDescription(s, level);
- break;
-
- default:
- break;
+bool Breakpoint::AddName(const char *new_name, Error &error) {
+ if (!new_name)
+ return false;
+ if (!BreakpointID::StringIsBreakpointName(new_name, error)) {
+ error.SetErrorStringWithFormat("input name \"%s\" not a breakpoint name.",
+ new_name);
+ return false;
+ }
+ if (!error.Success())
+ return false;
+
+ m_name_list.insert(new_name);
+ return true;
+}
+
+void Breakpoint::GetDescription(Stream *s, lldb::DescriptionLevel level,
+ bool show_locations) {
+ assert(s != nullptr);
+
+ if (!m_kind_description.empty()) {
+ if (level == eDescriptionLevelBrief) {
+ s->PutCString(GetBreakpointKind());
+ return;
+ } else
+ s->Printf("Kind: %s\n", GetBreakpointKind());
+ }
+
+ const size_t num_locations = GetNumLocations();
+ const size_t num_resolved_locations = GetNumResolvedLocations();
+
+ // They just made the breakpoint, they don't need to be told HOW they made
+ // it...
+ // Also, we'll print the breakpoint number differently depending on whether
+ // there is 1 or more locations.
+ if (level != eDescriptionLevelInitial) {
+ s->Printf("%i: ", GetID());
+ GetResolverDescription(s);
+ GetFilterDescription(s);
+ }
+
+ switch (level) {
+ case lldb::eDescriptionLevelBrief:
+ case lldb::eDescriptionLevelFull:
+ if (num_locations > 0) {
+ s->Printf(", locations = %" PRIu64, (uint64_t)num_locations);
+ if (num_resolved_locations > 0)
+ s->Printf(", resolved = %" PRIu64 ", hit count = %d",
+ (uint64_t)num_resolved_locations, GetHitCount());
+ } else {
+ // Don't print the pending notification for exception resolvers since we
+ // don't generally
+ // know how to set them until the target is run.
+ if (m_resolver_sp->getResolverID() !=
+ BreakpointResolver::ExceptionResolver)
+ s->Printf(", locations = 0 (pending)");
}
- // The brief description is just the location name (1.2 or whatever). That's pointless to
- // show in the breakpoint's description, so suppress it.
- if (show_locations && level != lldb::eDescriptionLevelBrief)
- {
+ GetOptions()->GetDescription(s, level);
+
+ if (m_precondition_sp)
+ m_precondition_sp->GetDescription(*s, level);
+
+ if (level == lldb::eDescriptionLevelFull) {
+ if (!m_name_list.empty()) {
+ s->EOL();
+ s->Indent();
+ s->Printf("Names:");
+ s->EOL();
s->IndentMore();
- for (size_t i = 0; i < num_locations; ++i)
- {
- BreakpointLocation *loc = GetLocationAtIndex(i).get();
- loc->GetDescription(s, level);
- s->EOL();
+ for (std::string name : m_name_list) {
+ s->Indent();
+ s->Printf("%s\n", name.c_str());
}
s->IndentLess();
+ }
+ s->IndentLess();
+ s->EOL();
+ }
+ break;
+
+ case lldb::eDescriptionLevelInitial:
+ s->Printf("Breakpoint %i: ", GetID());
+ if (num_locations == 0) {
+ s->Printf("no locations (pending).");
+ } else if (num_locations == 1 && !show_locations) {
+ // There is only one location, so we'll just print that location
+ // information.
+ GetLocationAtIndex(0)->GetDescription(s, level);
+ } else {
+ s->Printf("%" PRIu64 " locations.", static_cast<uint64_t>(num_locations));
+ }
+ s->EOL();
+ break;
+
+ case lldb::eDescriptionLevelVerbose:
+ // Verbose mode does a debug dump of the breakpoint
+ Dump(s);
+ s->EOL();
+ // s->Indent();
+ GetOptions()->GetDescription(s, level);
+ break;
+
+ default:
+ break;
+ }
+
+ // The brief description is just the location name (1.2 or whatever). That's
+ // pointless to
+ // show in the breakpoint's description, so suppress it.
+ if (show_locations && level != lldb::eDescriptionLevelBrief) {
+ s->IndentMore();
+ for (size_t i = 0; i < num_locations; ++i) {
+ BreakpointLocation *loc = GetLocationAtIndex(i).get();
+ loc->GetDescription(s, level);
+ s->EOL();
}
+ s->IndentLess();
+ }
+}
+
+void Breakpoint::GetResolverDescription(Stream *s) {
+ if (m_resolver_sp)
+ m_resolver_sp->GetDescription(s);
+}
+
+bool Breakpoint::GetMatchingFileLine(const ConstString &filename,
+ uint32_t line_number,
+ BreakpointLocationCollection &loc_coll) {
+ // TODO: To be correct, this method needs to fill the breakpoint location
+ // collection
+ // with the location IDs which match the filename and line_number.
+ //
+
+ if (m_resolver_sp) {
+ BreakpointResolverFileLine *resolverFileLine =
+ dyn_cast<BreakpointResolverFileLine>(m_resolver_sp.get());
+ if (resolverFileLine &&
+ resolverFileLine->m_file_spec.GetFilename() == filename &&
+ resolverFileLine->m_line_number == line_number) {
+ return true;
+ }
+ }
+ return false;
}
-void
-Breakpoint::GetResolverDescription (Stream *s)
-{
- if (m_resolver_sp)
- m_resolver_sp->GetDescription (s);
+void Breakpoint::GetFilterDescription(Stream *s) {
+ m_filter_sp->GetDescription(s);
}
-bool
-Breakpoint::GetMatchingFileLine (const ConstString &filename, uint32_t line_number, BreakpointLocationCollection &loc_coll)
-{
- // TODO: To be correct, this method needs to fill the breakpoint location collection
- // with the location IDs which match the filename and line_number.
- //
+bool Breakpoint::EvaluatePrecondition(StoppointCallbackContext &context) {
+ if (!m_precondition_sp)
+ return true;
- if (m_resolver_sp)
- {
- BreakpointResolverFileLine *resolverFileLine = dyn_cast<BreakpointResolverFileLine>(m_resolver_sp.get());
- if (resolverFileLine &&
- resolverFileLine->m_file_spec.GetFilename() == filename &&
- resolverFileLine->m_line_number == line_number)
- {
- return true;
- }
- }
- return false;
+ return m_precondition_sp->EvaluatePrecondition(context);
}
-void
-Breakpoint::GetFilterDescription (Stream *s)
-{
- m_filter_sp->GetDescription (s);
+bool Breakpoint::BreakpointPrecondition::EvaluatePrecondition(
+ StoppointCallbackContext &context) {
+ return true;
}
-bool
-Breakpoint::EvaluatePrecondition (StoppointCallbackContext &context)
-{
- if (!m_precondition_sp)
- return true;
+void Breakpoint::BreakpointPrecondition::GetDescription(
+ Stream &stream, lldb::DescriptionLevel level) {}
- return m_precondition_sp->EvaluatePrecondition(context);
+Error Breakpoint::BreakpointPrecondition::ConfigurePrecondition(Args &options) {
+ Error error;
+ error.SetErrorString("Base breakpoint precondition has no options.");
+ return error;
}
-bool
-Breakpoint::BreakpointPrecondition::EvaluatePrecondition(StoppointCallbackContext &context)
-{
- return true;
-}
+void Breakpoint::SendBreakpointChangedEvent(
+ lldb::BreakpointEventType eventKind) {
+ if (!m_being_created && !IsInternal() &&
+ GetTarget().EventTypeHasListeners(
+ Target::eBroadcastBitBreakpointChanged)) {
+ BreakpointEventData *data =
+ new Breakpoint::BreakpointEventData(eventKind, shared_from_this());
-void
-Breakpoint::BreakpointPrecondition::GetDescription(Stream &stream, lldb::DescriptionLevel level)
-{
+ GetTarget().BroadcastEvent(Target::eBroadcastBitBreakpointChanged, data);
+ }
}
-Error
-Breakpoint::BreakpointPrecondition::ConfigurePrecondition(Args &options)
-{
- Error error;
- error.SetErrorString("Base breakpoint precondition has no options.");
- return error;
-}
+void Breakpoint::SendBreakpointChangedEvent(BreakpointEventData *data) {
+ if (data == nullptr)
+ return;
-void
-Breakpoint::SendBreakpointChangedEvent (lldb::BreakpointEventType eventKind)
-{
- if (!m_being_created
- && !IsInternal()
- && GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged))
- {
- BreakpointEventData *data = new Breakpoint::BreakpointEventData (eventKind, shared_from_this());
-
- GetTarget().BroadcastEvent (Target::eBroadcastBitBreakpointChanged, data);
- }
+ if (!m_being_created && !IsInternal() &&
+ GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged))
+ GetTarget().BroadcastEvent(Target::eBroadcastBitBreakpointChanged, data);
+ else
+ delete data;
}
-void
-Breakpoint::SendBreakpointChangedEvent (BreakpointEventData *data)
-{
- if (data == nullptr)
- return;
-
- if (!m_being_created
- && !IsInternal()
- && GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged))
- GetTarget().BroadcastEvent (Target::eBroadcastBitBreakpointChanged, data);
- else
- delete data;
-}
-
-Breakpoint::BreakpointEventData::BreakpointEventData (BreakpointEventType sub_type,
- const BreakpointSP &new_breakpoint_sp) :
- EventData (),
- m_breakpoint_event (sub_type),
- m_new_breakpoint_sp (new_breakpoint_sp)
-{
-}
+Breakpoint::BreakpointEventData::BreakpointEventData(
+ BreakpointEventType sub_type, const BreakpointSP &new_breakpoint_sp)
+ : EventData(), m_breakpoint_event(sub_type),
+ m_new_breakpoint_sp(new_breakpoint_sp) {}
Breakpoint::BreakpointEventData::~BreakpointEventData() = default;
-const ConstString &
-Breakpoint::BreakpointEventData::GetFlavorString ()
-{
- static ConstString g_flavor ("Breakpoint::BreakpointEventData");
- return g_flavor;
+const ConstString &Breakpoint::BreakpointEventData::GetFlavorString() {
+ static ConstString g_flavor("Breakpoint::BreakpointEventData");
+ return g_flavor;
}
-const ConstString &
-Breakpoint::BreakpointEventData::GetFlavor () const
-{
- return BreakpointEventData::GetFlavorString ();
+const ConstString &Breakpoint::BreakpointEventData::GetFlavor() const {
+ return BreakpointEventData::GetFlavorString();
}
-BreakpointSP &
-Breakpoint::BreakpointEventData::GetBreakpoint ()
-{
- return m_new_breakpoint_sp;
+BreakpointSP &Breakpoint::BreakpointEventData::GetBreakpoint() {
+ return m_new_breakpoint_sp;
}
BreakpointEventType
-Breakpoint::BreakpointEventData::GetBreakpointEventType () const
-{
- return m_breakpoint_event;
+Breakpoint::BreakpointEventData::GetBreakpointEventType() const {
+ return m_breakpoint_event;
}
-void
-Breakpoint::BreakpointEventData::Dump (Stream *s) const
-{
-}
+void Breakpoint::BreakpointEventData::Dump(Stream *s) const {}
const Breakpoint::BreakpointEventData *
-Breakpoint::BreakpointEventData::GetEventDataFromEvent (const Event *event)
-{
- if (event)
- {
- const EventData *event_data = event->GetData();
- if (event_data && event_data->GetFlavor() == BreakpointEventData::GetFlavorString())
- return static_cast <const BreakpointEventData *> (event->GetData());
- }
- return nullptr;
+Breakpoint::BreakpointEventData::GetEventDataFromEvent(const Event *event) {
+ if (event) {
+ const EventData *event_data = event->GetData();
+ if (event_data &&
+ event_data->GetFlavor() == BreakpointEventData::GetFlavorString())
+ return static_cast<const BreakpointEventData *>(event->GetData());
+ }
+ return nullptr;
}
BreakpointEventType
-Breakpoint::BreakpointEventData::GetBreakpointEventTypeFromEvent (const EventSP &event_sp)
-{
- const BreakpointEventData *data = GetEventDataFromEvent (event_sp.get());
+Breakpoint::BreakpointEventData::GetBreakpointEventTypeFromEvent(
+ const EventSP &event_sp) {
+ const BreakpointEventData *data = GetEventDataFromEvent(event_sp.get());
- if (data == nullptr)
- return eBreakpointEventTypeInvalidType;
- else
- return data->GetBreakpointEventType();
+ if (data == nullptr)
+ return eBreakpointEventTypeInvalidType;
+ else
+ return data->GetBreakpointEventType();
}
-BreakpointSP
-Breakpoint::BreakpointEventData::GetBreakpointFromEvent (const EventSP &event_sp)
-{
- BreakpointSP bp_sp;
+BreakpointSP Breakpoint::BreakpointEventData::GetBreakpointFromEvent(
+ const EventSP &event_sp) {
+ BreakpointSP bp_sp;
- const BreakpointEventData *data = GetEventDataFromEvent (event_sp.get());
- if (data)
- bp_sp = data->m_new_breakpoint_sp;
+ const BreakpointEventData *data = GetEventDataFromEvent(event_sp.get());
+ if (data)
+ bp_sp = data->m_new_breakpoint_sp;
- return bp_sp;
+ return bp_sp;
}
-size_t
-Breakpoint::BreakpointEventData::GetNumBreakpointLocationsFromEvent (const EventSP &event_sp)
-{
- const BreakpointEventData *data = GetEventDataFromEvent (event_sp.get());
- if (data)
- return data->m_locations.GetSize();
+size_t Breakpoint::BreakpointEventData::GetNumBreakpointLocationsFromEvent(
+ const EventSP &event_sp) {
+ const BreakpointEventData *data = GetEventDataFromEvent(event_sp.get());
+ if (data)
+ return data->m_locations.GetSize();
- return 0;
+ return 0;
}
lldb::BreakpointLocationSP
-Breakpoint::BreakpointEventData::GetBreakpointLocationAtIndexFromEvent (const lldb::EventSP &event_sp, uint32_t bp_loc_idx)
-{
- lldb::BreakpointLocationSP bp_loc_sp;
-
- const BreakpointEventData *data = GetEventDataFromEvent (event_sp.get());
- if (data)
- {
- bp_loc_sp = data->m_locations.GetByIndex(bp_loc_idx);
- }
+Breakpoint::BreakpointEventData::GetBreakpointLocationAtIndexFromEvent(
+ const lldb::EventSP &event_sp, uint32_t bp_loc_idx) {
+ lldb::BreakpointLocationSP bp_loc_sp;
+
+ const BreakpointEventData *data = GetEventDataFromEvent(event_sp.get());
+ if (data) {
+ bp_loc_sp = data->m_locations.GetByIndex(bp_loc_idx);
+ }
- return bp_loc_sp;
+ return bp_loc_sp;
}
diff --git a/lldb/source/Breakpoint/BreakpointID.cpp b/lldb/source/Breakpoint/BreakpointID.cpp
index 81a3dfe..9ab7adf 100644
--- a/lldb/source/Breakpoint/BreakpointID.cpp
+++ b/lldb/source/Breakpoint/BreakpointID.cpp
@@ -13,121 +13,108 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Breakpoint/BreakpointID.h"
#include "lldb/Breakpoint/Breakpoint.h"
-#include "lldb/Core/Stream.h"
+#include "lldb/Breakpoint/BreakpointID.h"
#include "lldb/Core/Error.h"
+#include "lldb/Core/Stream.h"
using namespace lldb;
using namespace lldb_private;
-BreakpointID::BreakpointID (break_id_t bp_id, break_id_t loc_id) :
- m_break_id (bp_id),
- m_location_id (loc_id)
-{
-}
+BreakpointID::BreakpointID(break_id_t bp_id, break_id_t loc_id)
+ : m_break_id(bp_id), m_location_id(loc_id) {}
BreakpointID::~BreakpointID() = default;
-const char *BreakpointID::g_range_specifiers[] = { "-", "to", "To", "TO", nullptr };
+const char *BreakpointID::g_range_specifiers[] = {"-", "to", "To", "TO",
+ nullptr};
-// Tells whether or not STR is valid to use between two strings representing breakpoint IDs, to
-// indicate a range of breakpoint IDs. This is broken out into a separate function so that we can
+// Tells whether or not STR is valid to use between two strings representing
+// breakpoint IDs, to
+// indicate a range of breakpoint IDs. This is broken out into a separate
+// function so that we can
// easily change or add to the format for specifying ID ranges at a later date.
-bool
-BreakpointID::IsRangeIdentifier (const char *str)
-{
- int specifier_count = 0;
- for (int i = 0; g_range_specifiers[i] != nullptr; ++i)
- ++specifier_count;
-
- for (int i = 0; i < specifier_count; ++i)
- {
- if (strcmp (g_range_specifiers[i], str) == 0)
- return true;
- }
+bool BreakpointID::IsRangeIdentifier(const char *str) {
+ int specifier_count = 0;
+ for (int i = 0; g_range_specifiers[i] != nullptr; ++i)
+ ++specifier_count;
+
+ for (int i = 0; i < specifier_count; ++i) {
+ if (strcmp(g_range_specifiers[i], str) == 0)
+ return true;
+ }
return false;
}
-bool
-BreakpointID::IsValidIDExpression (const char *str)
-{
- break_id_t bp_id;
- break_id_t loc_id;
- BreakpointID::ParseCanonicalReference (str, &bp_id, &loc_id);
+bool BreakpointID::IsValidIDExpression(const char *str) {
+ break_id_t bp_id;
+ break_id_t loc_id;
+ BreakpointID::ParseCanonicalReference(str, &bp_id, &loc_id);
- return (bp_id != LLDB_INVALID_BREAK_ID);
+ return (bp_id != LLDB_INVALID_BREAK_ID);
}
-void
-BreakpointID::GetDescription (Stream *s, lldb::DescriptionLevel level)
-{
- if (level == eDescriptionLevelVerbose)
- s->Printf("%p BreakpointID:", static_cast<void*>(this));
-
- if (m_break_id == LLDB_INVALID_BREAK_ID)
- s->PutCString ("<invalid>");
- else if (m_location_id == LLDB_INVALID_BREAK_ID)
- s->Printf("%i", m_break_id);
- else
- s->Printf("%i.%i", m_break_id, m_location_id);
+void BreakpointID::GetDescription(Stream *s, lldb::DescriptionLevel level) {
+ if (level == eDescriptionLevelVerbose)
+ s->Printf("%p BreakpointID:", static_cast<void *>(this));
+
+ if (m_break_id == LLDB_INVALID_BREAK_ID)
+ s->PutCString("<invalid>");
+ else if (m_location_id == LLDB_INVALID_BREAK_ID)
+ s->Printf("%i", m_break_id);
+ else
+ s->Printf("%i.%i", m_break_id, m_location_id);
}
-void
-BreakpointID::GetCanonicalReference (Stream *s, break_id_t bp_id, break_id_t loc_id)
-{
- if (bp_id == LLDB_INVALID_BREAK_ID)
- s->PutCString ("<invalid>");
- else if (loc_id == LLDB_INVALID_BREAK_ID)
- s->Printf("%i", bp_id);
- else
- s->Printf("%i.%i", bp_id, loc_id);
+void BreakpointID::GetCanonicalReference(Stream *s, break_id_t bp_id,
+ break_id_t loc_id) {
+ if (bp_id == LLDB_INVALID_BREAK_ID)
+ s->PutCString("<invalid>");
+ else if (loc_id == LLDB_INVALID_BREAK_ID)
+ s->Printf("%i", bp_id);
+ else
+ s->Printf("%i.%i", bp_id, loc_id);
}
-bool
-BreakpointID::ParseCanonicalReference (const char *input, break_id_t *break_id_ptr, break_id_t *break_loc_id_ptr)
-{
- *break_id_ptr = LLDB_INVALID_BREAK_ID;
- *break_loc_id_ptr = LLDB_INVALID_BREAK_ID;
-
- if (input == nullptr || *input == '\0')
- return false;
-
- const char *format = "%i%n.%i%n";
- int chars_consumed_1 = 0;
- int chars_consumed_2 = 0;
- int n_items_parsed = ::sscanf (input,
- format,
- break_id_ptr, // %i parse the breakpoint ID
- &chars_consumed_1, // %n gets the number of characters parsed so far
- break_loc_id_ptr, // %i parse the breakpoint location ID
- &chars_consumed_2); // %n gets the number of characters parsed so far
-
- if ((n_items_parsed == 1 && input[chars_consumed_1] == '\0') ||
- (n_items_parsed == 2 && input[chars_consumed_2] == '\0'))
- return true;
-
- // Badly formatted canonical reference.
- *break_id_ptr = LLDB_INVALID_BREAK_ID;
- *break_loc_id_ptr = LLDB_INVALID_BREAK_ID;
+bool BreakpointID::ParseCanonicalReference(const char *input,
+ break_id_t *break_id_ptr,
+ break_id_t *break_loc_id_ptr) {
+ *break_id_ptr = LLDB_INVALID_BREAK_ID;
+ *break_loc_id_ptr = LLDB_INVALID_BREAK_ID;
+
+ if (input == nullptr || *input == '\0')
return false;
+
+ const char *format = "%i%n.%i%n";
+ int chars_consumed_1 = 0;
+ int chars_consumed_2 = 0;
+ int n_items_parsed = ::sscanf(
+ input, format,
+ break_id_ptr, // %i parse the breakpoint ID
+ &chars_consumed_1, // %n gets the number of characters parsed so far
+ break_loc_id_ptr, // %i parse the breakpoint location ID
+ &chars_consumed_2); // %n gets the number of characters parsed so far
+
+ if ((n_items_parsed == 1 && input[chars_consumed_1] == '\0') ||
+ (n_items_parsed == 2 && input[chars_consumed_2] == '\0'))
+ return true;
+
+ // Badly formatted canonical reference.
+ *break_id_ptr = LLDB_INVALID_BREAK_ID;
+ *break_loc_id_ptr = LLDB_INVALID_BREAK_ID;
+ return false;
}
-bool
-BreakpointID::StringIsBreakpointName(const char *name, Error &error)
-{
- error.Clear();
-
- if (name && (name[0] >= 'A' && name[0] <= 'z'))
- {
- if (strcspn(name, ".- ") != strlen(name))
- {
- error.SetErrorStringWithFormat("invalid breakpoint name: \"%s\"", name);
- }
- return true;
+bool BreakpointID::StringIsBreakpointName(const char *name, Error &error) {
+ error.Clear();
+
+ if (name && (name[0] >= 'A' && name[0] <= 'z')) {
+ if (strcspn(name, ".- ") != strlen(name)) {
+ error.SetErrorStringWithFormat("invalid breakpoint name: \"%s\"", name);
}
- else
- return false;
+ return true;
+ } else
+ return false;
}
diff --git a/lldb/source/Breakpoint/BreakpointIDList.cpp b/lldb/source/Breakpoint/BreakpointIDList.cpp
index ebf0697..4871105 100644
--- a/lldb/source/Breakpoint/BreakpointIDList.cpp
+++ b/lldb/source/Breakpoint/BreakpointIDList.cpp
@@ -15,8 +15,8 @@
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
-#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/Args.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Target/Target.h"
using namespace lldb;
@@ -26,412 +26,370 @@ using namespace lldb_private;
// class BreakpointIDList
//----------------------------------------------------------------------
-BreakpointIDList::BreakpointIDList () :
-m_invalid_id (LLDB_INVALID_BREAK_ID, LLDB_INVALID_BREAK_ID)
-{
-}
+BreakpointIDList::BreakpointIDList()
+ : m_invalid_id(LLDB_INVALID_BREAK_ID, LLDB_INVALID_BREAK_ID) {}
BreakpointIDList::~BreakpointIDList() = default;
-size_t
-BreakpointIDList::GetSize()
-{
- return m_breakpoint_ids.size();
-}
+size_t BreakpointIDList::GetSize() { return m_breakpoint_ids.size(); }
-BreakpointID &
-BreakpointIDList::GetBreakpointIDAtIndex(size_t index)
-{
- return ((index < m_breakpoint_ids.size()) ? m_breakpoint_ids[index] : m_invalid_id);
+BreakpointID &BreakpointIDList::GetBreakpointIDAtIndex(size_t index) {
+ return ((index < m_breakpoint_ids.size()) ? m_breakpoint_ids[index]
+ : m_invalid_id);
}
-bool
-BreakpointIDList::RemoveBreakpointIDAtIndex (size_t index)
-{
- if (index >= m_breakpoint_ids.size())
- return false;
+bool BreakpointIDList::RemoveBreakpointIDAtIndex(size_t index) {
+ if (index >= m_breakpoint_ids.size())
+ return false;
- m_breakpoint_ids.erase (m_breakpoint_ids.begin() + index);
- return true;
+ m_breakpoint_ids.erase(m_breakpoint_ids.begin() + index);
+ return true;
}
-void
-BreakpointIDList::Clear()
-{
- m_breakpoint_ids.clear ();
-}
+void BreakpointIDList::Clear() { m_breakpoint_ids.clear(); }
-bool
-BreakpointIDList::AddBreakpointID (BreakpointID bp_id)
-{
- m_breakpoint_ids.push_back (bp_id);
+bool BreakpointIDList::AddBreakpointID(BreakpointID bp_id) {
+ m_breakpoint_ids.push_back(bp_id);
- return true; // We don't do any verification in this function, so always return true.
+ return true; // We don't do any verification in this function, so always
+ // return true.
}
-bool
-BreakpointIDList::AddBreakpointID (const char *bp_id_str)
-{
- BreakpointID temp_bp_id;
- break_id_t bp_id;
- break_id_t loc_id;
+bool BreakpointIDList::AddBreakpointID(const char *bp_id_str) {
+ BreakpointID temp_bp_id;
+ break_id_t bp_id;
+ break_id_t loc_id;
- bool success = BreakpointID::ParseCanonicalReference (bp_id_str, &bp_id, &loc_id);
+ bool success =
+ BreakpointID::ParseCanonicalReference(bp_id_str, &bp_id, &loc_id);
- if (success)
- {
- temp_bp_id.SetID (bp_id, loc_id);
- m_breakpoint_ids.push_back (temp_bp_id);
- }
+ if (success) {
+ temp_bp_id.SetID(bp_id, loc_id);
+ m_breakpoint_ids.push_back(temp_bp_id);
+ }
- return success;
+ return success;
}
-bool
-BreakpointIDList::FindBreakpointID (BreakpointID &bp_id, size_t *position)
-{
- for (size_t i = 0; i < m_breakpoint_ids.size(); ++i)
- {
- BreakpointID tmp_id = m_breakpoint_ids[i];
- if (tmp_id.GetBreakpointID() == bp_id.GetBreakpointID()
- && tmp_id.GetLocationID() == bp_id.GetLocationID())
- {
- *position = i;
- return true;
- }
+bool BreakpointIDList::FindBreakpointID(BreakpointID &bp_id, size_t *position) {
+ for (size_t i = 0; i < m_breakpoint_ids.size(); ++i) {
+ BreakpointID tmp_id = m_breakpoint_ids[i];
+ if (tmp_id.GetBreakpointID() == bp_id.GetBreakpointID() &&
+ tmp_id.GetLocationID() == bp_id.GetLocationID()) {
+ *position = i;
+ return true;
}
+ }
+ return false;
+}
+
+bool BreakpointIDList::FindBreakpointID(const char *bp_id_str,
+ size_t *position) {
+ BreakpointID temp_bp_id;
+ break_id_t bp_id;
+ break_id_t loc_id;
+
+ if (BreakpointID::ParseCanonicalReference(bp_id_str, &bp_id, &loc_id)) {
+ temp_bp_id.SetID(bp_id, loc_id);
+ return FindBreakpointID(temp_bp_id, position);
+ } else
return false;
}
-bool
-BreakpointIDList::FindBreakpointID (const char *bp_id_str, size_t *position)
-{
- BreakpointID temp_bp_id;
+void BreakpointIDList::InsertStringArray(const char **string_array,
+ size_t array_size,
+ CommandReturnObject &result) {
+ if (string_array == nullptr)
+ return;
+
+ for (uint32_t i = 0; i < array_size; ++i) {
break_id_t bp_id;
break_id_t loc_id;
- if (BreakpointID::ParseCanonicalReference (bp_id_str, &bp_id, &loc_id))
- {
- temp_bp_id.SetID (bp_id, loc_id);
- return FindBreakpointID (temp_bp_id, position);
- }
- else
- return false;
-}
-
-void
-BreakpointIDList::InsertStringArray (const char **string_array, size_t array_size, CommandReturnObject &result)
-{
- if (string_array == nullptr)
+ if (BreakpointID::ParseCanonicalReference(string_array[i], &bp_id,
+ &loc_id)) {
+ if (bp_id != LLDB_INVALID_BREAK_ID) {
+ BreakpointID temp_bp_id(bp_id, loc_id);
+ m_breakpoint_ids.push_back(temp_bp_id);
+ } else {
+ result.AppendErrorWithFormat("'%s' is not a valid breakpoint ID.\n",
+ string_array[i]);
+ result.SetStatus(eReturnStatusFailed);
return;
-
- for (uint32_t i = 0; i < array_size; ++i)
- {
- break_id_t bp_id;
- break_id_t loc_id;
-
- if (BreakpointID::ParseCanonicalReference (string_array[i], &bp_id, &loc_id))
- {
- if (bp_id != LLDB_INVALID_BREAK_ID)
- {
- BreakpointID temp_bp_id(bp_id, loc_id);
- m_breakpoint_ids.push_back (temp_bp_id);
- }
- else
- {
- result.AppendErrorWithFormat ("'%s' is not a valid breakpoint ID.\n", string_array[i]);
- result.SetStatus (eReturnStatusFailed);
- return;
- }
- }
+ }
}
- result.SetStatus (eReturnStatusSuccessFinishNoResult);
+ }
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
}
+// This function takes OLD_ARGS, which is usually the result of breaking the
+// command string arguments into
+// an array of space-separated strings, and searches through the arguments for
+// any breakpoint ID range specifiers.
+// Any string in the array that is not part of an ID range specifier is copied
+// directly into NEW_ARGS. If any
+// ID range specifiers are found, the range is interpreted and a list of
+// canonical breakpoint IDs corresponding to
+// all the current breakpoints and locations in the range are added to
+// NEW_ARGS. When this function is done,
+// NEW_ARGS should be a copy of OLD_ARGS, with and ID range specifiers replaced
+// by the members of the range.
+
+void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target,
+ bool allow_locations,
+ CommandReturnObject &result,
+ Args &new_args) {
+ std::string range_start;
+ const char *range_end;
+ const char *current_arg;
+ const size_t num_old_args = old_args.GetArgumentCount();
+ std::set<std::string> names_found;
+
+ for (size_t i = 0; i < num_old_args; ++i) {
+ bool is_range = false;
+
+ current_arg = old_args.GetArgumentAtIndex(i);
+ if (!allow_locations && strchr(current_arg, '.') != nullptr) {
+ result.AppendErrorWithFormat(
+ "Breakpoint locations not allowed, saw location: %s.", current_arg);
+ new_args.Clear();
+ return;
+ }
-// This function takes OLD_ARGS, which is usually the result of breaking the command string arguments into
-// an array of space-separated strings, and searches through the arguments for any breakpoint ID range specifiers.
-// Any string in the array that is not part of an ID range specifier is copied directly into NEW_ARGS. If any
-// ID range specifiers are found, the range is interpreted and a list of canonical breakpoint IDs corresponding to
-// all the current breakpoints and locations in the range are added to NEW_ARGS. When this function is done,
-// NEW_ARGS should be a copy of OLD_ARGS, with and ID range specifiers replaced by the members of the range.
-
-void
-BreakpointIDList::FindAndReplaceIDRanges (Args &old_args,
- Target *target,
- bool allow_locations,
- CommandReturnObject &result,
- Args &new_args)
-{
- std::string range_start;
- const char *range_end;
- const char *current_arg;
- const size_t num_old_args = old_args.GetArgumentCount();
- std::set<std::string> names_found;
-
- for (size_t i = 0; i < num_old_args; ++i)
- {
- bool is_range = false;
-
- current_arg = old_args.GetArgumentAtIndex (i);
- if (!allow_locations && strchr(current_arg, '.') != nullptr)
- {
- result.AppendErrorWithFormat ("Breakpoint locations not allowed, saw location: %s.", current_arg);
+ size_t range_start_len = 0;
+ size_t range_end_pos = 0;
+ Error error;
+
+ if (BreakpointIDList::StringContainsIDRangeExpression(
+ current_arg, &range_start_len, &range_end_pos)) {
+ is_range = true;
+ range_start.assign(current_arg, range_start_len);
+ range_end = current_arg + range_end_pos;
+ } else if (BreakpointID::StringIsBreakpointName(current_arg, error)) {
+ if (!error.Success()) {
+ new_args.Clear();
+ result.AppendError(error.AsCString());
+ result.SetStatus(eReturnStatusFailed);
+ return;
+ } else
+ names_found.insert(current_arg);
+ } else if ((i + 2 < num_old_args) &&
+ BreakpointID::IsRangeIdentifier(
+ old_args.GetArgumentAtIndex(i + 1)) &&
+ BreakpointID::IsValidIDExpression(current_arg) &&
+ BreakpointID::IsValidIDExpression(
+ old_args.GetArgumentAtIndex(i + 2))) {
+ range_start.assign(current_arg);
+ range_end = old_args.GetArgumentAtIndex(i + 2);
+ is_range = true;
+ i = i + 2;
+ } else {
+ // See if user has specified id.*
+ std::string tmp_str = old_args.GetArgumentAtIndex(i);
+ size_t pos = tmp_str.find('.');
+ if (pos != std::string::npos) {
+ std::string bp_id_str = tmp_str.substr(0, pos);
+ if (BreakpointID::IsValidIDExpression(bp_id_str.c_str()) &&
+ tmp_str[pos + 1] == '*' && tmp_str.length() == (pos + 2)) {
+ break_id_t bp_id;
+ break_id_t bp_loc_id;
+
+ BreakpointID::ParseCanonicalReference(bp_id_str.c_str(), &bp_id,
+ &bp_loc_id);
+ BreakpointSP breakpoint_sp = target->GetBreakpointByID(bp_id);
+ if (!breakpoint_sp) {
new_args.Clear();
+ result.AppendErrorWithFormat("'%d' is not a valid breakpoint ID.\n",
+ bp_id);
+ result.SetStatus(eReturnStatusFailed);
return;
+ }
+ const size_t num_locations = breakpoint_sp->GetNumLocations();
+ for (size_t j = 0; j < num_locations; ++j) {
+ BreakpointLocation *bp_loc =
+ breakpoint_sp->GetLocationAtIndex(j).get();
+ StreamString canonical_id_str;
+ BreakpointID::GetCanonicalReference(&canonical_id_str, bp_id,
+ bp_loc->GetID());
+ new_args.AppendArgument(canonical_id_str.GetData());
+ }
}
+ }
+ }
- size_t range_start_len = 0;
- size_t range_end_pos = 0;
- Error error;
-
- if (BreakpointIDList::StringContainsIDRangeExpression (current_arg, &range_start_len, &range_end_pos))
- {
- is_range = true;
- range_start.assign (current_arg, range_start_len);
- range_end = current_arg + range_end_pos;
- }
- else if (BreakpointID::StringIsBreakpointName(current_arg, error))
- {
- if (!error.Success())
- {
- new_args.Clear();
- result.AppendError (error.AsCString());
- result.SetStatus (eReturnStatusFailed);
- return;
- }
- else
- names_found.insert(current_arg);
- }
- else if ((i + 2 < num_old_args)
- && BreakpointID::IsRangeIdentifier (old_args.GetArgumentAtIndex (i+1))
- && BreakpointID::IsValidIDExpression (current_arg)
- && BreakpointID::IsValidIDExpression (old_args.GetArgumentAtIndex (i+2)))
- {
- range_start.assign (current_arg);
- range_end = old_args.GetArgumentAtIndex (i+2);
- is_range = true;
- i = i+2;
- }
- else
- {
- // See if user has specified id.*
- std::string tmp_str = old_args.GetArgumentAtIndex (i);
- size_t pos = tmp_str.find ('.');
- if (pos != std::string::npos)
- {
- std::string bp_id_str = tmp_str.substr (0, pos);
- if (BreakpointID::IsValidIDExpression (bp_id_str.c_str())
- && tmp_str[pos+1] == '*'
- && tmp_str.length() == (pos + 2))
- {
- break_id_t bp_id;
- break_id_t bp_loc_id;
-
- BreakpointID::ParseCanonicalReference (bp_id_str.c_str(), &bp_id, &bp_loc_id);
- BreakpointSP breakpoint_sp = target->GetBreakpointByID (bp_id);
- if (! breakpoint_sp)
- {
- new_args.Clear();
- result.AppendErrorWithFormat ("'%d' is not a valid breakpoint ID.\n", bp_id);
- result.SetStatus (eReturnStatusFailed);
- return;
- }
- const size_t num_locations = breakpoint_sp->GetNumLocations();
- for (size_t j = 0; j < num_locations; ++j)
- {
- BreakpointLocation *bp_loc = breakpoint_sp->GetLocationAtIndex(j).get();
- StreamString canonical_id_str;
- BreakpointID::GetCanonicalReference (&canonical_id_str, bp_id, bp_loc->GetID());
- new_args.AppendArgument (canonical_id_str.GetData());
- }
- }
-
- }
+ if (is_range) {
+ break_id_t start_bp_id;
+ break_id_t end_bp_id;
+ break_id_t start_loc_id;
+ break_id_t end_loc_id;
+
+ BreakpointID::ParseCanonicalReference(range_start.c_str(), &start_bp_id,
+ &start_loc_id);
+ BreakpointID::ParseCanonicalReference(range_end, &end_bp_id, &end_loc_id);
+
+ if ((start_bp_id == LLDB_INVALID_BREAK_ID) ||
+ (!target->GetBreakpointByID(start_bp_id))) {
+ new_args.Clear();
+ result.AppendErrorWithFormat("'%s' is not a valid breakpoint ID.\n",
+ range_start.c_str());
+ result.SetStatus(eReturnStatusFailed);
+ return;
+ }
+
+ if ((end_bp_id == LLDB_INVALID_BREAK_ID) ||
+ (!target->GetBreakpointByID(end_bp_id))) {
+ new_args.Clear();
+ result.AppendErrorWithFormat("'%s' is not a valid breakpoint ID.\n",
+ range_end);
+ result.SetStatus(eReturnStatusFailed);
+ return;
+ }
+
+ if (((start_loc_id == LLDB_INVALID_BREAK_ID) &&
+ (end_loc_id != LLDB_INVALID_BREAK_ID)) ||
+ ((start_loc_id != LLDB_INVALID_BREAK_ID) &&
+ (end_loc_id == LLDB_INVALID_BREAK_ID))) {
+ new_args.Clear();
+ result.AppendErrorWithFormat("Invalid breakpoint id range: Either "
+ "both ends of range must specify"
+ " a breakpoint location, or neither can "
+ "specify a breakpoint location.\n");
+ result.SetStatus(eReturnStatusFailed);
+ return;
+ }
+
+ // We have valid range starting & ending breakpoint IDs. Go through all
+ // the breakpoints in the
+ // target and find all the breakpoints that fit into this range, and add
+ // them to new_args.
+
+ // Next check to see if we have location id's. If so, make sure the
+ // start_bp_id and end_bp_id are
+ // for the same breakpoint; otherwise we have an illegal range: breakpoint
+ // id ranges that specify
+ // bp locations are NOT allowed to cross major bp id numbers.
+
+ if ((start_loc_id != LLDB_INVALID_BREAK_ID) ||
+ (end_loc_id != LLDB_INVALID_BREAK_ID)) {
+ if (start_bp_id != end_bp_id) {
+ new_args.Clear();
+ result.AppendErrorWithFormat(
+ "Invalid range: Ranges that specify particular breakpoint "
+ "locations"
+ " must be within the same major breakpoint; you specified two"
+ " different major breakpoints, %d and %d.\n",
+ start_bp_id, end_bp_id);
+ result.SetStatus(eReturnStatusFailed);
+ return;
}
-
- if (is_range)
- {
- break_id_t start_bp_id;
- break_id_t end_bp_id;
- break_id_t start_loc_id;
- break_id_t end_loc_id;
-
- BreakpointID::ParseCanonicalReference (range_start.c_str(), &start_bp_id, &start_loc_id);
- BreakpointID::ParseCanonicalReference (range_end, &end_bp_id, &end_loc_id);
-
- if ((start_bp_id == LLDB_INVALID_BREAK_ID)
- || (! target->GetBreakpointByID (start_bp_id)))
- {
- new_args.Clear();
- result.AppendErrorWithFormat ("'%s' is not a valid breakpoint ID.\n", range_start.c_str());
- result.SetStatus (eReturnStatusFailed);
- return;
- }
-
- if ((end_bp_id == LLDB_INVALID_BREAK_ID)
- || (! target->GetBreakpointByID (end_bp_id)))
- {
- new_args.Clear();
- result.AppendErrorWithFormat ("'%s' is not a valid breakpoint ID.\n", range_end);
- result.SetStatus (eReturnStatusFailed);
- return;
- }
-
-
- if (((start_loc_id == LLDB_INVALID_BREAK_ID)
- && (end_loc_id != LLDB_INVALID_BREAK_ID))
- || ((start_loc_id != LLDB_INVALID_BREAK_ID)
- && (end_loc_id == LLDB_INVALID_BREAK_ID)))
- {
- new_args.Clear ();
- result.AppendErrorWithFormat ("Invalid breakpoint id range: Either both ends of range must specify"
- " a breakpoint location, or neither can specify a breakpoint location.\n");
- result.SetStatus (eReturnStatusFailed);
- return;
+ }
+
+ const BreakpointList &breakpoints = target->GetBreakpointList();
+ const size_t num_breakpoints = breakpoints.GetSize();
+ for (size_t j = 0; j < num_breakpoints; ++j) {
+ Breakpoint *breakpoint = breakpoints.GetBreakpointAtIndex(j).get();
+ break_id_t cur_bp_id = breakpoint->GetID();
+
+ if ((cur_bp_id < start_bp_id) || (cur_bp_id > end_bp_id))
+ continue;
+
+ const size_t num_locations = breakpoint->GetNumLocations();
+
+ if ((cur_bp_id == start_bp_id) &&
+ (start_loc_id != LLDB_INVALID_BREAK_ID)) {
+ for (size_t k = 0; k < num_locations; ++k) {
+ BreakpointLocation *bp_loc =
+ breakpoint->GetLocationAtIndex(k).get();
+ if ((bp_loc->GetID() >= start_loc_id) &&
+ (bp_loc->GetID() <= end_loc_id)) {
+ StreamString canonical_id_str;
+ BreakpointID::GetCanonicalReference(&canonical_id_str, cur_bp_id,
+ bp_loc->GetID());
+ new_args.AppendArgument(canonical_id_str.GetData());
}
-
- // We have valid range starting & ending breakpoint IDs. Go through all the breakpoints in the
- // target and find all the breakpoints that fit into this range, and add them to new_args.
-
- // Next check to see if we have location id's. If so, make sure the start_bp_id and end_bp_id are
- // for the same breakpoint; otherwise we have an illegal range: breakpoint id ranges that specify
- // bp locations are NOT allowed to cross major bp id numbers.
-
- if ((start_loc_id != LLDB_INVALID_BREAK_ID)
- || (end_loc_id != LLDB_INVALID_BREAK_ID))
- {
- if (start_bp_id != end_bp_id)
- {
- new_args.Clear();
- result.AppendErrorWithFormat ("Invalid range: Ranges that specify particular breakpoint locations"
- " must be within the same major breakpoint; you specified two"
- " different major breakpoints, %d and %d.\n",
- start_bp_id, end_bp_id);
- result.SetStatus (eReturnStatusFailed);
- return;
- }
- }
-
- const BreakpointList& breakpoints = target->GetBreakpointList();
- const size_t num_breakpoints = breakpoints.GetSize();
- for (size_t j = 0; j < num_breakpoints; ++j)
- {
- Breakpoint *breakpoint = breakpoints.GetBreakpointAtIndex (j).get();
- break_id_t cur_bp_id = breakpoint->GetID();
-
- if ((cur_bp_id < start_bp_id) || (cur_bp_id > end_bp_id))
- continue;
-
- const size_t num_locations = breakpoint->GetNumLocations();
-
- if ((cur_bp_id == start_bp_id) && (start_loc_id != LLDB_INVALID_BREAK_ID))
- {
- for (size_t k = 0; k < num_locations; ++k)
- {
- BreakpointLocation * bp_loc = breakpoint->GetLocationAtIndex(k).get();
- if ((bp_loc->GetID() >= start_loc_id) && (bp_loc->GetID() <= end_loc_id))
- {
- StreamString canonical_id_str;
- BreakpointID::GetCanonicalReference (&canonical_id_str, cur_bp_id, bp_loc->GetID());
- new_args.AppendArgument (canonical_id_str.GetData());
- }
- }
- }
- else if ((cur_bp_id == end_bp_id) && (end_loc_id != LLDB_INVALID_BREAK_ID))
- {
- for (size_t k = 0; k < num_locations; ++k)
- {
- BreakpointLocation * bp_loc = breakpoint->GetLocationAtIndex(k).get();
- if (bp_loc->GetID() <= end_loc_id)
- {
- StreamString canonical_id_str;
- BreakpointID::GetCanonicalReference (&canonical_id_str, cur_bp_id, bp_loc->GetID());
- new_args.AppendArgument (canonical_id_str.GetData());
- }
- }
- }
- else
- {
- StreamString canonical_id_str;
- BreakpointID::GetCanonicalReference (&canonical_id_str, cur_bp_id, LLDB_INVALID_BREAK_ID);
- new_args.AppendArgument (canonical_id_str.GetData());
- }
+ }
+ } else if ((cur_bp_id == end_bp_id) &&
+ (end_loc_id != LLDB_INVALID_BREAK_ID)) {
+ for (size_t k = 0; k < num_locations; ++k) {
+ BreakpointLocation *bp_loc =
+ breakpoint->GetLocationAtIndex(k).get();
+ if (bp_loc->GetID() <= end_loc_id) {
+ StreamString canonical_id_str;
+ BreakpointID::GetCanonicalReference(&canonical_id_str, cur_bp_id,
+ bp_loc->GetID());
+ new_args.AppendArgument(canonical_id_str.GetData());
}
+ }
+ } else {
+ StreamString canonical_id_str;
+ BreakpointID::GetCanonicalReference(&canonical_id_str, cur_bp_id,
+ LLDB_INVALID_BREAK_ID);
+ new_args.AppendArgument(canonical_id_str.GetData());
}
- else // else is_range was false
- {
- new_args.AppendArgument (current_arg);
- }
- }
-
- // Okay, now see if we found any names, and if we did, add them:
- if (target && names_found.size())
+ }
+ } else // else is_range was false
{
- for (BreakpointSP bkpt_sp : target->GetBreakpointList().Breakpoints())
- {
- for (std::string name : names_found)
- {
- if (bkpt_sp->MatchesName(name.c_str()))
- {
- StreamString canonical_id_str;
- BreakpointID::GetCanonicalReference (&canonical_id_str, bkpt_sp->GetID(), LLDB_INVALID_BREAK_ID);
- new_args.AppendArgument (canonical_id_str.GetData());
- }
- }
+ new_args.AppendArgument(current_arg);
+ }
+ }
+
+ // Okay, now see if we found any names, and if we did, add them:
+ if (target && names_found.size()) {
+ for (BreakpointSP bkpt_sp : target->GetBreakpointList().Breakpoints()) {
+ for (std::string name : names_found) {
+ if (bkpt_sp->MatchesName(name.c_str())) {
+ StreamString canonical_id_str;
+ BreakpointID::GetCanonicalReference(
+ &canonical_id_str, bkpt_sp->GetID(), LLDB_INVALID_BREAK_ID);
+ new_args.AppendArgument(canonical_id_str.GetData());
}
+ }
}
+ }
- result.SetStatus (eReturnStatusSuccessFinishNoResult);
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
}
-bool
-BreakpointIDList::StringContainsIDRangeExpression (const char *in_string,
- size_t *range_start_len,
- size_t *range_end_pos)
-{
- bool is_range_expression = false;
- std::string arg_str = in_string;
- std::string::size_type idx;
- std::string::size_type start_pos = 0;
-
- *range_start_len = 0;
- *range_end_pos = 0;
-
- int specifiers_size = 0;
- for (int i = 0; BreakpointID::g_range_specifiers[i] != nullptr; ++i)
- ++specifiers_size;
-
- for (int i = 0; i < specifiers_size && !is_range_expression; ++i)
- {
- const char *specifier_str = BreakpointID::g_range_specifiers[i];
- size_t len = strlen (specifier_str);
- idx = arg_str.find (BreakpointID::g_range_specifiers[i]);
- if (idx != std::string::npos)
- {
- *range_start_len = idx - start_pos;
- std::string start_str = arg_str.substr (start_pos, *range_start_len);
- if (idx + len < arg_str.length())
- {
- *range_end_pos = idx + len;
- std::string end_str = arg_str.substr (*range_end_pos);
- if (BreakpointID::IsValidIDExpression (start_str.c_str())
- && BreakpointID::IsValidIDExpression (end_str.c_str()))
- {
- is_range_expression = true;
- //*range_start = start_str;
- //*range_end = end_str;
- }
- }
+bool BreakpointIDList::StringContainsIDRangeExpression(const char *in_string,
+ size_t *range_start_len,
+ size_t *range_end_pos) {
+ bool is_range_expression = false;
+ std::string arg_str = in_string;
+ std::string::size_type idx;
+ std::string::size_type start_pos = 0;
+
+ *range_start_len = 0;
+ *range_end_pos = 0;
+
+ int specifiers_size = 0;
+ for (int i = 0; BreakpointID::g_range_specifiers[i] != nullptr; ++i)
+ ++specifiers_size;
+
+ for (int i = 0; i < specifiers_size && !is_range_expression; ++i) {
+ const char *specifier_str = BreakpointID::g_range_specifiers[i];
+ size_t len = strlen(specifier_str);
+ idx = arg_str.find(BreakpointID::g_range_specifiers[i]);
+ if (idx != std::string::npos) {
+ *range_start_len = idx - start_pos;
+ std::string start_str = arg_str.substr(start_pos, *range_start_len);
+ if (idx + len < arg_str.length()) {
+ *range_end_pos = idx + len;
+ std::string end_str = arg_str.substr(*range_end_pos);
+ if (BreakpointID::IsValidIDExpression(start_str.c_str()) &&
+ BreakpointID::IsValidIDExpression(end_str.c_str())) {
+ is_range_expression = true;
+ //*range_start = start_str;
+ //*range_end = end_str;
}
+ }
}
+ }
- if (!is_range_expression)
- {
- *range_start_len = 0;
- *range_end_pos = 0;
- }
+ if (!is_range_expression) {
+ *range_start_len = 0;
+ *range_end_pos = 0;
+ }
- return is_range_expression;
+ return is_range_expression;
}
diff --git a/lldb/source/Breakpoint/BreakpointList.cpp b/lldb/source/Breakpoint/BreakpointList.cpp
index 9877c2d..a47a07d 100644
--- a/lldb/source/Breakpoint/BreakpointList.cpp
+++ b/lldb/source/Breakpoint/BreakpointList.cpp
@@ -19,222 +19,183 @@ using namespace lldb;
using namespace lldb_private;
BreakpointList::BreakpointList(bool is_internal)
- : m_mutex(), m_breakpoints(), m_next_break_id(0), m_is_internal(is_internal)
-{
-}
-
-BreakpointList::~BreakpointList()
-{
-}
-
-
-break_id_t
-BreakpointList::Add (BreakpointSP &bp_sp, bool notify)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- // Internal breakpoint IDs are negative, normal ones are positive
- bp_sp->SetID (m_is_internal ? --m_next_break_id : ++m_next_break_id);
-
- m_breakpoints.push_back(bp_sp);
- if (notify)
- {
- if (bp_sp->GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged))
- bp_sp->GetTarget().BroadcastEvent (Target::eBroadcastBitBreakpointChanged,
- new Breakpoint::BreakpointEventData (eBreakpointEventTypeAdded, bp_sp));
- }
- return bp_sp->GetID();
-}
-
-bool
-BreakpointList::Remove (break_id_t break_id, bool notify)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- bp_collection::iterator pos = GetBreakpointIDIterator(break_id); // Predicate
- if (pos != m_breakpoints.end())
- {
- BreakpointSP bp_sp (*pos);
- m_breakpoints.erase(pos);
- if (notify)
- {
- if (bp_sp->GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged))
- bp_sp->GetTarget().BroadcastEvent (Target::eBroadcastBitBreakpointChanged,
- new Breakpoint::BreakpointEventData (eBreakpointEventTypeRemoved, bp_sp));
- }
- return true;
+ : m_mutex(), m_breakpoints(), m_next_break_id(0),
+ m_is_internal(is_internal) {}
+
+BreakpointList::~BreakpointList() {}
+
+break_id_t BreakpointList::Add(BreakpointSP &bp_sp, bool notify) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ // Internal breakpoint IDs are negative, normal ones are positive
+ bp_sp->SetID(m_is_internal ? --m_next_break_id : ++m_next_break_id);
+
+ m_breakpoints.push_back(bp_sp);
+ if (notify) {
+ if (bp_sp->GetTarget().EventTypeHasListeners(
+ Target::eBroadcastBitBreakpointChanged))
+ bp_sp->GetTarget().BroadcastEvent(Target::eBroadcastBitBreakpointChanged,
+ new Breakpoint::BreakpointEventData(
+ eBreakpointEventTypeAdded, bp_sp));
+ }
+ return bp_sp->GetID();
+}
+
+bool BreakpointList::Remove(break_id_t break_id, bool notify) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ bp_collection::iterator pos = GetBreakpointIDIterator(break_id); // Predicate
+ if (pos != m_breakpoints.end()) {
+ BreakpointSP bp_sp(*pos);
+ m_breakpoints.erase(pos);
+ if (notify) {
+ if (bp_sp->GetTarget().EventTypeHasListeners(
+ Target::eBroadcastBitBreakpointChanged))
+ bp_sp->GetTarget().BroadcastEvent(
+ Target::eBroadcastBitBreakpointChanged,
+ new Breakpoint::BreakpointEventData(eBreakpointEventTypeRemoved,
+ bp_sp));
}
- return false;
+ return true;
+ }
+ return false;
}
-void
-BreakpointList::RemoveInvalidLocations (const ArchSpec &arch)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- for (const auto &bp_sp : m_breakpoints)
- bp_sp->RemoveInvalidLocations(arch);
+void BreakpointList::RemoveInvalidLocations(const ArchSpec &arch) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ for (const auto &bp_sp : m_breakpoints)
+ bp_sp->RemoveInvalidLocations(arch);
}
-
-void
-BreakpointList::SetEnabledAll (bool enabled)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- for (const auto &bp_sp : m_breakpoints)
- bp_sp->SetEnabled (enabled);
+void BreakpointList::SetEnabledAll(bool enabled) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ for (const auto &bp_sp : m_breakpoints)
+ bp_sp->SetEnabled(enabled);
}
+void BreakpointList::RemoveAll(bool notify) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ ClearAllBreakpointSites();
-void
-BreakpointList::RemoveAll (bool notify)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- ClearAllBreakpointSites ();
-
- if (notify)
- {
- bp_collection::iterator pos, end = m_breakpoints.end();
- for (pos = m_breakpoints.begin(); pos != end; ++pos)
- {
- if ((*pos)->GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged))
- {
- (*pos)->GetTarget().BroadcastEvent (Target::eBroadcastBitBreakpointChanged,
- new Breakpoint::BreakpointEventData (eBreakpointEventTypeRemoved,
- *pos));
- }
- }
+ if (notify) {
+ bp_collection::iterator pos, end = m_breakpoints.end();
+ for (pos = m_breakpoints.begin(); pos != end; ++pos) {
+ if ((*pos)->GetTarget().EventTypeHasListeners(
+ Target::eBroadcastBitBreakpointChanged)) {
+ (*pos)->GetTarget().BroadcastEvent(
+ Target::eBroadcastBitBreakpointChanged,
+ new Breakpoint::BreakpointEventData(eBreakpointEventTypeRemoved,
+ *pos));
+ }
}
- m_breakpoints.erase (m_breakpoints.begin(), m_breakpoints.end());
+ }
+ m_breakpoints.erase(m_breakpoints.begin(), m_breakpoints.end());
}
-class BreakpointIDMatches
-{
+class BreakpointIDMatches {
public:
- BreakpointIDMatches (break_id_t break_id) :
- m_break_id(break_id)
- {
- }
+ BreakpointIDMatches(break_id_t break_id) : m_break_id(break_id) {}
- bool operator() (const BreakpointSP &bp) const
- {
- return m_break_id == bp->GetID();
- }
+ bool operator()(const BreakpointSP &bp) const {
+ return m_break_id == bp->GetID();
+ }
private:
- const break_id_t m_break_id;
+ const break_id_t m_break_id;
};
BreakpointList::bp_collection::iterator
-BreakpointList::GetBreakpointIDIterator (break_id_t break_id)
-{
- return std::find_if(m_breakpoints.begin(), m_breakpoints.end(), // Search full range
- BreakpointIDMatches(break_id)); // Predicate
+BreakpointList::GetBreakpointIDIterator(break_id_t break_id) {
+ return std::find_if(m_breakpoints.begin(),
+ m_breakpoints.end(), // Search full range
+ BreakpointIDMatches(break_id)); // Predicate
}
BreakpointList::bp_collection::const_iterator
-BreakpointList::GetBreakpointIDConstIterator (break_id_t break_id) const
-{
- return std::find_if(m_breakpoints.begin(), m_breakpoints.end(), // Search full range
- BreakpointIDMatches(break_id)); // Predicate
+BreakpointList::GetBreakpointIDConstIterator(break_id_t break_id) const {
+ return std::find_if(m_breakpoints.begin(),
+ m_breakpoints.end(), // Search full range
+ BreakpointIDMatches(break_id)); // Predicate
}
-BreakpointSP
-BreakpointList::FindBreakpointByID (break_id_t break_id)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- BreakpointSP stop_sp;
- bp_collection::iterator pos = GetBreakpointIDIterator(break_id);
- if (pos != m_breakpoints.end())
- stop_sp = *pos;
+BreakpointSP BreakpointList::FindBreakpointByID(break_id_t break_id) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ BreakpointSP stop_sp;
+ bp_collection::iterator pos = GetBreakpointIDIterator(break_id);
+ if (pos != m_breakpoints.end())
+ stop_sp = *pos;
- return stop_sp;
-}
-
-const BreakpointSP
-BreakpointList::FindBreakpointByID (break_id_t break_id) const
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- BreakpointSP stop_sp;
- bp_collection::const_iterator pos = GetBreakpointIDConstIterator(break_id);
- if (pos != m_breakpoints.end())
- stop_sp = *pos;
-
- return stop_sp;
-}
-
-void
-BreakpointList::Dump (Stream *s) const
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- s->Printf("%p: ", static_cast<const void*>(this));
- s->Indent();
- s->Printf("BreakpointList with %u Breakpoints:\n", (uint32_t)m_breakpoints.size());
- s->IndentMore();
- for (const auto &bp_sp : m_breakpoints)
- bp_sp->Dump(s);
- s->IndentLess();
-}
-
-
-BreakpointSP
-BreakpointList::GetBreakpointAtIndex (size_t i)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- BreakpointSP stop_sp;
- bp_collection::iterator end = m_breakpoints.end();
- bp_collection::iterator pos;
- size_t curr_i = 0;
- for (pos = m_breakpoints.begin(), curr_i = 0; pos != end; ++pos, ++curr_i)
- {
- if (curr_i == i)
- stop_sp = *pos;
- }
- return stop_sp;
+ return stop_sp;
}
const BreakpointSP
-BreakpointList::GetBreakpointAtIndex (size_t i) const
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- BreakpointSP stop_sp;
- bp_collection::const_iterator end = m_breakpoints.end();
- bp_collection::const_iterator pos;
- size_t curr_i = 0;
- for (pos = m_breakpoints.begin(), curr_i = 0; pos != end; ++pos, ++curr_i)
- {
- if (curr_i == i)
- stop_sp = *pos;
- }
- return stop_sp;
-}
-
-void
-BreakpointList::UpdateBreakpoints (ModuleList& module_list, bool added, bool delete_locations)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- for (const auto &bp_sp : m_breakpoints)
- bp_sp->ModulesChanged (module_list, added, delete_locations);
-
-}
-
-void
-BreakpointList::UpdateBreakpointsWhenModuleIsReplaced (ModuleSP old_module_sp, ModuleSP new_module_sp)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- for (const auto &bp_sp : m_breakpoints)
- bp_sp->ModuleReplaced (old_module_sp, new_module_sp);
-
-}
-
-void
-BreakpointList::ClearAllBreakpointSites ()
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- for (const auto &bp_sp : m_breakpoints)
- bp_sp->ClearAllBreakpointSites ();
-
-}
-
-void
-BreakpointList::GetListMutex(std::unique_lock<std::recursive_mutex> &lock)
-{
- lock = std::unique_lock<std::recursive_mutex>(m_mutex);
+BreakpointList::FindBreakpointByID(break_id_t break_id) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ BreakpointSP stop_sp;
+ bp_collection::const_iterator pos = GetBreakpointIDConstIterator(break_id);
+ if (pos != m_breakpoints.end())
+ stop_sp = *pos;
+
+ return stop_sp;
+}
+
+void BreakpointList::Dump(Stream *s) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ s->Printf("%p: ", static_cast<const void *>(this));
+ s->Indent();
+ s->Printf("BreakpointList with %u Breakpoints:\n",
+ (uint32_t)m_breakpoints.size());
+ s->IndentMore();
+ for (const auto &bp_sp : m_breakpoints)
+ bp_sp->Dump(s);
+ s->IndentLess();
+}
+
+BreakpointSP BreakpointList::GetBreakpointAtIndex(size_t i) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ BreakpointSP stop_sp;
+ bp_collection::iterator end = m_breakpoints.end();
+ bp_collection::iterator pos;
+ size_t curr_i = 0;
+ for (pos = m_breakpoints.begin(), curr_i = 0; pos != end; ++pos, ++curr_i) {
+ if (curr_i == i)
+ stop_sp = *pos;
+ }
+ return stop_sp;
+}
+
+const BreakpointSP BreakpointList::GetBreakpointAtIndex(size_t i) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ BreakpointSP stop_sp;
+ bp_collection::const_iterator end = m_breakpoints.end();
+ bp_collection::const_iterator pos;
+ size_t curr_i = 0;
+ for (pos = m_breakpoints.begin(), curr_i = 0; pos != end; ++pos, ++curr_i) {
+ if (curr_i == i)
+ stop_sp = *pos;
+ }
+ return stop_sp;
+}
+
+void BreakpointList::UpdateBreakpoints(ModuleList &module_list, bool added,
+ bool delete_locations) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ for (const auto &bp_sp : m_breakpoints)
+ bp_sp->ModulesChanged(module_list, added, delete_locations);
+}
+
+void BreakpointList::UpdateBreakpointsWhenModuleIsReplaced(
+ ModuleSP old_module_sp, ModuleSP new_module_sp) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ for (const auto &bp_sp : m_breakpoints)
+ bp_sp->ModuleReplaced(old_module_sp, new_module_sp);
+}
+
+void BreakpointList::ClearAllBreakpointSites() {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ for (const auto &bp_sp : m_breakpoints)
+ bp_sp->ClearAllBreakpointSites();
+}
+
+void BreakpointList::GetListMutex(
+ std::unique_lock<std::recursive_mutex> &lock) {
+ lock = std::unique_lock<std::recursive_mutex>(m_mutex);
}
diff --git a/lldb/source/Breakpoint/BreakpointLocation.cpp b/lldb/source/Breakpoint/BreakpointLocation.cpp
index e1b1af0..c68bf6a 100644
--- a/lldb/source/Breakpoint/BreakpointLocation.cpp
+++ b/lldb/source/Breakpoint/BreakpointLocation.cpp
@@ -25,421 +25,336 @@
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/TypeSystem.h"
-#include "lldb/Target/Target.h"
#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadSpec.h"
using namespace lldb;
using namespace lldb_private;
-BreakpointLocation::BreakpointLocation(break_id_t loc_id, Breakpoint &owner, const Address &addr, lldb::tid_t tid,
+BreakpointLocation::BreakpointLocation(break_id_t loc_id, Breakpoint &owner,
+ const Address &addr, lldb::tid_t tid,
bool hardware, bool check_for_resolver)
- : StoppointLocation(loc_id, addr.GetOpcodeLoadAddress(&owner.GetTarget()), hardware),
- m_being_created(true),
- m_should_resolve_indirect_functions(false),
- m_is_reexported(false),
- m_is_indirect(false),
- m_address(addr),
- m_owner(owner),
- m_options_ap(),
- m_bp_site_sp(),
- m_condition_mutex()
-{
- if (check_for_resolver)
- {
- Symbol *symbol = m_address.CalculateSymbolContextSymbol();
- if (symbol && symbol->IsIndirect())
- {
- SetShouldResolveIndirectFunctions(true);
- }
+ : StoppointLocation(loc_id, addr.GetOpcodeLoadAddress(&owner.GetTarget()),
+ hardware),
+ m_being_created(true), m_should_resolve_indirect_functions(false),
+ m_is_reexported(false), m_is_indirect(false), m_address(addr),
+ m_owner(owner), m_options_ap(), m_bp_site_sp(), m_condition_mutex() {
+ if (check_for_resolver) {
+ Symbol *symbol = m_address.CalculateSymbolContextSymbol();
+ if (symbol && symbol->IsIndirect()) {
+ SetShouldResolveIndirectFunctions(true);
}
+ }
- SetThreadID(tid);
- m_being_created = false;
+ SetThreadID(tid);
+ m_being_created = false;
}
-BreakpointLocation::~BreakpointLocation()
-{
- ClearBreakpointSite();
-}
+BreakpointLocation::~BreakpointLocation() { ClearBreakpointSite(); }
-lldb::addr_t
-BreakpointLocation::GetLoadAddress () const
-{
- return m_address.GetOpcodeLoadAddress (&m_owner.GetTarget());
+lldb::addr_t BreakpointLocation::GetLoadAddress() const {
+ return m_address.GetOpcodeLoadAddress(&m_owner.GetTarget());
}
-Address &
-BreakpointLocation::GetAddress ()
-{
- return m_address;
-}
+Address &BreakpointLocation::GetAddress() { return m_address; }
-Breakpoint &
-BreakpointLocation::GetBreakpoint ()
-{
- return m_owner;
-}
+Breakpoint &BreakpointLocation::GetBreakpoint() { return m_owner; }
-Target &
-BreakpointLocation::GetTarget()
-{
- return m_owner.GetTarget();
-}
+Target &BreakpointLocation::GetTarget() { return m_owner.GetTarget(); }
-bool
-BreakpointLocation::IsEnabled () const
-{
- if (!m_owner.IsEnabled())
- return false;
- else if (m_options_ap.get() != nullptr)
- return m_options_ap->IsEnabled();
- else
- return true;
+bool BreakpointLocation::IsEnabled() const {
+ if (!m_owner.IsEnabled())
+ return false;
+ else if (m_options_ap.get() != nullptr)
+ return m_options_ap->IsEnabled();
+ else
+ return true;
}
-void
-BreakpointLocation::SetEnabled (bool enabled)
-{
- GetLocationOptions()->SetEnabled(enabled);
- if (enabled)
- {
- ResolveBreakpointSite();
- }
- else
- {
- ClearBreakpointSite();
- }
- SendBreakpointLocationChangedEvent (enabled ? eBreakpointEventTypeEnabled : eBreakpointEventTypeDisabled);
+void BreakpointLocation::SetEnabled(bool enabled) {
+ GetLocationOptions()->SetEnabled(enabled);
+ if (enabled) {
+ ResolveBreakpointSite();
+ } else {
+ ClearBreakpointSite();
+ }
+ SendBreakpointLocationChangedEvent(enabled ? eBreakpointEventTypeEnabled
+ : eBreakpointEventTypeDisabled);
}
-void
-BreakpointLocation::SetThreadID (lldb::tid_t thread_id)
-{
- if (thread_id != LLDB_INVALID_THREAD_ID)
- GetLocationOptions()->SetThreadID(thread_id);
- else
- {
- // If we're resetting this to an invalid thread id, then
- // don't make an options pointer just to do that.
- if (m_options_ap.get() != nullptr)
- m_options_ap->SetThreadID (thread_id);
- }
- SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged);
+void BreakpointLocation::SetThreadID(lldb::tid_t thread_id) {
+ if (thread_id != LLDB_INVALID_THREAD_ID)
+ GetLocationOptions()->SetThreadID(thread_id);
+ else {
+ // If we're resetting this to an invalid thread id, then
+ // don't make an options pointer just to do that.
+ if (m_options_ap.get() != nullptr)
+ m_options_ap->SetThreadID(thread_id);
+ }
+ SendBreakpointLocationChangedEvent(eBreakpointEventTypeThreadChanged);
}
-lldb::tid_t
-BreakpointLocation::GetThreadID ()
-{
- if (GetOptionsNoCreate()->GetThreadSpecNoCreate())
- return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetTID();
- else
- return LLDB_INVALID_THREAD_ID;
+lldb::tid_t BreakpointLocation::GetThreadID() {
+ if (GetOptionsNoCreate()->GetThreadSpecNoCreate())
+ return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetTID();
+ else
+ return LLDB_INVALID_THREAD_ID;
}
-void
-BreakpointLocation::SetThreadIndex (uint32_t index)
-{
- if (index != 0)
- GetLocationOptions()->GetThreadSpec()->SetIndex(index);
- else
- {
- // If we're resetting this to an invalid thread id, then
- // don't make an options pointer just to do that.
- if (m_options_ap.get() != nullptr)
- m_options_ap->GetThreadSpec()->SetIndex(index);
- }
- SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged);
+void BreakpointLocation::SetThreadIndex(uint32_t index) {
+ if (index != 0)
+ GetLocationOptions()->GetThreadSpec()->SetIndex(index);
+ else {
+ // If we're resetting this to an invalid thread id, then
+ // don't make an options pointer just to do that.
+ if (m_options_ap.get() != nullptr)
+ m_options_ap->GetThreadSpec()->SetIndex(index);
+ }
+ SendBreakpointLocationChangedEvent(eBreakpointEventTypeThreadChanged);
}
-uint32_t
-BreakpointLocation::GetThreadIndex() const
-{
- if (GetOptionsNoCreate()->GetThreadSpecNoCreate())
- return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetIndex();
- else
- return 0;
+uint32_t BreakpointLocation::GetThreadIndex() const {
+ if (GetOptionsNoCreate()->GetThreadSpecNoCreate())
+ return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetIndex();
+ else
+ return 0;
}
-void
-BreakpointLocation::SetThreadName (const char *thread_name)
-{
- if (thread_name != nullptr)
- GetLocationOptions()->GetThreadSpec()->SetName(thread_name);
- else
- {
- // If we're resetting this to an invalid thread id, then
- // don't make an options pointer just to do that.
- if (m_options_ap.get() != nullptr)
- m_options_ap->GetThreadSpec()->SetName(thread_name);
- }
- SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged);
+void BreakpointLocation::SetThreadName(const char *thread_name) {
+ if (thread_name != nullptr)
+ GetLocationOptions()->GetThreadSpec()->SetName(thread_name);
+ else {
+ // If we're resetting this to an invalid thread id, then
+ // don't make an options pointer just to do that.
+ if (m_options_ap.get() != nullptr)
+ m_options_ap->GetThreadSpec()->SetName(thread_name);
+ }
+ SendBreakpointLocationChangedEvent(eBreakpointEventTypeThreadChanged);
}
-const char *
-BreakpointLocation::GetThreadName () const
-{
- if (GetOptionsNoCreate()->GetThreadSpecNoCreate())
- return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetName();
- else
- return nullptr;
+const char *BreakpointLocation::GetThreadName() const {
+ if (GetOptionsNoCreate()->GetThreadSpecNoCreate())
+ return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetName();
+ else
+ return nullptr;
}
-void
-BreakpointLocation::SetQueueName (const char *queue_name)
-{
- if (queue_name != nullptr)
- GetLocationOptions()->GetThreadSpec()->SetQueueName(queue_name);
- else
- {
- // If we're resetting this to an invalid thread id, then
- // don't make an options pointer just to do that.
- if (m_options_ap.get() != nullptr)
- m_options_ap->GetThreadSpec()->SetQueueName(queue_name);
- }
- SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged);
+void BreakpointLocation::SetQueueName(const char *queue_name) {
+ if (queue_name != nullptr)
+ GetLocationOptions()->GetThreadSpec()->SetQueueName(queue_name);
+ else {
+ // If we're resetting this to an invalid thread id, then
+ // don't make an options pointer just to do that.
+ if (m_options_ap.get() != nullptr)
+ m_options_ap->GetThreadSpec()->SetQueueName(queue_name);
+ }
+ SendBreakpointLocationChangedEvent(eBreakpointEventTypeThreadChanged);
}
-const char *
-BreakpointLocation::GetQueueName () const
-{
- if (GetOptionsNoCreate()->GetThreadSpecNoCreate())
- return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetQueueName();
- else
- return nullptr;
+const char *BreakpointLocation::GetQueueName() const {
+ if (GetOptionsNoCreate()->GetThreadSpecNoCreate())
+ return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetQueueName();
+ else
+ return nullptr;
}
-bool
-BreakpointLocation::InvokeCallback (StoppointCallbackContext *context)
-{
- if (m_options_ap.get() != nullptr && m_options_ap->HasCallback())
- return m_options_ap->InvokeCallback (context, m_owner.GetID(), GetID());
- else
- return m_owner.InvokeCallback (context, GetID());
+bool BreakpointLocation::InvokeCallback(StoppointCallbackContext *context) {
+ if (m_options_ap.get() != nullptr && m_options_ap->HasCallback())
+ return m_options_ap->InvokeCallback(context, m_owner.GetID(), GetID());
+ else
+ return m_owner.InvokeCallback(context, GetID());
}
-void
-BreakpointLocation::SetCallback (BreakpointHitCallback callback, void *baton,
- bool is_synchronous)
-{
- // The default "Baton" class will keep a copy of "baton" and won't free
- // or delete it when it goes goes out of scope.
- GetLocationOptions()->SetCallback(callback, BatonSP (new Baton(baton)), is_synchronous);
- SendBreakpointLocationChangedEvent (eBreakpointEventTypeCommandChanged);
+void BreakpointLocation::SetCallback(BreakpointHitCallback callback,
+ void *baton, bool is_synchronous) {
+ // The default "Baton" class will keep a copy of "baton" and won't free
+ // or delete it when it goes goes out of scope.
+ GetLocationOptions()->SetCallback(callback, BatonSP(new Baton(baton)),
+ is_synchronous);
+ SendBreakpointLocationChangedEvent(eBreakpointEventTypeCommandChanged);
}
-void
-BreakpointLocation::SetCallback (BreakpointHitCallback callback, const BatonSP &baton_sp,
- bool is_synchronous)
-{
- GetLocationOptions()->SetCallback (callback, baton_sp, is_synchronous);
- SendBreakpointLocationChangedEvent (eBreakpointEventTypeCommandChanged);
+void BreakpointLocation::SetCallback(BreakpointHitCallback callback,
+ const BatonSP &baton_sp,
+ bool is_synchronous) {
+ GetLocationOptions()->SetCallback(callback, baton_sp, is_synchronous);
+ SendBreakpointLocationChangedEvent(eBreakpointEventTypeCommandChanged);
}
-void
-BreakpointLocation::ClearCallback ()
-{
- GetLocationOptions()->ClearCallback();
+void BreakpointLocation::ClearCallback() {
+ GetLocationOptions()->ClearCallback();
}
-void
-BreakpointLocation::SetCondition (const char *condition)
-{
- GetLocationOptions()->SetCondition (condition);
- SendBreakpointLocationChangedEvent (eBreakpointEventTypeConditionChanged);
+void BreakpointLocation::SetCondition(const char *condition) {
+ GetLocationOptions()->SetCondition(condition);
+ SendBreakpointLocationChangedEvent(eBreakpointEventTypeConditionChanged);
}
-const char *
-BreakpointLocation::GetConditionText (size_t *hash) const
-{
- return GetOptionsNoCreate()->GetConditionText(hash);
+const char *BreakpointLocation::GetConditionText(size_t *hash) const {
+ return GetOptionsNoCreate()->GetConditionText(hash);
}
-bool
-BreakpointLocation::ConditionSaysStop (ExecutionContext &exe_ctx, Error &error)
-{
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
+bool BreakpointLocation::ConditionSaysStop(ExecutionContext &exe_ctx,
+ Error &error) {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS);
+
+ std::lock_guard<std::mutex> guard(m_condition_mutex);
- std::lock_guard<std::mutex> guard(m_condition_mutex);
+ size_t condition_hash;
+ const char *condition_text = GetConditionText(&condition_hash);
- size_t condition_hash;
- const char *condition_text = GetConditionText(&condition_hash);
-
- if (!condition_text)
- {
- m_user_expression_sp.reset();
- return false;
+ if (!condition_text) {
+ m_user_expression_sp.reset();
+ return false;
+ }
+
+ error.Clear();
+
+ DiagnosticManager diagnostics;
+
+ if (condition_hash != m_condition_hash || !m_user_expression_sp ||
+ !m_user_expression_sp->MatchesContext(exe_ctx)) {
+ LanguageType language = eLanguageTypeUnknown;
+ // See if we can figure out the language from the frame, otherwise use the
+ // default language:
+ CompileUnit *comp_unit = m_address.CalculateSymbolContextCompileUnit();
+ if (comp_unit)
+ language = comp_unit->GetLanguage();
+
+ m_user_expression_sp.reset(GetTarget().GetUserExpressionForLanguage(
+ condition_text, nullptr, language, Expression::eResultTypeAny,
+ EvaluateExpressionOptions(), error));
+ if (error.Fail()) {
+ if (log)
+ log->Printf("Error getting condition expression: %s.",
+ error.AsCString());
+ m_user_expression_sp.reset();
+ return true;
}
- error.Clear();
-
- DiagnosticManager diagnostics;
-
- if (condition_hash != m_condition_hash || !m_user_expression_sp || !m_user_expression_sp->MatchesContext(exe_ctx))
- {
- LanguageType language = eLanguageTypeUnknown;
- // See if we can figure out the language from the frame, otherwise use the default language:
- CompileUnit *comp_unit = m_address.CalculateSymbolContextCompileUnit();
- if (comp_unit)
- language = comp_unit->GetLanguage();
-
- m_user_expression_sp.reset(GetTarget().GetUserExpressionForLanguage(condition_text,
- nullptr,
- language,
- Expression::eResultTypeAny,
- EvaluateExpressionOptions(),
- error));
- if (error.Fail())
- {
- if (log)
- log->Printf("Error getting condition expression: %s.", error.AsCString());
- m_user_expression_sp.reset();
- return true;
- }
+ if (!m_user_expression_sp->Parse(diagnostics, exe_ctx,
+ eExecutionPolicyOnlyWhenNeeded, true,
+ false)) {
+ error.SetErrorStringWithFormat(
+ "Couldn't parse conditional expression:\n%s",
+ diagnostics.GetString().c_str());
+ m_user_expression_sp.reset();
+ return true;
+ }
- if (!m_user_expression_sp->Parse(diagnostics, exe_ctx, eExecutionPolicyOnlyWhenNeeded, true, false))
- {
- error.SetErrorStringWithFormat("Couldn't parse conditional expression:\n%s",
- diagnostics.GetString().c_str());
- m_user_expression_sp.reset();
- return true;
- }
+ m_condition_hash = condition_hash;
+ }
+
+ // We need to make sure the user sees any parse errors in their condition, so
+ // we'll hook the
+ // constructor errors up to the debugger's Async I/O.
+
+ ValueObjectSP result_value_sp;
+
+ EvaluateExpressionOptions options;
+ options.SetUnwindOnError(true);
+ options.SetIgnoreBreakpoints(true);
+ options.SetTryAllThreads(true);
+ options.SetResultIsInternal(
+ true); // Don't generate a user variable for condition expressions.
+
+ Error expr_error;
+
+ diagnostics.Clear();
- m_condition_hash = condition_hash;
+ ExpressionVariableSP result_variable_sp;
+
+ ExpressionResults result_code = m_user_expression_sp->Execute(
+ diagnostics, exe_ctx, options, m_user_expression_sp, result_variable_sp);
+
+ bool ret;
+
+ if (result_code == eExpressionCompleted) {
+ if (!result_variable_sp) {
+ error.SetErrorString("Expression did not return a result");
+ return false;
}
- // We need to make sure the user sees any parse errors in their condition, so we'll hook the
- // constructor errors up to the debugger's Async I/O.
-
- ValueObjectSP result_value_sp;
-
- EvaluateExpressionOptions options;
- options.SetUnwindOnError(true);
- options.SetIgnoreBreakpoints(true);
- options.SetTryAllThreads(true);
- options.SetResultIsInternal(true); // Don't generate a user variable for condition expressions.
-
- Error expr_error;
-
- diagnostics.Clear();
-
- ExpressionVariableSP result_variable_sp;
-
- ExpressionResults result_code =
- m_user_expression_sp->Execute(diagnostics, exe_ctx, options, m_user_expression_sp, result_variable_sp);
-
- bool ret;
-
- if (result_code == eExpressionCompleted)
- {
- if (!result_variable_sp)
- {
- error.SetErrorString("Expression did not return a result");
- return false;
- }
-
- result_value_sp = result_variable_sp->GetValueObject();
-
- if (result_value_sp)
- {
- ret = result_value_sp->IsLogicalTrue(error);
- if (log)
- {
- if (error.Success())
- {
- log->Printf("Condition successfully evaluated, result is %s.\n",
- ret ? "true" : "false");
- }
- else
- {
- error.SetErrorString("Failed to get an integer result from the expression");
- ret = false;
- }
-
- }
+ result_value_sp = result_variable_sp->GetValueObject();
+
+ if (result_value_sp) {
+ ret = result_value_sp->IsLogicalTrue(error);
+ if (log) {
+ if (error.Success()) {
+ log->Printf("Condition successfully evaluated, result is %s.\n",
+ ret ? "true" : "false");
+ } else {
+ error.SetErrorString(
+ "Failed to get an integer result from the expression");
+ ret = false;
}
- else
- {
- ret = false;
- error.SetErrorString("Failed to get any result from the expression");
- }
- }
- else
- {
- ret = false;
- error.SetErrorStringWithFormat("Couldn't execute expression:\n%s", diagnostics.GetString().c_str());
+ }
+ } else {
+ ret = false;
+ error.SetErrorString("Failed to get any result from the expression");
}
+ } else {
+ ret = false;
+ error.SetErrorStringWithFormat("Couldn't execute expression:\n%s",
+ diagnostics.GetString().c_str());
+ }
- return ret;
+ return ret;
}
-uint32_t
-BreakpointLocation::GetIgnoreCount ()
-{
- return GetOptionsNoCreate()->GetIgnoreCount();
+uint32_t BreakpointLocation::GetIgnoreCount() {
+ return GetOptionsNoCreate()->GetIgnoreCount();
}
-void
-BreakpointLocation::SetIgnoreCount (uint32_t n)
-{
- GetLocationOptions()->SetIgnoreCount(n);
- SendBreakpointLocationChangedEvent (eBreakpointEventTypeIgnoreChanged);
+void BreakpointLocation::SetIgnoreCount(uint32_t n) {
+ GetLocationOptions()->SetIgnoreCount(n);
+ SendBreakpointLocationChangedEvent(eBreakpointEventTypeIgnoreChanged);
}
-void
-BreakpointLocation::DecrementIgnoreCount()
-{
- if (m_options_ap.get() != nullptr)
- {
- uint32_t loc_ignore = m_options_ap->GetIgnoreCount();
- if (loc_ignore != 0)
- m_options_ap->SetIgnoreCount(loc_ignore - 1);
- }
+void BreakpointLocation::DecrementIgnoreCount() {
+ if (m_options_ap.get() != nullptr) {
+ uint32_t loc_ignore = m_options_ap->GetIgnoreCount();
+ if (loc_ignore != 0)
+ m_options_ap->SetIgnoreCount(loc_ignore - 1);
+ }
}
-bool
-BreakpointLocation::IgnoreCountShouldStop()
-{
- if (m_options_ap.get() != nullptr)
- {
- uint32_t loc_ignore = m_options_ap->GetIgnoreCount();
- if (loc_ignore != 0)
- {
- m_owner.DecrementIgnoreCount();
- DecrementIgnoreCount(); // Have to decrement our owners' ignore count, since it won't get a
- // chance to.
- return false;
- }
+bool BreakpointLocation::IgnoreCountShouldStop() {
+ if (m_options_ap.get() != nullptr) {
+ uint32_t loc_ignore = m_options_ap->GetIgnoreCount();
+ if (loc_ignore != 0) {
+ m_owner.DecrementIgnoreCount();
+ DecrementIgnoreCount(); // Have to decrement our owners' ignore count,
+ // since it won't get a
+ // chance to.
+ return false;
}
- return true;
+ }
+ return true;
}
-const BreakpointOptions *
-BreakpointLocation::GetOptionsNoCreate () const
-{
- if (m_options_ap.get() != nullptr)
- return m_options_ap.get();
- else
- return m_owner.GetOptions ();
-}
-
-BreakpointOptions *
-BreakpointLocation::GetLocationOptions ()
-{
- // If we make the copy we don't copy the callbacks because that is potentially
- // expensive and we don't want to do that for the simple case where someone is
- // just disabling the location.
- if (m_options_ap.get() == nullptr)
- m_options_ap.reset(BreakpointOptions::CopyOptionsNoCallback(*m_owner.GetOptions ()));
-
+const BreakpointOptions *BreakpointLocation::GetOptionsNoCreate() const {
+ if (m_options_ap.get() != nullptr)
return m_options_ap.get();
+ else
+ return m_owner.GetOptions();
+}
+
+BreakpointOptions *BreakpointLocation::GetLocationOptions() {
+ // If we make the copy we don't copy the callbacks because that is potentially
+ // expensive and we don't want to do that for the simple case where someone is
+ // just disabling the location.
+ if (m_options_ap.get() == nullptr)
+ m_options_ap.reset(
+ BreakpointOptions::CopyOptionsNoCallback(*m_owner.GetOptions()));
+
+ return m_options_ap.get();
}
-bool
-BreakpointLocation::ValidForThisThread (Thread *thread)
-{
- return thread->MatchesSpec(GetOptionsNoCreate()->GetThreadSpecNoCreate());
+bool BreakpointLocation::ValidForThisThread(Thread *thread) {
+ return thread->MatchesSpec(GetOptionsNoCreate()->GetThreadSpecNoCreate());
}
// RETURNS - true if we should stop at this breakpoint, false if we
@@ -447,309 +362,275 @@ BreakpointLocation::ValidForThisThread (Thread *thread)
// here, since if the breakpoint is not for this thread, then the event won't
// even get reported, so the check is redundant.
-bool
-BreakpointLocation::ShouldStop (StoppointCallbackContext *context)
-{
- bool should_stop = true;
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
-
- // Do this first, if a location is disabled, it shouldn't increment its hit count.
- if (!IsEnabled())
- return false;
-
- if (!IgnoreCountShouldStop())
- return false;
-
- if (!m_owner.IgnoreCountShouldStop())
- return false;
-
- // We only run synchronous callbacks in ShouldStop:
- context->is_synchronous = true;
- should_stop = InvokeCallback (context);
-
- if (log)
- {
- StreamString s;
- GetDescription (&s, lldb::eDescriptionLevelVerbose);
- log->Printf ("Hit breakpoint location: %s, %s.\n", s.GetData(), should_stop ? "stopping" : "continuing");
- }
-
- return should_stop;
-}
-
-void
-BreakpointLocation::BumpHitCount()
-{
- if (IsEnabled())
- {
- // Step our hit count, and also step the hit count of the owner.
- IncrementHitCount();
- m_owner.IncrementHitCount();
- }
+bool BreakpointLocation::ShouldStop(StoppointCallbackContext *context) {
+ bool should_stop = true;
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS);
+
+ // Do this first, if a location is disabled, it shouldn't increment its hit
+ // count.
+ if (!IsEnabled())
+ return false;
+
+ if (!IgnoreCountShouldStop())
+ return false;
+
+ if (!m_owner.IgnoreCountShouldStop())
+ return false;
+
+ // We only run synchronous callbacks in ShouldStop:
+ context->is_synchronous = true;
+ should_stop = InvokeCallback(context);
+
+ if (log) {
+ StreamString s;
+ GetDescription(&s, lldb::eDescriptionLevelVerbose);
+ log->Printf("Hit breakpoint location: %s, %s.\n", s.GetData(),
+ should_stop ? "stopping" : "continuing");
+ }
+
+ return should_stop;
}
-void
-BreakpointLocation::UndoBumpHitCount()
-{
- if (IsEnabled())
- {
- // Step our hit count, and also step the hit count of the owner.
- DecrementHitCount();
- m_owner.DecrementHitCount();
- }
+void BreakpointLocation::BumpHitCount() {
+ if (IsEnabled()) {
+ // Step our hit count, and also step the hit count of the owner.
+ IncrementHitCount();
+ m_owner.IncrementHitCount();
+ }
}
-bool
-BreakpointLocation::IsResolved () const
-{
- return m_bp_site_sp.get() != nullptr;
+void BreakpointLocation::UndoBumpHitCount() {
+ if (IsEnabled()) {
+ // Step our hit count, and also step the hit count of the owner.
+ DecrementHitCount();
+ m_owner.DecrementHitCount();
+ }
}
-lldb::BreakpointSiteSP
-BreakpointLocation::GetBreakpointSite() const
-{
- return m_bp_site_sp;
+bool BreakpointLocation::IsResolved() const {
+ return m_bp_site_sp.get() != nullptr;
}
-bool
-BreakpointLocation::ResolveBreakpointSite ()
-{
- if (m_bp_site_sp)
- return true;
+lldb::BreakpointSiteSP BreakpointLocation::GetBreakpointSite() const {
+ return m_bp_site_sp;
+}
- Process *process = m_owner.GetTarget().GetProcessSP().get();
- if (process == nullptr)
- return false;
+bool BreakpointLocation::ResolveBreakpointSite() {
+ if (m_bp_site_sp)
+ return true;
- lldb::break_id_t new_id = process->CreateBreakpointSite (shared_from_this(), m_owner.IsHardware());
+ Process *process = m_owner.GetTarget().GetProcessSP().get();
+ if (process == nullptr)
+ return false;
- if (new_id == LLDB_INVALID_BREAK_ID)
- {
- Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
- if (log)
- log->Warning ("Tried to add breakpoint site at 0x%" PRIx64 " but it was already present.\n",
- m_address.GetOpcodeLoadAddress (&m_owner.GetTarget()));
- return false;
- }
+ lldb::break_id_t new_id =
+ process->CreateBreakpointSite(shared_from_this(), m_owner.IsHardware());
- return true;
-}
+ if (new_id == LLDB_INVALID_BREAK_ID) {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS);
+ if (log)
+ log->Warning("Tried to add breakpoint site at 0x%" PRIx64
+ " but it was already present.\n",
+ m_address.GetOpcodeLoadAddress(&m_owner.GetTarget()));
+ return false;
+ }
-bool
-BreakpointLocation::SetBreakpointSite (BreakpointSiteSP& bp_site_sp)
-{
- m_bp_site_sp = bp_site_sp;
- SendBreakpointLocationChangedEvent (eBreakpointEventTypeLocationsResolved);
- return true;
+ return true;
}
-bool
-BreakpointLocation::ClearBreakpointSite ()
-{
- if (m_bp_site_sp.get())
- {
- ProcessSP process_sp(m_owner.GetTarget().GetProcessSP());
- // If the process exists, get it to remove the owner, it will remove the physical implementation
- // of the breakpoint as well if there are no more owners. Otherwise just remove this owner.
- if (process_sp)
- process_sp->RemoveOwnerFromBreakpointSite (GetBreakpoint().GetID(),
- GetID(), m_bp_site_sp);
- else
- m_bp_site_sp->RemoveOwner(GetBreakpoint().GetID(), GetID());
-
- m_bp_site_sp.reset();
- return true;
- }
- return false;
+bool BreakpointLocation::SetBreakpointSite(BreakpointSiteSP &bp_site_sp) {
+ m_bp_site_sp = bp_site_sp;
+ SendBreakpointLocationChangedEvent(eBreakpointEventTypeLocationsResolved);
+ return true;
}
-void
-BreakpointLocation::GetDescription (Stream *s, lldb::DescriptionLevel level)
-{
- SymbolContext sc;
-
- // If the description level is "initial" then the breakpoint is printing out our initial state,
- // and we should let it decide how it wants to print our label.
- if (level != eDescriptionLevelInitial)
- {
- s->Indent();
- BreakpointID::GetCanonicalReference(s, m_owner.GetID(), GetID());
- }
-
- if (level == lldb::eDescriptionLevelBrief)
- return;
-
- if (level != eDescriptionLevelInitial)
- s->PutCString(": ");
-
- if (level == lldb::eDescriptionLevelVerbose)
- s->IndentMore();
-
- if (m_address.IsSectionOffset())
- {
- m_address.CalculateSymbolContext(&sc);
-
- if (level == lldb::eDescriptionLevelFull || level == eDescriptionLevelInitial)
- {
- if (IsReExported())
- s->PutCString ("re-exported target = ");
- else
- s->PutCString("where = ");
- sc.DumpStopContext (s, m_owner.GetTarget().GetProcessSP().get(), m_address, false, true, false, true, true);
- }
- else
- {
- if (sc.module_sp)
- {
- s->EOL();
- s->Indent("module = ");
- sc.module_sp->GetFileSpec().Dump (s);
- }
-
- if (sc.comp_unit != nullptr)
- {
- s->EOL();
- s->Indent("compile unit = ");
- static_cast<FileSpec*>(sc.comp_unit)->GetFilename().Dump (s);
-
- if (sc.function != nullptr)
- {
- s->EOL();
- s->Indent("function = ");
- s->PutCString (sc.function->GetName().AsCString("<unknown>"));
- }
-
- if (sc.line_entry.line > 0)
- {
- s->EOL();
- s->Indent("location = ");
- sc.line_entry.DumpStopContext (s, true);
- }
-
- }
- else
- {
- // If we don't have a comp unit, see if we have a symbol we can print.
- if (sc.symbol)
- {
- s->EOL();
- if (IsReExported())
- s->Indent ("re-exported target = ");
- else
- s->Indent("symbol = ");
- s->PutCString(sc.symbol->GetName().AsCString("<unknown>"));
- }
- }
- }
- }
+bool BreakpointLocation::ClearBreakpointSite() {
+ if (m_bp_site_sp.get()) {
+ ProcessSP process_sp(m_owner.GetTarget().GetProcessSP());
+ // If the process exists, get it to remove the owner, it will remove the
+ // physical implementation
+ // of the breakpoint as well if there are no more owners. Otherwise just
+ // remove this owner.
+ if (process_sp)
+ process_sp->RemoveOwnerFromBreakpointSite(GetBreakpoint().GetID(),
+ GetID(), m_bp_site_sp);
+ else
+ m_bp_site_sp->RemoveOwner(GetBreakpoint().GetID(), GetID());
- if (level == lldb::eDescriptionLevelVerbose)
- {
+ m_bp_site_sp.reset();
+ return true;
+ }
+ return false;
+}
+
+void BreakpointLocation::GetDescription(Stream *s,
+ lldb::DescriptionLevel level) {
+ SymbolContext sc;
+
+ // If the description level is "initial" then the breakpoint is printing out
+ // our initial state,
+ // and we should let it decide how it wants to print our label.
+ if (level != eDescriptionLevelInitial) {
+ s->Indent();
+ BreakpointID::GetCanonicalReference(s, m_owner.GetID(), GetID());
+ }
+
+ if (level == lldb::eDescriptionLevelBrief)
+ return;
+
+ if (level != eDescriptionLevelInitial)
+ s->PutCString(": ");
+
+ if (level == lldb::eDescriptionLevelVerbose)
+ s->IndentMore();
+
+ if (m_address.IsSectionOffset()) {
+ m_address.CalculateSymbolContext(&sc);
+
+ if (level == lldb::eDescriptionLevelFull ||
+ level == eDescriptionLevelInitial) {
+ if (IsReExported())
+ s->PutCString("re-exported target = ");
+ else
+ s->PutCString("where = ");
+ sc.DumpStopContext(s, m_owner.GetTarget().GetProcessSP().get(), m_address,
+ false, true, false, true, true);
+ } else {
+ if (sc.module_sp) {
s->EOL();
- s->Indent();
- }
-
- if (m_address.IsSectionOffset() && (level == eDescriptionLevelFull || level == eDescriptionLevelInitial))
- s->Printf (", ");
- s->Printf ("address = ");
-
- ExecutionContextScope *exe_scope = nullptr;
- Target *target = &m_owner.GetTarget();
- if (target)
- exe_scope = target->GetProcessSP().get();
- if (exe_scope == nullptr)
- exe_scope = target;
-
- if (level == eDescriptionLevelInitial)
- m_address.Dump(s, exe_scope, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress);
- else
- m_address.Dump(s, exe_scope, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress);
-
- if (IsIndirect() && m_bp_site_sp)
- {
- Address resolved_address;
- resolved_address.SetLoadAddress(m_bp_site_sp->GetLoadAddress(), target);
- Symbol *resolved_symbol = resolved_address.CalculateSymbolContextSymbol();
- if (resolved_symbol)
- {
- if (level == eDescriptionLevelFull || level == eDescriptionLevelInitial)
- s->Printf (", ");
- else if (level == lldb::eDescriptionLevelVerbose)
- {
- s->EOL();
- s->Indent();
- }
- s->Printf ("indirect target = %s", resolved_symbol->GetName().GetCString());
- }
- }
+ s->Indent("module = ");
+ sc.module_sp->GetFileSpec().Dump(s);
+ }
- if (level == lldb::eDescriptionLevelVerbose)
- {
+ if (sc.comp_unit != nullptr) {
s->EOL();
- s->Indent();
- s->Printf("resolved = %s\n", IsResolved() ? "true" : "false");
+ s->Indent("compile unit = ");
+ static_cast<FileSpec *>(sc.comp_unit)->GetFilename().Dump(s);
- s->Indent();
- s->Printf ("hit count = %-4u\n", GetHitCount());
+ if (sc.function != nullptr) {
+ s->EOL();
+ s->Indent("function = ");
+ s->PutCString(sc.function->GetName().AsCString("<unknown>"));
+ }
- if (m_options_ap.get())
- {
- s->Indent();
- m_options_ap->GetDescription (s, level);
- s->EOL();
+ if (sc.line_entry.line > 0) {
+ s->EOL();
+ s->Indent("location = ");
+ sc.line_entry.DumpStopContext(s, true);
}
- s->IndentLess();
- }
- else if (level != eDescriptionLevelInitial)
- {
- s->Printf(", %sresolved, hit count = %u ",
- (IsResolved() ? "" : "un"),
- GetHitCount());
- if (m_options_ap.get())
- {
- m_options_ap->GetDescription (s, level);
+
+ } else {
+ // If we don't have a comp unit, see if we have a symbol we can print.
+ if (sc.symbol) {
+ s->EOL();
+ if (IsReExported())
+ s->Indent("re-exported target = ");
+ else
+ s->Indent("symbol = ");
+ s->PutCString(sc.symbol->GetName().AsCString("<unknown>"));
}
+ }
}
-}
-
-void
-BreakpointLocation::Dump(Stream *s) const
-{
- if (s == nullptr)
- return;
-
- s->Printf("BreakpointLocation %u: tid = %4.4" PRIx64 " load addr = 0x%8.8" PRIx64 " state = %s type = %s breakpoint "
- "hw_index = %i hit_count = %-4u ignore_count = %-4u",
- GetID(),
- GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetTID(),
- (uint64_t) m_address.GetOpcodeLoadAddress (&m_owner.GetTarget()),
- (m_options_ap.get() ? m_options_ap->IsEnabled() : m_owner.IsEnabled()) ? "enabled " : "disabled",
- IsHardware() ? "hardware" : "software",
- GetHardwareIndex(),
- GetHitCount(),
- GetOptionsNoCreate()->GetIgnoreCount());
-}
-
-void
-BreakpointLocation::SendBreakpointLocationChangedEvent (lldb::BreakpointEventType eventKind)
-{
- if (!m_being_created
- && !m_owner.IsInternal()
- && m_owner.GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged))
- {
- Breakpoint::BreakpointEventData *data = new Breakpoint::BreakpointEventData (eventKind,
- m_owner.shared_from_this());
- data->GetBreakpointLocationCollection().Add (shared_from_this());
- m_owner.GetTarget().BroadcastEvent (Target::eBroadcastBitBreakpointChanged, data);
+ }
+
+ if (level == lldb::eDescriptionLevelVerbose) {
+ s->EOL();
+ s->Indent();
+ }
+
+ if (m_address.IsSectionOffset() &&
+ (level == eDescriptionLevelFull || level == eDescriptionLevelInitial))
+ s->Printf(", ");
+ s->Printf("address = ");
+
+ ExecutionContextScope *exe_scope = nullptr;
+ Target *target = &m_owner.GetTarget();
+ if (target)
+ exe_scope = target->GetProcessSP().get();
+ if (exe_scope == nullptr)
+ exe_scope = target;
+
+ if (level == eDescriptionLevelInitial)
+ m_address.Dump(s, exe_scope, Address::DumpStyleLoadAddress,
+ Address::DumpStyleFileAddress);
+ else
+ m_address.Dump(s, exe_scope, Address::DumpStyleLoadAddress,
+ Address::DumpStyleModuleWithFileAddress);
+
+ if (IsIndirect() && m_bp_site_sp) {
+ Address resolved_address;
+ resolved_address.SetLoadAddress(m_bp_site_sp->GetLoadAddress(), target);
+ Symbol *resolved_symbol = resolved_address.CalculateSymbolContextSymbol();
+ if (resolved_symbol) {
+ if (level == eDescriptionLevelFull || level == eDescriptionLevelInitial)
+ s->Printf(", ");
+ else if (level == lldb::eDescriptionLevelVerbose) {
+ s->EOL();
+ s->Indent();
+ }
+ s->Printf("indirect target = %s",
+ resolved_symbol->GetName().GetCString());
}
-}
+ }
-void
-BreakpointLocation::SwapLocation (BreakpointLocationSP swap_from)
-{
- m_address = swap_from->m_address;
- m_should_resolve_indirect_functions = swap_from->m_should_resolve_indirect_functions;
- m_is_reexported = swap_from->m_is_reexported;
- m_is_indirect = swap_from->m_is_indirect;
- m_user_expression_sp.reset();
+ if (level == lldb::eDescriptionLevelVerbose) {
+ s->EOL();
+ s->Indent();
+ s->Printf("resolved = %s\n", IsResolved() ? "true" : "false");
+
+ s->Indent();
+ s->Printf("hit count = %-4u\n", GetHitCount());
+
+ if (m_options_ap.get()) {
+ s->Indent();
+ m_options_ap->GetDescription(s, level);
+ s->EOL();
+ }
+ s->IndentLess();
+ } else if (level != eDescriptionLevelInitial) {
+ s->Printf(", %sresolved, hit count = %u ", (IsResolved() ? "" : "un"),
+ GetHitCount());
+ if (m_options_ap.get()) {
+ m_options_ap->GetDescription(s, level);
+ }
+ }
+}
+
+void BreakpointLocation::Dump(Stream *s) const {
+ if (s == nullptr)
+ return;
+
+ s->Printf(
+ "BreakpointLocation %u: tid = %4.4" PRIx64 " load addr = 0x%8.8" PRIx64
+ " state = %s type = %s breakpoint "
+ "hw_index = %i hit_count = %-4u ignore_count = %-4u",
+ GetID(), GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetTID(),
+ (uint64_t)m_address.GetOpcodeLoadAddress(&m_owner.GetTarget()),
+ (m_options_ap.get() ? m_options_ap->IsEnabled() : m_owner.IsEnabled())
+ ? "enabled "
+ : "disabled",
+ IsHardware() ? "hardware" : "software", GetHardwareIndex(), GetHitCount(),
+ GetOptionsNoCreate()->GetIgnoreCount());
+}
+
+void BreakpointLocation::SendBreakpointLocationChangedEvent(
+ lldb::BreakpointEventType eventKind) {
+ if (!m_being_created && !m_owner.IsInternal() &&
+ m_owner.GetTarget().EventTypeHasListeners(
+ Target::eBroadcastBitBreakpointChanged)) {
+ Breakpoint::BreakpointEventData *data = new Breakpoint::BreakpointEventData(
+ eventKind, m_owner.shared_from_this());
+ data->GetBreakpointLocationCollection().Add(shared_from_this());
+ m_owner.GetTarget().BroadcastEvent(Target::eBroadcastBitBreakpointChanged,
+ data);
+ }
+}
+
+void BreakpointLocation::SwapLocation(BreakpointLocationSP swap_from) {
+ m_address = swap_from->m_address;
+ m_should_resolve_indirect_functions =
+ swap_from->m_should_resolve_indirect_functions;
+ m_is_reexported = swap_from->m_is_reexported;
+ m_is_indirect = swap_from->m_is_indirect;
+ m_user_expression_sp.reset();
}
diff --git a/lldb/source/Breakpoint/BreakpointLocationCollection.cpp b/lldb/source/Breakpoint/BreakpointLocationCollection.cpp
index 52698b2f..6536002 100644
--- a/lldb/source/Breakpoint/BreakpointLocationCollection.cpp
+++ b/lldb/source/Breakpoint/BreakpointLocationCollection.cpp
@@ -7,15 +7,14 @@
//
//===----------------------------------------------------------------------===//
-
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Breakpoint/BreakpointLocationCollection.h"
-#include "lldb/Core/ModuleList.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
+#include "lldb/Core/ModuleList.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadSpec.h"
@@ -25,189 +24,162 @@ using namespace lldb_private;
//----------------------------------------------------------------------
// BreakpointLocationCollection constructor
//----------------------------------------------------------------------
-BreakpointLocationCollection::BreakpointLocationCollection() :
- m_break_loc_collection(),
- m_collection_mutex()
-{
-}
+BreakpointLocationCollection::BreakpointLocationCollection()
+ : m_break_loc_collection(), m_collection_mutex() {}
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
-BreakpointLocationCollection::~BreakpointLocationCollection()
-{
+BreakpointLocationCollection::~BreakpointLocationCollection() {}
+
+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())
+ m_break_loc_collection.push_back(bp_loc);
}
-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())
- m_break_loc_collection.push_back(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);
+ collection::iterator pos = GetIDPairIterator(bp_id, bp_loc_id); // Predicate
+ if (pos != m_break_loc_collection.end()) {
+ m_break_loc_collection.erase(pos);
+ return true;
+ }
+ return false;
}
-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);
- collection::iterator pos = GetIDPairIterator(bp_id, bp_loc_id); // Predicate
- if (pos != m_break_loc_collection.end())
- {
- m_break_loc_collection.erase(pos);
- return true;
- }
- return false;
-
-}
-
-class BreakpointIDPairMatches
-{
+class BreakpointIDPairMatches {
public:
- BreakpointIDPairMatches (lldb::break_id_t break_id, lldb::break_id_t break_loc_id) :
- m_break_id(break_id),
- m_break_loc_id (break_loc_id)
- {
- }
+ BreakpointIDPairMatches(lldb::break_id_t break_id,
+ lldb::break_id_t break_loc_id)
+ : m_break_id(break_id), m_break_loc_id(break_loc_id) {}
- bool operator() (const BreakpointLocationSP &bp_loc) const
- {
- return m_break_id == bp_loc->GetBreakpoint().GetID()
- && m_break_loc_id == bp_loc->GetID();
- }
+ bool operator()(const BreakpointLocationSP &bp_loc) const {
+ return m_break_id == bp_loc->GetBreakpoint().GetID() &&
+ m_break_loc_id == bp_loc->GetID();
+ }
private:
- const lldb::break_id_t m_break_id;
- const lldb::break_id_t m_break_loc_id;
+ const lldb::break_id_t m_break_id;
+ const lldb::break_id_t m_break_loc_id;
};
BreakpointLocationCollection::collection::iterator
-BreakpointLocationCollection::GetIDPairIterator (lldb::break_id_t break_id, lldb::break_id_t break_loc_id)
-{
- return std::find_if(m_break_loc_collection.begin(), m_break_loc_collection.end(), // Search full range
- BreakpointIDPairMatches(break_id, break_loc_id)); // Predicate
+BreakpointLocationCollection::GetIDPairIterator(lldb::break_id_t break_id,
+ lldb::break_id_t break_loc_id) {
+ return std::find_if(
+ m_break_loc_collection.begin(),
+ m_break_loc_collection.end(), // Search full range
+ BreakpointIDPairMatches(break_id, break_loc_id)); // Predicate
}
BreakpointLocationCollection::collection::const_iterator
-BreakpointLocationCollection::GetIDPairConstIterator (lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const
-{
- return std::find_if(m_break_loc_collection.begin(), m_break_loc_collection.end(), // Search full range
- BreakpointIDPairMatches(break_id, break_loc_id)); // Predicate
+BreakpointLocationCollection::GetIDPairConstIterator(
+ lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const {
+ return std::find_if(
+ m_break_loc_collection.begin(),
+ m_break_loc_collection.end(), // Search full range
+ BreakpointIDPairMatches(break_id, break_loc_id)); // Predicate
}
BreakpointLocationSP
-BreakpointLocationCollection::FindByIDPair (lldb::break_id_t break_id, lldb::break_id_t break_loc_id)
-{
- BreakpointLocationSP stop_sp;
- collection::iterator pos = GetIDPairIterator(break_id, break_loc_id);
- if (pos != m_break_loc_collection.end())
- stop_sp = *pos;
-
- return stop_sp;
+BreakpointLocationCollection::FindByIDPair(lldb::break_id_t break_id,
+ lldb::break_id_t break_loc_id) {
+ BreakpointLocationSP stop_sp;
+ collection::iterator pos = GetIDPairIterator(break_id, break_loc_id);
+ if (pos != m_break_loc_collection.end())
+ stop_sp = *pos;
+
+ return stop_sp;
}
-const BreakpointLocationSP
-BreakpointLocationCollection::FindByIDPair (lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const
-{
- BreakpointLocationSP stop_sp;
- collection::const_iterator pos = GetIDPairConstIterator(break_id, break_loc_id);
- if (pos != m_break_loc_collection.end())
- stop_sp = *pos;
-
- return stop_sp;
+const BreakpointLocationSP BreakpointLocationCollection::FindByIDPair(
+ lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const {
+ BreakpointLocationSP stop_sp;
+ collection::const_iterator pos =
+ GetIDPairConstIterator(break_id, break_loc_id);
+ if (pos != m_break_loc_collection.end())
+ stop_sp = *pos;
+
+ return stop_sp;
}
-BreakpointLocationSP
-BreakpointLocationCollection::GetByIndex (size_t i)
-{
- std::lock_guard<std::mutex> guard(m_collection_mutex);
- BreakpointLocationSP stop_sp;
- if (i < m_break_loc_collection.size())
- stop_sp = m_break_loc_collection[i];
-
- return stop_sp;
+BreakpointLocationSP BreakpointLocationCollection::GetByIndex(size_t i) {
+ std::lock_guard<std::mutex> guard(m_collection_mutex);
+ BreakpointLocationSP stop_sp;
+ if (i < m_break_loc_collection.size())
+ stop_sp = m_break_loc_collection[i];
+
+ return stop_sp;
}
const BreakpointLocationSP
-BreakpointLocationCollection::GetByIndex (size_t i) const
-{
- std::lock_guard<std::mutex> guard(m_collection_mutex);
- BreakpointLocationSP stop_sp;
- if (i < m_break_loc_collection.size())
- stop_sp = m_break_loc_collection[i];
-
- return stop_sp;
-}
+BreakpointLocationCollection::GetByIndex(size_t i) const {
+ std::lock_guard<std::mutex> guard(m_collection_mutex);
+ BreakpointLocationSP stop_sp;
+ if (i < m_break_loc_collection.size())
+ stop_sp = m_break_loc_collection[i];
-bool
-BreakpointLocationCollection::ShouldStop (StoppointCallbackContext *context)
-{
- bool shouldStop = false;
- size_t i = 0;
- size_t prev_size = GetSize();
- while (i < prev_size)
- {
- // ShouldStop can remove the breakpoint from the list
- if (GetByIndex(i)->ShouldStop(context))
- shouldStop = true;
-
- if (prev_size == GetSize())
- i++;
- prev_size = GetSize();
- }
- return shouldStop;
+ return stop_sp;
}
-bool
-BreakpointLocationCollection::ValidForThisThread (Thread *thread)
-{
- std::lock_guard<std::mutex> guard(m_collection_mutex);
- collection::iterator pos,
- begin = m_break_loc_collection.begin(),
- end = m_break_loc_collection.end();
-
- for (pos = begin; pos != end; ++pos)
- {
- if ((*pos)->ValidForThisThread (thread))
- return true;
- }
- return false;
+bool BreakpointLocationCollection::ShouldStop(
+ StoppointCallbackContext *context) {
+ bool shouldStop = false;
+ size_t i = 0;
+ size_t prev_size = GetSize();
+ while (i < prev_size) {
+ // ShouldStop can remove the breakpoint from the list
+ if (GetByIndex(i)->ShouldStop(context))
+ shouldStop = true;
+
+ if (prev_size == GetSize())
+ i++;
+ prev_size = GetSize();
+ }
+ return shouldStop;
}
-bool
-BreakpointLocationCollection::IsInternal () const
-{
- std::lock_guard<std::mutex> guard(m_collection_mutex);
- collection::const_iterator pos,
- begin = m_break_loc_collection.begin(),
- end = m_break_loc_collection.end();
-
- bool is_internal = true;
-
- for (pos = begin; pos != end; ++pos)
- {
- if (!(*pos)->GetBreakpoint().IsInternal ())
- {
- is_internal = false;
- break;
- }
- }
- return is_internal;
+bool BreakpointLocationCollection::ValidForThisThread(Thread *thread) {
+ std::lock_guard<std::mutex> guard(m_collection_mutex);
+ collection::iterator pos, begin = m_break_loc_collection.begin(),
+ end = m_break_loc_collection.end();
+
+ for (pos = begin; pos != end; ++pos) {
+ if ((*pos)->ValidForThisThread(thread))
+ return true;
+ }
+ return false;
}
-void
-BreakpointLocationCollection::GetDescription (Stream *s, lldb::DescriptionLevel level)
-{
- std::lock_guard<std::mutex> guard(m_collection_mutex);
- collection::iterator pos,
- begin = m_break_loc_collection.begin(),
- end = m_break_loc_collection.end();
-
- for (pos = begin; pos != end; ++pos)
- {
- if (pos != begin)
- s->PutChar(' ');
- (*pos)->GetDescription(s, level);
+bool BreakpointLocationCollection::IsInternal() const {
+ std::lock_guard<std::mutex> guard(m_collection_mutex);
+ collection::const_iterator pos, begin = m_break_loc_collection.begin(),
+ end = m_break_loc_collection.end();
+
+ bool is_internal = true;
+
+ for (pos = begin; pos != end; ++pos) {
+ if (!(*pos)->GetBreakpoint().IsInternal()) {
+ is_internal = false;
+ break;
}
+ }
+ return is_internal;
}
+void BreakpointLocationCollection::GetDescription(
+ Stream *s, lldb::DescriptionLevel level) {
+ std::lock_guard<std::mutex> guard(m_collection_mutex);
+ collection::iterator pos, begin = m_break_loc_collection.begin(),
+ end = m_break_loc_collection.end();
+
+ for (pos = begin; pos != end; ++pos) {
+ if (pos != begin)
+ s->PutChar(' ');
+ (*pos)->GetDescription(s, level);
+ }
+}
diff --git a/lldb/source/Breakpoint/BreakpointLocationList.cpp b/lldb/source/Breakpoint/BreakpointLocationList.cpp
index 5e56299..b4cf0c3 100644
--- a/lldb/source/Breakpoint/BreakpointLocationList.cpp
+++ b/lldb/source/Breakpoint/BreakpointLocationList.cpp
@@ -13,8 +13,8 @@
// Project includes
#include "lldb/Breakpoint/BreakpointLocationList.h"
-#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Breakpoint/Breakpoint.h"
+#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Section.h"
@@ -25,339 +25,286 @@ using namespace lldb;
using namespace lldb_private;
BreakpointLocationList::BreakpointLocationList(Breakpoint &owner)
- : m_owner(owner), m_locations(), m_address_to_location(), m_mutex(), m_next_id(0), m_new_location_recorder(nullptr)
-{
-}
+ : m_owner(owner), m_locations(), m_address_to_location(), m_mutex(),
+ m_next_id(0), m_new_location_recorder(nullptr) {}
BreakpointLocationList::~BreakpointLocationList() = default;
BreakpointLocationSP
-BreakpointLocationList::Create (const Address &addr, bool resolve_indirect_symbols)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- // The location ID is just the size of the location list + 1
- lldb::break_id_t bp_loc_id = ++m_next_id;
- BreakpointLocationSP bp_loc_sp (new BreakpointLocation (bp_loc_id, m_owner, addr, LLDB_INVALID_THREAD_ID, m_owner.IsHardware(), resolve_indirect_symbols));
- m_locations.push_back (bp_loc_sp);
- m_address_to_location[addr] = bp_loc_sp;
- return bp_loc_sp;
+BreakpointLocationList::Create(const Address &addr,
+ bool resolve_indirect_symbols) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ // The location ID is just the size of the location list + 1
+ lldb::break_id_t bp_loc_id = ++m_next_id;
+ BreakpointLocationSP bp_loc_sp(
+ new BreakpointLocation(bp_loc_id, m_owner, addr, LLDB_INVALID_THREAD_ID,
+ m_owner.IsHardware(), resolve_indirect_symbols));
+ m_locations.push_back(bp_loc_sp);
+ m_address_to_location[addr] = bp_loc_sp;
+ return bp_loc_sp;
}
-bool
-BreakpointLocationList::ShouldStop (StoppointCallbackContext *context, lldb::break_id_t break_id)
-{
- BreakpointLocationSP bp = FindByID (break_id);
- if (bp)
- {
- // Let the BreakpointLocation decide if it should stop here (could not have
- // reached it's target hit count yet, or it could have a callback
- // that decided it shouldn't stop (shared library loads/unloads).
- return bp->ShouldStop (context);
- }
- // We should stop here since this BreakpointLocation isn't valid anymore or it
- // doesn't exist.
- return true;
+bool BreakpointLocationList::ShouldStop(StoppointCallbackContext *context,
+ lldb::break_id_t break_id) {
+ BreakpointLocationSP bp = FindByID(break_id);
+ if (bp) {
+ // Let the BreakpointLocation decide if it should stop here (could not have
+ // reached it's target hit count yet, or it could have a callback
+ // that decided it shouldn't stop (shared library loads/unloads).
+ return bp->ShouldStop(context);
+ }
+ // We should stop here since this BreakpointLocation isn't valid anymore or it
+ // doesn't exist.
+ return true;
}
-lldb::break_id_t
-BreakpointLocationList::FindIDByAddress (const Address &addr)
-{
- BreakpointLocationSP bp_loc_sp = FindByAddress (addr);
- if (bp_loc_sp)
- {
- return bp_loc_sp->GetID();
- }
- return LLDB_INVALID_BREAK_ID;
+lldb::break_id_t BreakpointLocationList::FindIDByAddress(const Address &addr) {
+ BreakpointLocationSP bp_loc_sp = FindByAddress(addr);
+ if (bp_loc_sp) {
+ return bp_loc_sp->GetID();
+ }
+ return LLDB_INVALID_BREAK_ID;
}
-static bool
-Compare (BreakpointLocationSP lhs, lldb::break_id_t val)
-{
- return lhs->GetID() < val;
+static bool Compare(BreakpointLocationSP lhs, lldb::break_id_t val) {
+ return lhs->GetID() < val;
}
BreakpointLocationSP
-BreakpointLocationList::FindByID (lldb::break_id_t break_id) const
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- collection::const_iterator end = m_locations.end();
- collection::const_iterator pos = std::lower_bound(m_locations.begin(), end, break_id, Compare);
- if (pos != end && (*pos)->GetID() == break_id)
- return *(pos);
- else
- return BreakpointLocationSP();
+BreakpointLocationList::FindByID(lldb::break_id_t break_id) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ collection::const_iterator end = m_locations.end();
+ collection::const_iterator pos =
+ std::lower_bound(m_locations.begin(), end, break_id, Compare);
+ if (pos != end && (*pos)->GetID() == break_id)
+ return *(pos);
+ else
+ return BreakpointLocationSP();
}
-size_t
-BreakpointLocationList::FindInModule (Module *module,
- BreakpointLocationCollection& bp_loc_list)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- const size_t orig_size = bp_loc_list.GetSize();
- collection::iterator pos, end = m_locations.end();
-
- for (pos = m_locations.begin(); pos != end; ++pos)
- {
- BreakpointLocationSP break_loc = (*pos);
- SectionSP section_sp (break_loc->GetAddress().GetSection());
- if (section_sp && section_sp->GetModule().get() == module)
- {
- bp_loc_list.Add (break_loc);
- }
+size_t BreakpointLocationList::FindInModule(
+ Module *module, BreakpointLocationCollection &bp_loc_list) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ const size_t orig_size = bp_loc_list.GetSize();
+ collection::iterator pos, end = m_locations.end();
+
+ for (pos = m_locations.begin(); pos != end; ++pos) {
+ BreakpointLocationSP break_loc = (*pos);
+ SectionSP section_sp(break_loc->GetAddress().GetSection());
+ if (section_sp && section_sp->GetModule().get() == module) {
+ bp_loc_list.Add(break_loc);
}
- return bp_loc_list.GetSize() - orig_size;
+ }
+ return bp_loc_list.GetSize() - orig_size;
}
const BreakpointLocationSP
-BreakpointLocationList::FindByAddress (const Address &addr) const
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- BreakpointLocationSP bp_loc_sp;
- if (!m_locations.empty())
- {
- Address so_addr;
-
- if (addr.IsSectionOffset())
- {
- so_addr = addr;
- }
- else
- {
- // Try and resolve as a load address if possible.
- m_owner.GetTarget().GetSectionLoadList().ResolveLoadAddress (addr.GetOffset(), so_addr);
- if (!so_addr.IsValid())
- {
- // The address didn't resolve, so just set to passed in addr.
- so_addr = addr;
- }
- }
-
- addr_map::const_iterator pos = m_address_to_location.find (so_addr);
- if (pos != m_address_to_location.end())
- bp_loc_sp = pos->second;
+BreakpointLocationList::FindByAddress(const Address &addr) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ BreakpointLocationSP bp_loc_sp;
+ if (!m_locations.empty()) {
+ Address so_addr;
+
+ if (addr.IsSectionOffset()) {
+ so_addr = addr;
+ } else {
+ // Try and resolve as a load address if possible.
+ m_owner.GetTarget().GetSectionLoadList().ResolveLoadAddress(
+ addr.GetOffset(), so_addr);
+ if (!so_addr.IsValid()) {
+ // The address didn't resolve, so just set to passed in addr.
+ so_addr = addr;
+ }
}
- return bp_loc_sp;
+ addr_map::const_iterator pos = m_address_to_location.find(so_addr);
+ if (pos != m_address_to_location.end())
+ bp_loc_sp = pos->second;
+ }
+
+ return bp_loc_sp;
}
-void
-BreakpointLocationList::Dump (Stream *s) const
-{
- s->Printf("%p: ", static_cast<const void*>(this));
- //s->Indent();
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- s->Printf("BreakpointLocationList with %" PRIu64 " BreakpointLocations:\n", (uint64_t)m_locations.size());
- s->IndentMore();
- collection::const_iterator pos, end = m_locations.end();
- for (pos = m_locations.begin(); pos != end; ++pos)
- (*pos).get()->Dump(s);
- s->IndentLess();
+void BreakpointLocationList::Dump(Stream *s) const {
+ s->Printf("%p: ", static_cast<const void *>(this));
+ // s->Indent();
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ s->Printf("BreakpointLocationList with %" PRIu64 " BreakpointLocations:\n",
+ (uint64_t)m_locations.size());
+ s->IndentMore();
+ collection::const_iterator pos, end = m_locations.end();
+ for (pos = m_locations.begin(); pos != end; ++pos)
+ (*pos).get()->Dump(s);
+ s->IndentLess();
}
-BreakpointLocationSP
-BreakpointLocationList::GetByIndex (size_t i)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- BreakpointLocationSP bp_loc_sp;
- if (i < m_locations.size())
- bp_loc_sp = m_locations[i];
+BreakpointLocationSP BreakpointLocationList::GetByIndex(size_t i) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ BreakpointLocationSP bp_loc_sp;
+ if (i < m_locations.size())
+ bp_loc_sp = m_locations[i];
- return bp_loc_sp;
+ return bp_loc_sp;
}
-const BreakpointLocationSP
-BreakpointLocationList::GetByIndex (size_t i) const
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- BreakpointLocationSP bp_loc_sp;
- if (i < m_locations.size())
- bp_loc_sp = m_locations[i];
+const BreakpointLocationSP BreakpointLocationList::GetByIndex(size_t i) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ BreakpointLocationSP bp_loc_sp;
+ if (i < m_locations.size())
+ bp_loc_sp = m_locations[i];
- return bp_loc_sp;
+ return bp_loc_sp;
}
-void
-BreakpointLocationList::ClearAllBreakpointSites ()
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- collection::iterator pos, end = m_locations.end();
- for (pos = m_locations.begin(); pos != end; ++pos)
- (*pos)->ClearBreakpointSite();
+void BreakpointLocationList::ClearAllBreakpointSites() {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ collection::iterator pos, end = m_locations.end();
+ for (pos = m_locations.begin(); pos != end; ++pos)
+ (*pos)->ClearBreakpointSite();
}
-void
-BreakpointLocationList::ResolveAllBreakpointSites ()
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- collection::iterator pos, end = m_locations.end();
+void BreakpointLocationList::ResolveAllBreakpointSites() {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ collection::iterator pos, end = m_locations.end();
- for (pos = m_locations.begin(); pos != end; ++pos)
- {
- if ((*pos)->IsEnabled())
- (*pos)->ResolveBreakpointSite();
- }
+ for (pos = m_locations.begin(); pos != end; ++pos) {
+ if ((*pos)->IsEnabled())
+ (*pos)->ResolveBreakpointSite();
+ }
}
-uint32_t
-BreakpointLocationList::GetHitCount () const
-{
- uint32_t hit_count = 0;
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- collection::const_iterator pos, end = m_locations.end();
- for (pos = m_locations.begin(); pos != end; ++pos)
- hit_count += (*pos)->GetHitCount();
- return hit_count;
+uint32_t BreakpointLocationList::GetHitCount() const {
+ uint32_t hit_count = 0;
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ collection::const_iterator pos, end = m_locations.end();
+ for (pos = m_locations.begin(); pos != end; ++pos)
+ hit_count += (*pos)->GetHitCount();
+ return hit_count;
}
-size_t
-BreakpointLocationList::GetNumResolvedLocations() const
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- size_t resolve_count = 0;
- collection::const_iterator pos, end = m_locations.end();
- for (pos = m_locations.begin(); pos != end; ++pos)
- {
- if ((*pos)->IsResolved())
- ++resolve_count;
- }
- return resolve_count;
+size_t BreakpointLocationList::GetNumResolvedLocations() const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ size_t resolve_count = 0;
+ collection::const_iterator pos, end = m_locations.end();
+ for (pos = m_locations.begin(); pos != end; ++pos) {
+ if ((*pos)->IsResolved())
+ ++resolve_count;
+ }
+ return resolve_count;
}
-void
-BreakpointLocationList::GetDescription (Stream *s, lldb::DescriptionLevel level)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- collection::iterator pos, end = m_locations.end();
+void BreakpointLocationList::GetDescription(Stream *s,
+ lldb::DescriptionLevel level) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ collection::iterator pos, end = m_locations.end();
- for (pos = m_locations.begin(); pos != end; ++pos)
- {
- s->Printf(" ");
- (*pos)->GetDescription(s, level);
- }
+ for (pos = m_locations.begin(); pos != end; ++pos) {
+ s->Printf(" ");
+ (*pos)->GetDescription(s, level);
+ }
}
-BreakpointLocationSP
-BreakpointLocationList::AddLocation (const Address &addr, bool resolve_indirect_symbols, bool *new_location)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
-
- if (new_location)
- *new_location = false;
- BreakpointLocationSP bp_loc_sp (FindByAddress(addr));
- if (!bp_loc_sp)
- {
- bp_loc_sp = Create (addr, resolve_indirect_symbols);
- if (bp_loc_sp)
- {
- bp_loc_sp->ResolveBreakpointSite();
-
- if (new_location)
- *new_location = true;
- if(m_new_location_recorder)
- {
- m_new_location_recorder->Add(bp_loc_sp);
- }
- }
- }
- return bp_loc_sp;
+BreakpointLocationSP BreakpointLocationList::AddLocation(
+ const Address &addr, bool resolve_indirect_symbols, bool *new_location) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+
+ if (new_location)
+ *new_location = false;
+ BreakpointLocationSP bp_loc_sp(FindByAddress(addr));
+ if (!bp_loc_sp) {
+ bp_loc_sp = Create(addr, resolve_indirect_symbols);
+ if (bp_loc_sp) {
+ bp_loc_sp->ResolveBreakpointSite();
+
+ if (new_location)
+ *new_location = true;
+ if (m_new_location_recorder) {
+ m_new_location_recorder->Add(bp_loc_sp);
+ }
+ }
+ }
+ return bp_loc_sp;
}
-void
-BreakpointLocationList::SwapLocation (BreakpointLocationSP to_location_sp, BreakpointLocationSP from_location_sp)
-{
- if (!from_location_sp || !to_location_sp)
- return;
-
- m_address_to_location.erase(to_location_sp->GetAddress());
- to_location_sp->SwapLocation(from_location_sp);
- RemoveLocation(from_location_sp);
- m_address_to_location[to_location_sp->GetAddress()] = to_location_sp;
- to_location_sp->ResolveBreakpointSite();
+void BreakpointLocationList::SwapLocation(
+ BreakpointLocationSP to_location_sp,
+ BreakpointLocationSP from_location_sp) {
+ if (!from_location_sp || !to_location_sp)
+ return;
+
+ m_address_to_location.erase(to_location_sp->GetAddress());
+ to_location_sp->SwapLocation(from_location_sp);
+ RemoveLocation(from_location_sp);
+ m_address_to_location[to_location_sp->GetAddress()] = to_location_sp;
+ to_location_sp->ResolveBreakpointSite();
}
-bool
-BreakpointLocationList::RemoveLocation (const lldb::BreakpointLocationSP &bp_loc_sp)
-{
- if (bp_loc_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
-
- m_address_to_location.erase (bp_loc_sp->GetAddress());
-
- collection::iterator pos, end = m_locations.end();
- for (pos = m_locations.begin(); pos != end; ++pos)
- {
- if ((*pos).get() == bp_loc_sp.get())
- {
- m_locations.erase (pos);
- return true;
- }
- }
+bool BreakpointLocationList::RemoveLocation(
+ const lldb::BreakpointLocationSP &bp_loc_sp) {
+ if (bp_loc_sp) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+
+ m_address_to_location.erase(bp_loc_sp->GetAddress());
+
+ collection::iterator pos, end = m_locations.end();
+ for (pos = m_locations.begin(); pos != end; ++pos) {
+ if ((*pos).get() == bp_loc_sp.get()) {
+ m_locations.erase(pos);
+ return true;
+ }
}
- return false;
+ }
+ return false;
}
-void
-BreakpointLocationList::RemoveInvalidLocations (const ArchSpec &arch)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- size_t idx = 0;
- // Don't cache m_location.size() as it will change since we might
- // remove locations from our vector...
- while (idx < m_locations.size())
- {
- BreakpointLocation *bp_loc = m_locations[idx].get();
- if (bp_loc->GetAddress().SectionWasDeleted())
- {
- // Section was deleted which means this breakpoint comes from a module
- // that is no longer valid, so we should remove it.
- m_locations.erase(m_locations.begin() + idx);
- continue;
- }
- if (arch.IsValid())
- {
- ModuleSP module_sp (bp_loc->GetAddress().GetModule());
- if (module_sp)
- {
- if (!arch.IsCompatibleMatch(module_sp->GetArchitecture()))
- {
- // The breakpoint was in a module whose architecture is no longer
- // compatible with "arch", so we need to remove it
- m_locations.erase(m_locations.begin() + idx);
- continue;
- }
- }
+void BreakpointLocationList::RemoveInvalidLocations(const ArchSpec &arch) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ size_t idx = 0;
+ // Don't cache m_location.size() as it will change since we might
+ // remove locations from our vector...
+ while (idx < m_locations.size()) {
+ BreakpointLocation *bp_loc = m_locations[idx].get();
+ if (bp_loc->GetAddress().SectionWasDeleted()) {
+ // Section was deleted which means this breakpoint comes from a module
+ // that is no longer valid, so we should remove it.
+ m_locations.erase(m_locations.begin() + idx);
+ continue;
+ }
+ if (arch.IsValid()) {
+ ModuleSP module_sp(bp_loc->GetAddress().GetModule());
+ if (module_sp) {
+ if (!arch.IsCompatibleMatch(module_sp->GetArchitecture())) {
+ // The breakpoint was in a module whose architecture is no longer
+ // compatible with "arch", so we need to remove it
+ m_locations.erase(m_locations.begin() + idx);
+ continue;
}
- // Only increment the index if we didn't remove the locations at index "idx"
- ++idx;
+ }
}
+ // Only increment the index if we didn't remove the locations at index "idx"
+ ++idx;
+ }
}
-void
-BreakpointLocationList::StartRecordingNewLocations (BreakpointLocationCollection &new_locations)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- assert(m_new_location_recorder == nullptr);
- m_new_location_recorder = &new_locations;
+void BreakpointLocationList::StartRecordingNewLocations(
+ BreakpointLocationCollection &new_locations) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ assert(m_new_location_recorder == nullptr);
+ m_new_location_recorder = &new_locations;
}
-void
-BreakpointLocationList::StopRecordingNewLocations ()
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- m_new_location_recorder = nullptr;
+void BreakpointLocationList::StopRecordingNewLocations() {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ m_new_location_recorder = nullptr;
}
-void
-BreakpointLocationList::Compact()
-{
- lldb::break_id_t highest_id = 0;
-
- for (BreakpointLocationSP loc_sp : m_locations)
- {
- lldb::break_id_t cur_id = loc_sp->GetID();
- if (cur_id > highest_id)
- highest_id = cur_id;
- }
- m_next_id = highest_id;
+void BreakpointLocationList::Compact() {
+ lldb::break_id_t highest_id = 0;
+
+ for (BreakpointLocationSP loc_sp : m_locations) {
+ lldb::break_id_t cur_id = loc_sp->GetID();
+ if (cur_id > highest_id)
+ highest_id = cur_id;
+ }
+ m_next_id = highest_id;
}
diff --git a/lldb/source/Breakpoint/BreakpointOptions.cpp b/lldb/source/Breakpoint/BreakpointOptions.cpp
index d2a9197..bb43e3a9 100644
--- a/lldb/source/Breakpoint/BreakpointOptions.cpp
+++ b/lldb/source/Breakpoint/BreakpointOptions.cpp
@@ -13,10 +13,10 @@
// Project includes
#include "lldb/Breakpoint/BreakpointOptions.h"
+#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StringList.h"
#include "lldb/Core/Value.h"
-#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadSpec.h"
@@ -24,78 +24,66 @@
using namespace lldb;
using namespace lldb_private;
-bool
-BreakpointOptions::NullCallback (void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
-{
- return true;
+bool BreakpointOptions::NullCallback(void *baton,
+ StoppointCallbackContext *context,
+ lldb::user_id_t break_id,
+ lldb::user_id_t break_loc_id) {
+ return true;
}
//----------------------------------------------------------------------
// BreakpointOptions constructor
//----------------------------------------------------------------------
-BreakpointOptions::BreakpointOptions() :
- m_callback (BreakpointOptions::NullCallback),
- m_callback_baton_sp (),
- m_callback_is_synchronous (false),
- m_enabled (true),
- m_one_shot (false),
- m_ignore_count (0),
- m_thread_spec_ap (),
- m_condition_text (),
- m_condition_text_hash (0)
-{
-}
+BreakpointOptions::BreakpointOptions()
+ : m_callback(BreakpointOptions::NullCallback), m_callback_baton_sp(),
+ m_callback_is_synchronous(false), m_enabled(true), m_one_shot(false),
+ m_ignore_count(0), m_thread_spec_ap(), m_condition_text(),
+ m_condition_text_hash(0) {}
//----------------------------------------------------------------------
// BreakpointOptions copy constructor
//----------------------------------------------------------------------
-BreakpointOptions::BreakpointOptions(const BreakpointOptions& rhs) :
- m_callback (rhs.m_callback),
- m_callback_baton_sp (rhs.m_callback_baton_sp),
- m_callback_is_synchronous (rhs.m_callback_is_synchronous),
- m_enabled (rhs.m_enabled),
- m_one_shot (rhs.m_one_shot),
- m_ignore_count (rhs.m_ignore_count),
- m_thread_spec_ap ()
-{
- if (rhs.m_thread_spec_ap.get() != nullptr)
- m_thread_spec_ap.reset (new ThreadSpec(*rhs.m_thread_spec_ap.get()));
- m_condition_text = rhs.m_condition_text;
- m_condition_text_hash = rhs.m_condition_text_hash;
+BreakpointOptions::BreakpointOptions(const BreakpointOptions &rhs)
+ : m_callback(rhs.m_callback), m_callback_baton_sp(rhs.m_callback_baton_sp),
+ m_callback_is_synchronous(rhs.m_callback_is_synchronous),
+ m_enabled(rhs.m_enabled), m_one_shot(rhs.m_one_shot),
+ m_ignore_count(rhs.m_ignore_count), m_thread_spec_ap() {
+ if (rhs.m_thread_spec_ap.get() != nullptr)
+ m_thread_spec_ap.reset(new ThreadSpec(*rhs.m_thread_spec_ap.get()));
+ m_condition_text = rhs.m_condition_text;
+ m_condition_text_hash = rhs.m_condition_text_hash;
}
//----------------------------------------------------------------------
// BreakpointOptions assignment operator
//----------------------------------------------------------------------
-const BreakpointOptions&
-BreakpointOptions::operator=(const BreakpointOptions& rhs)
-{
- m_callback = rhs.m_callback;
- m_callback_baton_sp = rhs.m_callback_baton_sp;
- m_callback_is_synchronous = rhs.m_callback_is_synchronous;
- m_enabled = rhs.m_enabled;
- m_one_shot = rhs.m_one_shot;
- m_ignore_count = rhs.m_ignore_count;
- if (rhs.m_thread_spec_ap.get() != nullptr)
- m_thread_spec_ap.reset(new ThreadSpec(*rhs.m_thread_spec_ap.get()));
- m_condition_text = rhs.m_condition_text;
- m_condition_text_hash = rhs.m_condition_text_hash;
- return *this;
+const BreakpointOptions &BreakpointOptions::
+operator=(const BreakpointOptions &rhs) {
+ m_callback = rhs.m_callback;
+ m_callback_baton_sp = rhs.m_callback_baton_sp;
+ m_callback_is_synchronous = rhs.m_callback_is_synchronous;
+ m_enabled = rhs.m_enabled;
+ m_one_shot = rhs.m_one_shot;
+ m_ignore_count = rhs.m_ignore_count;
+ if (rhs.m_thread_spec_ap.get() != nullptr)
+ m_thread_spec_ap.reset(new ThreadSpec(*rhs.m_thread_spec_ap.get()));
+ m_condition_text = rhs.m_condition_text;
+ m_condition_text_hash = rhs.m_condition_text_hash;
+ return *this;
}
BreakpointOptions *
-BreakpointOptions::CopyOptionsNoCallback (BreakpointOptions &orig)
-{
- BreakpointHitCallback orig_callback = orig.m_callback;
- lldb::BatonSP orig_callback_baton_sp = orig.m_callback_baton_sp;
- bool orig_is_sync = orig.m_callback_is_synchronous;
-
- orig.ClearCallback();
- BreakpointOptions *ret_val = new BreakpointOptions(orig);
-
- orig.SetCallback (orig_callback, orig_callback_baton_sp, orig_is_sync);
-
- return ret_val;
+BreakpointOptions::CopyOptionsNoCallback(BreakpointOptions &orig) {
+ BreakpointHitCallback orig_callback = orig.m_callback;
+ lldb::BatonSP orig_callback_baton_sp = orig.m_callback_baton_sp;
+ bool orig_is_sync = orig.m_callback_is_synchronous;
+
+ orig.ClearCallback();
+ BreakpointOptions *ret_val = new BreakpointOptions(orig);
+
+ orig.SetCallback(orig_callback, orig_callback_baton_sp, orig_is_sync);
+
+ return ret_val;
}
//----------------------------------------------------------------------
@@ -106,187 +94,148 @@ BreakpointOptions::~BreakpointOptions() = default;
//------------------------------------------------------------------
// Callbacks
//------------------------------------------------------------------
-void
-BreakpointOptions::SetCallback (BreakpointHitCallback callback, const BatonSP &callback_baton_sp, bool callback_is_synchronous)
-{
- m_callback_is_synchronous = callback_is_synchronous;
- m_callback = callback;
- m_callback_baton_sp = callback_baton_sp;
+void BreakpointOptions::SetCallback(BreakpointHitCallback callback,
+ const BatonSP &callback_baton_sp,
+ bool callback_is_synchronous) {
+ m_callback_is_synchronous = callback_is_synchronous;
+ m_callback = callback;
+ m_callback_baton_sp = callback_baton_sp;
}
-void
-BreakpointOptions::ClearCallback ()
-{
- m_callback = BreakpointOptions::NullCallback;
- m_callback_is_synchronous = false;
- m_callback_baton_sp.reset();
+void BreakpointOptions::ClearCallback() {
+ m_callback = BreakpointOptions::NullCallback;
+ m_callback_is_synchronous = false;
+ m_callback_baton_sp.reset();
}
-Baton *
-BreakpointOptions::GetBaton ()
-{
- return m_callback_baton_sp.get();
-}
+Baton *BreakpointOptions::GetBaton() { return m_callback_baton_sp.get(); }
-const Baton *
-BreakpointOptions::GetBaton () const
-{
- return m_callback_baton_sp.get();
+const Baton *BreakpointOptions::GetBaton() const {
+ return m_callback_baton_sp.get();
}
-bool
-BreakpointOptions::InvokeCallback (StoppointCallbackContext *context,
- lldb::user_id_t break_id,
- lldb::user_id_t break_loc_id)
-{
- if (m_callback && context->is_synchronous == IsCallbackSynchronous())
- {
- return m_callback(m_callback_baton_sp ? m_callback_baton_sp->m_data : nullptr,
- context,
- break_id,
- break_loc_id);
- }
- else
- return true;
+bool BreakpointOptions::InvokeCallback(StoppointCallbackContext *context,
+ lldb::user_id_t break_id,
+ lldb::user_id_t break_loc_id) {
+ if (m_callback && context->is_synchronous == IsCallbackSynchronous()) {
+ return m_callback(m_callback_baton_sp ? m_callback_baton_sp->m_data
+ : nullptr,
+ context, break_id, break_loc_id);
+ } else
+ return true;
}
-bool
-BreakpointOptions::HasCallback () const
-{
- return m_callback != BreakpointOptions::NullCallback;
+bool BreakpointOptions::HasCallback() const {
+ return m_callback != BreakpointOptions::NullCallback;
}
-void
-BreakpointOptions::SetCondition (const char *condition)
-{
- if (!condition)
- condition = "";
-
- m_condition_text.assign(condition);
- std::hash<std::string> hasher;
- m_condition_text_hash = hasher(m_condition_text);
+void BreakpointOptions::SetCondition(const char *condition) {
+ if (!condition)
+ condition = "";
+
+ m_condition_text.assign(condition);
+ std::hash<std::string> hasher;
+ m_condition_text_hash = hasher(m_condition_text);
}
-const char *
-BreakpointOptions::GetConditionText (size_t *hash) const
-{
- if (!m_condition_text.empty())
- {
- if (hash)
- *hash = m_condition_text_hash;
-
- return m_condition_text.c_str();
- }
- else
- {
- return nullptr;
- }
+const char *BreakpointOptions::GetConditionText(size_t *hash) const {
+ if (!m_condition_text.empty()) {
+ if (hash)
+ *hash = m_condition_text_hash;
+
+ return m_condition_text.c_str();
+ } else {
+ return nullptr;
+ }
}
-const ThreadSpec *
-BreakpointOptions::GetThreadSpecNoCreate () const
-{
- return m_thread_spec_ap.get();
+const ThreadSpec *BreakpointOptions::GetThreadSpecNoCreate() const {
+ return m_thread_spec_ap.get();
}
-ThreadSpec *
-BreakpointOptions::GetThreadSpec ()
-{
- if (m_thread_spec_ap.get() == nullptr)
- m_thread_spec_ap.reset (new ThreadSpec());
-
- return m_thread_spec_ap.get();
+ThreadSpec *BreakpointOptions::GetThreadSpec() {
+ if (m_thread_spec_ap.get() == nullptr)
+ m_thread_spec_ap.reset(new ThreadSpec());
+
+ return m_thread_spec_ap.get();
}
-void
-BreakpointOptions::SetThreadID (lldb::tid_t thread_id)
-{
- GetThreadSpec()->SetTID(thread_id);
+void BreakpointOptions::SetThreadID(lldb::tid_t thread_id) {
+ GetThreadSpec()->SetTID(thread_id);
}
-void
-BreakpointOptions::GetDescription (Stream *s, lldb::DescriptionLevel level) const
-{
- // Figure out if there are any options not at their default value, and only print
- // anything if there are:
-
- if (m_ignore_count != 0 || !m_enabled || m_one_shot || (GetThreadSpecNoCreate() != nullptr && GetThreadSpecNoCreate()->HasSpecification ()))
- {
- if (level == lldb::eDescriptionLevelVerbose)
- {
- s->EOL ();
- s->IndentMore();
- s->Indent();
- s->PutCString("Breakpoint Options:\n");
- s->IndentMore();
- s->Indent();
- }
- else
- s->PutCString(" Options: ");
-
- if (m_ignore_count > 0)
- s->Printf("ignore: %d ", m_ignore_count);
- s->Printf("%sabled ", m_enabled ? "en" : "dis");
-
- if (m_one_shot)
- s->Printf ("one-shot ");
-
- if (m_thread_spec_ap.get())
- m_thread_spec_ap->GetDescription (s, level);
-
- if (level == lldb::eDescriptionLevelFull)
- {
- s->IndentLess();
- s->IndentMore();
- }
+void BreakpointOptions::GetDescription(Stream *s,
+ lldb::DescriptionLevel level) const {
+ // Figure out if there are any options not at their default value, and only
+ // print
+ // anything if there are:
+
+ if (m_ignore_count != 0 || !m_enabled || m_one_shot ||
+ (GetThreadSpecNoCreate() != nullptr &&
+ GetThreadSpecNoCreate()->HasSpecification())) {
+ if (level == lldb::eDescriptionLevelVerbose) {
+ s->EOL();
+ s->IndentMore();
+ s->Indent();
+ s->PutCString("Breakpoint Options:\n");
+ s->IndentMore();
+ s->Indent();
+ } else
+ s->PutCString(" Options: ");
+
+ if (m_ignore_count > 0)
+ s->Printf("ignore: %d ", m_ignore_count);
+ s->Printf("%sabled ", m_enabled ? "en" : "dis");
+
+ if (m_one_shot)
+ s->Printf("one-shot ");
+
+ if (m_thread_spec_ap.get())
+ m_thread_spec_ap->GetDescription(s, level);
+
+ if (level == lldb::eDescriptionLevelFull) {
+ s->IndentLess();
+ s->IndentMore();
}
-
- if (m_callback_baton_sp.get())
- {
- if (level != eDescriptionLevelBrief)
- {
- s->EOL();
- m_callback_baton_sp->GetDescription (s, level);
- }
+ }
+
+ if (m_callback_baton_sp.get()) {
+ if (level != eDescriptionLevelBrief) {
+ s->EOL();
+ m_callback_baton_sp->GetDescription(s, level);
+ }
+ }
+ if (!m_condition_text.empty()) {
+ if (level != eDescriptionLevelBrief) {
+ s->EOL();
+ s->Printf("Condition: %s\n", m_condition_text.c_str());
}
- if (!m_condition_text.empty())
- {
- if (level != eDescriptionLevelBrief)
- {
- s->EOL();
- s->Printf("Condition: %s\n", m_condition_text.c_str());
- }
- }
+ }
}
-void
-BreakpointOptions::CommandBaton::GetDescription (Stream *s, lldb::DescriptionLevel level) const
-{
- CommandData *data = (CommandData *)m_data;
+void BreakpointOptions::CommandBaton::GetDescription(
+ Stream *s, lldb::DescriptionLevel level) const {
+ CommandData *data = (CommandData *)m_data;
- if (level == eDescriptionLevelBrief)
- {
- s->Printf (", commands = %s", (data && data->user_source.GetSize() > 0) ? "yes" : "no");
- return;
- }
-
- s->IndentMore ();
- s->Indent("Breakpoint commands:\n");
-
- s->IndentMore ();
- if (data && data->user_source.GetSize() > 0)
- {
- const size_t num_strings = data->user_source.GetSize();
- for (size_t i = 0; i < num_strings; ++i)
- {
- s->Indent(data->user_source.GetStringAtIndex(i));
- s->EOL();
- }
- }
- else
- {
- s->PutCString ("No commands.\n");
+ if (level == eDescriptionLevelBrief) {
+ s->Printf(", commands = %s",
+ (data && data->user_source.GetSize() > 0) ? "yes" : "no");
+ return;
+ }
+
+ s->IndentMore();
+ s->Indent("Breakpoint commands:\n");
+
+ s->IndentMore();
+ if (data && data->user_source.GetSize() > 0) {
+ const size_t num_strings = data->user_source.GetSize();
+ for (size_t i = 0; i < num_strings; ++i) {
+ s->Indent(data->user_source.GetStringAtIndex(i));
+ s->EOL();
}
- s->IndentLess ();
- s->IndentLess ();
+ } else {
+ s->PutCString("No commands.\n");
+ }
+ s->IndentLess();
+ s->IndentLess();
}
diff --git a/lldb/source/Breakpoint/BreakpointResolver.cpp b/lldb/source/Breakpoint/BreakpointResolver.cpp
index e757b38..ee6e4c8 100644
--- a/lldb/source/Breakpoint/BreakpointResolver.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolver.cpp
@@ -13,18 +13,18 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Address.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
+#include "lldb/Core/Address.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/SearchFilter.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamString.h"
-#include "lldb/Symbol/SymbolContext.h"
-#include "lldb/Target/Target.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Target/Target.h"
using namespace lldb_private;
using namespace lldb;
@@ -32,196 +32,169 @@ using namespace lldb;
//----------------------------------------------------------------------
// BreakpointResolver:
//----------------------------------------------------------------------
-BreakpointResolver::BreakpointResolver (Breakpoint *bkpt, const unsigned char resolverTy, lldb::addr_t offset) :
- m_breakpoint (bkpt),
- m_offset(offset),
- SubclassID (resolverTy)
-{
-}
+BreakpointResolver::BreakpointResolver(Breakpoint *bkpt,
+ const unsigned char resolverTy,
+ lldb::addr_t offset)
+ : m_breakpoint(bkpt), m_offset(offset), SubclassID(resolverTy) {}
-BreakpointResolver::~BreakpointResolver ()
-{
+BreakpointResolver::~BreakpointResolver() {}
+void BreakpointResolver::SetBreakpoint(Breakpoint *bkpt) {
+ m_breakpoint = bkpt;
}
-void
-BreakpointResolver::SetBreakpoint (Breakpoint *bkpt)
-{
- m_breakpoint = bkpt;
+void BreakpointResolver::ResolveBreakpointInModules(SearchFilter &filter,
+ ModuleList &modules) {
+ filter.SearchInModuleList(*this, modules);
}
-void
-BreakpointResolver::ResolveBreakpointInModules (SearchFilter &filter, ModuleList &modules)
-{
- filter.SearchInModuleList(*this, modules);
+void BreakpointResolver::ResolveBreakpoint(SearchFilter &filter) {
+ filter.Search(*this);
}
-void
-BreakpointResolver::ResolveBreakpoint (SearchFilter &filter)
-{
- filter.Search (*this);
-}
+void BreakpointResolver::SetSCMatchesByLine(SearchFilter &filter,
+ SymbolContextList &sc_list,
+ bool skip_prologue,
+ const char *log_ident) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+
+ while (sc_list.GetSize() > 0) {
+ SymbolContextList tmp_sc_list;
+ unsigned current_idx = 0;
+ SymbolContext sc;
+ bool first_entry = true;
+
+ FileSpec match_file_spec;
+ FileSpec match_original_file_spec;
+ uint32_t closest_line_number = UINT32_MAX;
+
+ // Pull out the first entry, and all the others that match its file spec,
+ // and stuff them in the tmp list.
+ while (current_idx < sc_list.GetSize()) {
+ bool matches;
+
+ sc_list.GetContextAtIndex(current_idx, sc);
+ if (first_entry) {
+ match_file_spec = sc.line_entry.file;
+ match_original_file_spec = sc.line_entry.original_file;
+ matches = true;
+ first_entry = false;
+ } else
+ matches = ((sc.line_entry.file == match_file_spec) ||
+ (sc.line_entry.original_file == match_original_file_spec));
+
+ if (matches) {
+ tmp_sc_list.Append(sc);
+ sc_list.RemoveContextAtIndex(current_idx);
+
+ // ResolveSymbolContext will always return a number that is >= the line
+ // number you pass in.
+ // So the smaller line number is always better.
+ if (sc.line_entry.line < closest_line_number)
+ closest_line_number = sc.line_entry.line;
+ } else
+ current_idx++;
+ }
-void
-BreakpointResolver::SetSCMatchesByLine (SearchFilter &filter, SymbolContextList &sc_list, bool skip_prologue, const char *log_ident)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
-
- while (sc_list.GetSize() > 0)
- {
- SymbolContextList tmp_sc_list;
- unsigned current_idx = 0;
- SymbolContext sc;
- bool first_entry = true;
-
- FileSpec match_file_spec;
- FileSpec match_original_file_spec;
- uint32_t closest_line_number = UINT32_MAX;
-
- // Pull out the first entry, and all the others that match its file spec, and stuff them in the tmp list.
- while (current_idx < sc_list.GetSize())
- {
- bool matches;
-
- sc_list.GetContextAtIndex (current_idx, sc);
- if (first_entry)
- {
- match_file_spec = sc.line_entry.file;
- match_original_file_spec = sc.line_entry.original_file;
- matches = true;
- first_entry = false;
- }
- else
- matches = ((sc.line_entry.file == match_file_spec) ||
- (sc.line_entry.original_file == match_original_file_spec));
-
- if (matches)
- {
- tmp_sc_list.Append (sc);
- sc_list.RemoveContextAtIndex(current_idx);
-
- // ResolveSymbolContext will always return a number that is >= the line number you pass in.
- // So the smaller line number is always better.
- if (sc.line_entry.line < closest_line_number)
- closest_line_number = sc.line_entry.line;
- }
- else
- current_idx++;
- }
-
- // Okay, we've found the closest line number match, now throw away all the others:
-
- current_idx = 0;
- while (current_idx < tmp_sc_list.GetSize())
- {
- if (tmp_sc_list.GetContextAtIndex(current_idx, sc))
- {
- if (sc.line_entry.line != closest_line_number)
- tmp_sc_list.RemoveContextAtIndex(current_idx);
- else
- current_idx++;
- }
- }
-
- // Next go through and see if there are line table entries that are contiguous, and if so keep only the
- // first of the contiguous range:
-
- current_idx = 0;
- std::map<Block *, lldb::addr_t> blocks_with_breakpoints;
-
- while (current_idx < tmp_sc_list.GetSize())
- {
- if (tmp_sc_list.GetContextAtIndex(current_idx, sc))
- {
- if (blocks_with_breakpoints.find (sc.block) != blocks_with_breakpoints.end())
- tmp_sc_list.RemoveContextAtIndex(current_idx);
- else
- {
- blocks_with_breakpoints.insert (std::pair<Block *, lldb::addr_t>(sc.block, sc.line_entry.range.GetBaseAddress().GetFileAddress()));
- current_idx++;
- }
- }
+ // Okay, we've found the closest line number match, now throw away all the
+ // others:
+
+ current_idx = 0;
+ while (current_idx < tmp_sc_list.GetSize()) {
+ if (tmp_sc_list.GetContextAtIndex(current_idx, sc)) {
+ if (sc.line_entry.line != closest_line_number)
+ tmp_sc_list.RemoveContextAtIndex(current_idx);
+ else
+ current_idx++;
+ }
+ }
+
+ // Next go through and see if there are line table entries that are
+ // contiguous, and if so keep only the
+ // first of the contiguous range:
+
+ current_idx = 0;
+ std::map<Block *, lldb::addr_t> blocks_with_breakpoints;
+
+ while (current_idx < tmp_sc_list.GetSize()) {
+ if (tmp_sc_list.GetContextAtIndex(current_idx, sc)) {
+ if (blocks_with_breakpoints.find(sc.block) !=
+ blocks_with_breakpoints.end())
+ tmp_sc_list.RemoveContextAtIndex(current_idx);
+ else {
+ blocks_with_breakpoints.insert(std::pair<Block *, lldb::addr_t>(
+ sc.block, sc.line_entry.range.GetBaseAddress().GetFileAddress()));
+ current_idx++;
}
-
- // and make breakpoints out of the closest line number match.
-
- uint32_t tmp_sc_list_size = tmp_sc_list.GetSize();
-
- for (uint32_t i = 0; i < tmp_sc_list_size; i++)
- {
- if (tmp_sc_list.GetContextAtIndex(i, sc))
- {
- Address line_start = sc.line_entry.range.GetBaseAddress();
- if (line_start.IsValid())
- {
- if (filter.AddressPasses(line_start))
- {
- // If the line number is before the prologue end, move it there...
- bool skipped_prologue = false;
- if (skip_prologue)
- {
- if (sc.function)
- {
- Address prologue_addr(sc.function->GetAddressRange().GetBaseAddress());
- if (prologue_addr.IsValid() && (line_start == prologue_addr))
- {
- const uint32_t prologue_byte_size = sc.function->GetPrologueByteSize();
- if (prologue_byte_size)
- {
- prologue_addr.Slide(prologue_byte_size);
-
- if (filter.AddressPasses(prologue_addr))
- {
- skipped_prologue = true;
- line_start = prologue_addr;
- }
- }
- }
- }
- }
-
- BreakpointLocationSP bp_loc_sp (AddLocation(line_start));
- if (log && bp_loc_sp && !m_breakpoint->IsInternal())
- {
- StreamString s;
- bp_loc_sp->GetDescription (&s, lldb::eDescriptionLevelVerbose);
- log->Printf ("Added location (skipped prologue: %s): %s \n", skipped_prologue ? "yes" : "no", s.GetData());
- }
- }
- else if (log)
- {
- log->Printf ("Breakpoint %s at file address 0x%" PRIx64 " didn't pass the filter.\n",
- log_ident ? log_ident : "",
- line_start.GetFileAddress());
+ }
+ }
+
+ // and make breakpoints out of the closest line number match.
+
+ uint32_t tmp_sc_list_size = tmp_sc_list.GetSize();
+
+ for (uint32_t i = 0; i < tmp_sc_list_size; i++) {
+ if (tmp_sc_list.GetContextAtIndex(i, sc)) {
+ Address line_start = sc.line_entry.range.GetBaseAddress();
+ if (line_start.IsValid()) {
+ if (filter.AddressPasses(line_start)) {
+ // If the line number is before the prologue end, move it there...
+ bool skipped_prologue = false;
+ if (skip_prologue) {
+ if (sc.function) {
+ Address prologue_addr(
+ sc.function->GetAddressRange().GetBaseAddress());
+ if (prologue_addr.IsValid() && (line_start == prologue_addr)) {
+ const uint32_t prologue_byte_size =
+ sc.function->GetPrologueByteSize();
+ if (prologue_byte_size) {
+ prologue_addr.Slide(prologue_byte_size);
+
+ if (filter.AddressPasses(prologue_addr)) {
+ skipped_prologue = true;
+ line_start = prologue_addr;
}
+ }
}
- else
- {
- if (log)
- log->Printf ("error: Unable to set breakpoint %s at file address 0x%" PRIx64 "\n",
- log_ident ? log_ident : "",
- line_start.GetFileAddress());
- }
+ }
}
+
+ BreakpointLocationSP bp_loc_sp(AddLocation(line_start));
+ if (log && bp_loc_sp && !m_breakpoint->IsInternal()) {
+ StreamString s;
+ bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
+ log->Printf("Added location (skipped prologue: %s): %s \n",
+ skipped_prologue ? "yes" : "no", s.GetData());
+ }
+ } else if (log) {
+ log->Printf("Breakpoint %s at file address 0x%" PRIx64
+ " didn't pass the filter.\n",
+ log_ident ? log_ident : "",
+ line_start.GetFileAddress());
+ }
+ } else {
+ if (log)
+ log->Printf(
+ "error: Unable to set breakpoint %s at file address 0x%" PRIx64
+ "\n",
+ log_ident ? log_ident : "", line_start.GetFileAddress());
}
+ }
}
+ }
}
-BreakpointLocationSP
-BreakpointResolver::AddLocation(Address loc_addr, bool *new_location)
-{
- loc_addr.Slide(m_offset);
- return m_breakpoint->AddLocation(loc_addr, new_location);
+BreakpointLocationSP BreakpointResolver::AddLocation(Address loc_addr,
+ bool *new_location) {
+ loc_addr.Slide(m_offset);
+ return m_breakpoint->AddLocation(loc_addr, new_location);
}
-
-void
-BreakpointResolver::SetOffset (lldb::addr_t offset)
-{
- // There may already be an offset, so we are actually adjusting location addresses by the difference.
- // lldb::addr_t slide = offset - m_offset;
- // FIXME: We should go fix up all the already set locations for the new slide.
+void BreakpointResolver::SetOffset(lldb::addr_t offset) {
+ // There may already be an offset, so we are actually adjusting location
+ // addresses by the difference.
+ // lldb::addr_t slide = offset - m_offset;
+ // FIXME: We should go fix up all the already set locations for the new slide.
- m_offset = offset;
+ m_offset = offset;
}
-
diff --git a/lldb/source/Breakpoint/BreakpointResolverAddress.cpp b/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
index 1494201..e52ec9c 100644
--- a/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
@@ -27,149 +27,111 @@ using namespace lldb_private;
//----------------------------------------------------------------------
// BreakpointResolverAddress:
//----------------------------------------------------------------------
-BreakpointResolverAddress::BreakpointResolverAddress
-(
- Breakpoint *bkpt,
- const Address &addr,
- const FileSpec &module_spec
-) :
- BreakpointResolver (bkpt, BreakpointResolver::AddressResolver),
- m_addr (addr),
- m_resolved_addr(LLDB_INVALID_ADDRESS),
- m_module_filespec(module_spec)
-{
+BreakpointResolverAddress::BreakpointResolverAddress(
+ Breakpoint *bkpt, const Address &addr, const FileSpec &module_spec)
+ : BreakpointResolver(bkpt, BreakpointResolver::AddressResolver),
+ m_addr(addr), m_resolved_addr(LLDB_INVALID_ADDRESS),
+ m_module_filespec(module_spec) {}
+
+BreakpointResolverAddress::BreakpointResolverAddress(Breakpoint *bkpt,
+ const Address &addr)
+ : BreakpointResolver(bkpt, BreakpointResolver::AddressResolver),
+ m_addr(addr), m_resolved_addr(LLDB_INVALID_ADDRESS), m_module_filespec() {
}
-BreakpointResolverAddress::BreakpointResolverAddress
-(
- Breakpoint *bkpt,
- const Address &addr
-) :
- BreakpointResolver (bkpt, BreakpointResolver::AddressResolver),
- m_addr (addr),
- m_resolved_addr(LLDB_INVALID_ADDRESS),
- m_module_filespec()
-{
+BreakpointResolverAddress::~BreakpointResolverAddress() {}
+
+void BreakpointResolverAddress::ResolveBreakpoint(SearchFilter &filter) {
+ // If the address is not section relative, then we should not try to
+ // re-resolve it, it is just some
+ // random address and we wouldn't know what to do on reload. But if it is
+ // section relative, we need to
+ // re-resolve it since the section it's in may have shifted on re-run.
+ bool re_resolve = false;
+ if (m_addr.GetSection() || m_module_filespec)
+ re_resolve = true;
+ else if (m_breakpoint->GetNumLocations() == 0)
+ re_resolve = true;
+
+ if (re_resolve)
+ BreakpointResolver::ResolveBreakpoint(filter);
}
-BreakpointResolverAddress::~BreakpointResolverAddress ()
-{
-
-}
-
-void
-BreakpointResolverAddress::ResolveBreakpoint (SearchFilter &filter)
-{
- // If the address is not section relative, then we should not try to re-resolve it, it is just some
- // random address and we wouldn't know what to do on reload. But if it is section relative, we need to
- // re-resolve it since the section it's in may have shifted on re-run.
- bool re_resolve = false;
- if (m_addr.GetSection() || m_module_filespec)
- re_resolve = true;
- else if (m_breakpoint->GetNumLocations() == 0)
- re_resolve = true;
-
- if (re_resolve)
- BreakpointResolver::ResolveBreakpoint(filter);
-}
-
-void
-BreakpointResolverAddress::ResolveBreakpointInModules
-(
- SearchFilter &filter,
- ModuleList &modules
-)
-{
- // See comment in ResolveBreakpoint.
- bool re_resolve = false;
- if (m_addr.GetSection())
- re_resolve = true;
- else if (m_breakpoint->GetNumLocations() == 0)
- re_resolve = true;
-
- if (re_resolve)
- BreakpointResolver::ResolveBreakpointInModules (filter, modules);
+void BreakpointResolverAddress::ResolveBreakpointInModules(
+ SearchFilter &filter, ModuleList &modules) {
+ // See comment in ResolveBreakpoint.
+ bool re_resolve = false;
+ if (m_addr.GetSection())
+ re_resolve = true;
+ else if (m_breakpoint->GetNumLocations() == 0)
+ re_resolve = true;
+
+ if (re_resolve)
+ BreakpointResolver::ResolveBreakpointInModules(filter, modules);
}
Searcher::CallbackReturn
-BreakpointResolverAddress::SearchCallback
-(
- SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool containing
-)
-{
- assert (m_breakpoint != NULL);
-
- if (filter.AddressPasses (m_addr))
- {
- if (m_breakpoint->GetNumLocations() == 0)
- {
- // If the address is just an offset, and we're given a module, see if we can find the appropriate module
- // loaded in the binary, and fix up m_addr to use that.
- if (!m_addr.IsSectionOffset() && m_module_filespec)
- {
- Target &target = m_breakpoint->GetTarget();
- ModuleSpec module_spec(m_module_filespec);
- ModuleSP module_sp = target.GetImages().FindFirstModule(module_spec);
- if (module_sp)
- {
- Address tmp_address;
- if (module_sp->ResolveFileAddress(m_addr.GetOffset(), tmp_address))
- m_addr = tmp_address;
- }
- }
-
- m_resolved_addr = m_addr.GetLoadAddress(&m_breakpoint->GetTarget());
- BreakpointLocationSP bp_loc_sp(AddLocation(m_addr));
- if (bp_loc_sp && !m_breakpoint->IsInternal())
- {
- StreamString s;
- bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
- if (log)
- log->Printf ("Added location: %s\n", s.GetData());
- }
- }
- else
- {
- BreakpointLocationSP loc_sp = m_breakpoint->GetLocationAtIndex(0);
- lldb::addr_t cur_load_location = m_addr.GetLoadAddress(&m_breakpoint->GetTarget());
- if (cur_load_location != m_resolved_addr)
- {
- m_resolved_addr = cur_load_location;
- loc_sp->ClearBreakpointSite();
- loc_sp->ResolveBreakpointSite();
- }
+BreakpointResolverAddress::SearchCallback(SearchFilter &filter,
+ SymbolContext &context, Address *addr,
+ bool containing) {
+ assert(m_breakpoint != NULL);
+
+ if (filter.AddressPasses(m_addr)) {
+ if (m_breakpoint->GetNumLocations() == 0) {
+ // If the address is just an offset, and we're given a module, see if we
+ // can find the appropriate module
+ // loaded in the binary, and fix up m_addr to use that.
+ if (!m_addr.IsSectionOffset() && m_module_filespec) {
+ Target &target = m_breakpoint->GetTarget();
+ ModuleSpec module_spec(m_module_filespec);
+ ModuleSP module_sp = target.GetImages().FindFirstModule(module_spec);
+ if (module_sp) {
+ Address tmp_address;
+ if (module_sp->ResolveFileAddress(m_addr.GetOffset(), tmp_address))
+ m_addr = tmp_address;
}
+ }
+
+ m_resolved_addr = m_addr.GetLoadAddress(&m_breakpoint->GetTarget());
+ BreakpointLocationSP bp_loc_sp(AddLocation(m_addr));
+ if (bp_loc_sp && !m_breakpoint->IsInternal()) {
+ StreamString s;
+ bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
+ Log *log(
+ lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+ if (log)
+ log->Printf("Added location: %s\n", s.GetData());
+ }
+ } else {
+ BreakpointLocationSP loc_sp = m_breakpoint->GetLocationAtIndex(0);
+ lldb::addr_t cur_load_location =
+ m_addr.GetLoadAddress(&m_breakpoint->GetTarget());
+ if (cur_load_location != m_resolved_addr) {
+ m_resolved_addr = cur_load_location;
+ loc_sp->ClearBreakpointSite();
+ loc_sp->ResolveBreakpointSite();
+ }
}
- return Searcher::eCallbackReturnStop;
+ }
+ return Searcher::eCallbackReturnStop;
}
-Searcher::Depth
-BreakpointResolverAddress::GetDepth()
-{
- return Searcher::eDepthTarget;
+Searcher::Depth BreakpointResolverAddress::GetDepth() {
+ return Searcher::eDepthTarget;
}
-void
-BreakpointResolverAddress::GetDescription (Stream *s)
-{
- s->PutCString ("address = ");
- m_addr.Dump(s, m_breakpoint->GetTarget().GetProcessSP().get(), Address::DumpStyleModuleWithFileAddress, Address::DumpStyleLoadAddress);
+void BreakpointResolverAddress::GetDescription(Stream *s) {
+ s->PutCString("address = ");
+ m_addr.Dump(s, m_breakpoint->GetTarget().GetProcessSP().get(),
+ Address::DumpStyleModuleWithFileAddress,
+ Address::DumpStyleLoadAddress);
}
-void
-BreakpointResolverAddress::Dump (Stream *s) const
-{
-
-}
+void BreakpointResolverAddress::Dump(Stream *s) const {}
lldb::BreakpointResolverSP
-BreakpointResolverAddress::CopyForBreakpoint (Breakpoint &breakpoint)
-{
- lldb::BreakpointResolverSP ret_sp(new BreakpointResolverAddress(&breakpoint, m_addr));
- return ret_sp;
+BreakpointResolverAddress::CopyForBreakpoint(Breakpoint &breakpoint) {
+ lldb::BreakpointResolverSP ret_sp(
+ new BreakpointResolverAddress(&breakpoint, m_addr));
+ return ret_sp;
}
-
diff --git a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
index e1fb87a..482b165 100644
--- a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
@@ -26,102 +26,79 @@ using namespace lldb_private;
//----------------------------------------------------------------------
// BreakpointResolverFileLine:
//----------------------------------------------------------------------
-BreakpointResolverFileLine::BreakpointResolverFileLine
-(
- Breakpoint *bkpt,
- const FileSpec &file_spec,
- uint32_t line_no,
- lldb::addr_t offset,
- bool check_inlines,
- bool skip_prologue,
- bool exact_match
-) :
- BreakpointResolver (bkpt, BreakpointResolver::FileLineResolver, offset),
- m_file_spec (file_spec),
- m_line_number (line_no),
- m_inlines (check_inlines),
- m_skip_prologue(skip_prologue),
- m_exact_match(exact_match)
-{
-}
+BreakpointResolverFileLine::BreakpointResolverFileLine(
+ Breakpoint *bkpt, const FileSpec &file_spec, uint32_t line_no,
+ lldb::addr_t offset, bool check_inlines, bool skip_prologue,
+ bool exact_match)
+ : BreakpointResolver(bkpt, BreakpointResolver::FileLineResolver, offset),
+ m_file_spec(file_spec), m_line_number(line_no), m_inlines(check_inlines),
+ m_skip_prologue(skip_prologue), m_exact_match(exact_match) {}
-BreakpointResolverFileLine::~BreakpointResolverFileLine ()
-{
-}
+BreakpointResolverFileLine::~BreakpointResolverFileLine() {}
Searcher::CallbackReturn
-BreakpointResolverFileLine::SearchCallback
-(
- SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool containing
-)
-{
- SymbolContextList sc_list;
-
- assert (m_breakpoint != NULL);
-
- // There is a tricky bit here. You can have two compilation units that #include the same file, and
- // in one of them the function at m_line_number is used (and so code and a line entry for it is generated) but in the
- // other it isn't. If we considered the CU's independently, then in the second inclusion, we'd move the breakpoint
- // to the next function that actually generated code in the header file. That would end up being confusing.
- // So instead, we do the CU iterations by hand here, then scan through the complete list of matches, and figure out
- // the closest line number match, and only set breakpoints on that match.
-
- // Note also that if file_spec only had a file name and not a directory, there may be many different file spec's in
- // the resultant list. The closest line match for one will not be right for some totally different file.
- // So we go through the match list and pull out the sets that have the same file spec in their line_entry
- // and treat each set separately.
-
- const size_t num_comp_units = context.module_sp->GetNumCompileUnits();
- for (size_t i = 0; i < num_comp_units; i++)
- {
- CompUnitSP cu_sp (context.module_sp->GetCompileUnitAtIndex (i));
- if (cu_sp)
- {
- if (filter.CompUnitPasses(*cu_sp))
- cu_sp->ResolveSymbolContext (m_file_spec, m_line_number, m_inlines, m_exact_match, eSymbolContextEverything, sc_list);
- }
+BreakpointResolverFileLine::SearchCallback(SearchFilter &filter,
+ SymbolContext &context,
+ Address *addr, bool containing) {
+ SymbolContextList sc_list;
+
+ assert(m_breakpoint != NULL);
+
+ // There is a tricky bit here. You can have two compilation units that
+ // #include the same file, and
+ // in one of them the function at m_line_number is used (and so code and a
+ // line entry for it is generated) but in the
+ // other it isn't. If we considered the CU's independently, then in the
+ // second inclusion, we'd move the breakpoint
+ // to the next function that actually generated code in the header file. That
+ // would end up being confusing.
+ // So instead, we do the CU iterations by hand here, then scan through the
+ // complete list of matches, and figure out
+ // the closest line number match, and only set breakpoints on that match.
+
+ // Note also that if file_spec only had a file name and not a directory, there
+ // may be many different file spec's in
+ // the resultant list. The closest line match for one will not be right for
+ // some totally different file.
+ // So we go through the match list and pull out the sets that have the same
+ // file spec in their line_entry
+ // and treat each set separately.
+
+ const size_t num_comp_units = context.module_sp->GetNumCompileUnits();
+ for (size_t i = 0; i < num_comp_units; i++) {
+ CompUnitSP cu_sp(context.module_sp->GetCompileUnitAtIndex(i));
+ if (cu_sp) {
+ if (filter.CompUnitPasses(*cu_sp))
+ cu_sp->ResolveSymbolContext(m_file_spec, m_line_number, m_inlines,
+ m_exact_match, eSymbolContextEverything,
+ sc_list);
}
- StreamString s;
- s.Printf ("for %s:%d ",
- m_file_spec.GetFilename().AsCString("<Unknown>"),
- m_line_number);
+ }
+ StreamString s;
+ s.Printf("for %s:%d ", m_file_spec.GetFilename().AsCString("<Unknown>"),
+ m_line_number);
- SetSCMatchesByLine (filter, sc_list, m_skip_prologue, s.GetData());
+ SetSCMatchesByLine(filter, sc_list, m_skip_prologue, s.GetData());
- return Searcher::eCallbackReturnContinue;
+ return Searcher::eCallbackReturnContinue;
}
-Searcher::Depth
-BreakpointResolverFileLine::GetDepth()
-{
- return Searcher::eDepthModule;
+Searcher::Depth BreakpointResolverFileLine::GetDepth() {
+ return Searcher::eDepthModule;
}
-void
-BreakpointResolverFileLine::GetDescription (Stream *s)
-{
- s->Printf ("file = '%s', line = %u, exact_match = %d", m_file_spec.GetPath().c_str(), m_line_number, m_exact_match);
+void BreakpointResolverFileLine::GetDescription(Stream *s) {
+ s->Printf("file = '%s', line = %u, exact_match = %d",
+ m_file_spec.GetPath().c_str(), m_line_number, m_exact_match);
}
-void
-BreakpointResolverFileLine::Dump (Stream *s) const
-{
-
-}
+void BreakpointResolverFileLine::Dump(Stream *s) const {}
lldb::BreakpointResolverSP
-BreakpointResolverFileLine::CopyForBreakpoint (Breakpoint &breakpoint)
-{
- lldb::BreakpointResolverSP ret_sp(new BreakpointResolverFileLine(&breakpoint,
- m_file_spec,
- m_line_number,
- m_offset,
- m_inlines,
- m_skip_prologue,
- m_exact_match));
-
- return ret_sp;
+BreakpointResolverFileLine::CopyForBreakpoint(Breakpoint &breakpoint) {
+ lldb::BreakpointResolverSP ret_sp(new BreakpointResolverFileLine(
+ &breakpoint, m_file_spec, m_line_number, m_offset, m_inlines,
+ m_skip_prologue, m_exact_match));
+
+ return ret_sp;
}
diff --git a/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp b/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
index ae7f58a..8d08908 100644
--- a/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
@@ -1,4 +1,5 @@
-//===-- BreakpointResolverFileRegex.cpp --------------------------*- C++ -*-===//
+//===-- BreakpointResolverFileRegex.cpp --------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,8 +15,8 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Breakpoint/BreakpointLocation.h"
-#include "lldb/Core/SourceManager.h"
#include "lldb/Core/Log.h"
+#include "lldb/Core/SourceManager.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Target/Target.h"
@@ -26,113 +27,90 @@ using namespace lldb_private;
//----------------------------------------------------------------------
// BreakpointResolverFileRegex:
//----------------------------------------------------------------------
-BreakpointResolverFileRegex::BreakpointResolverFileRegex
-(
- Breakpoint *bkpt,
- RegularExpression &regex,
- const std::unordered_set<std::string> &func_names,
- bool exact_match
-) :
- BreakpointResolver (bkpt, BreakpointResolver::FileLineResolver),
- m_regex (regex),
- m_exact_match (exact_match),
- m_function_names(func_names)
-{
+BreakpointResolverFileRegex::BreakpointResolverFileRegex(
+ Breakpoint *bkpt, RegularExpression &regex,
+ const std::unordered_set<std::string> &func_names, bool exact_match)
+ : BreakpointResolver(bkpt, BreakpointResolver::FileLineResolver),
+ m_regex(regex), m_exact_match(exact_match), m_function_names(func_names) {
}
-BreakpointResolverFileRegex::~BreakpointResolverFileRegex ()
-{
-}
+BreakpointResolverFileRegex::~BreakpointResolverFileRegex() {}
Searcher::CallbackReturn
-BreakpointResolverFileRegex::SearchCallback
-(
- SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool containing
-)
-{
-
- assert (m_breakpoint != NULL);
- if (!context.target_sp)
- return eCallbackReturnContinue;
-
- CompileUnit *cu = context.comp_unit;
- FileSpec cu_file_spec = *(static_cast<FileSpec *>(cu));
- std::vector<uint32_t> line_matches;
- context.target_sp->GetSourceManager().FindLinesMatchingRegex(cu_file_spec, m_regex, 1, UINT32_MAX, line_matches);
-
- uint32_t num_matches = line_matches.size();
- for (uint32_t i = 0; i < num_matches; i++)
- {
- SymbolContextList sc_list;
- const bool search_inlines = false;
-
- cu->ResolveSymbolContext (cu_file_spec, line_matches[i], search_inlines, m_exact_match, eSymbolContextEverything, sc_list);
- // Find all the function names:
- if (!m_function_names.empty())
- {
- std::vector<size_t> sc_to_remove;
- for (size_t i = 0; i < sc_list.GetSize(); i++)
- {
- SymbolContext sc_ctx;
- sc_list.GetContextAtIndex(i, sc_ctx);
- std::string name(sc_ctx.GetFunctionName(Mangled::NamePreference::ePreferDemangledWithoutArguments).AsCString());
- if (!m_function_names.count(name))
- {
- sc_to_remove.push_back(i);
- }
- }
-
- if (!sc_to_remove.empty())
- {
- std::vector<size_t>::reverse_iterator iter;
- std::vector<size_t>::reverse_iterator rend = sc_to_remove.rend();
- for (iter = sc_to_remove.rbegin(); iter != rend; iter++)
- {
- sc_list.RemoveContextAtIndex(*iter);
- }
- }
+BreakpointResolverFileRegex::SearchCallback(SearchFilter &filter,
+ SymbolContext &context,
+ Address *addr, bool containing) {
+
+ assert(m_breakpoint != NULL);
+ if (!context.target_sp)
+ return eCallbackReturnContinue;
+
+ CompileUnit *cu = context.comp_unit;
+ FileSpec cu_file_spec = *(static_cast<FileSpec *>(cu));
+ std::vector<uint32_t> line_matches;
+ context.target_sp->GetSourceManager().FindLinesMatchingRegex(
+ cu_file_spec, m_regex, 1, UINT32_MAX, line_matches);
+
+ uint32_t num_matches = line_matches.size();
+ for (uint32_t i = 0; i < num_matches; i++) {
+ SymbolContextList sc_list;
+ const bool search_inlines = false;
+
+ cu->ResolveSymbolContext(cu_file_spec, line_matches[i], search_inlines,
+ m_exact_match, eSymbolContextEverything, sc_list);
+ // Find all the function names:
+ if (!m_function_names.empty()) {
+ std::vector<size_t> sc_to_remove;
+ for (size_t i = 0; i < sc_list.GetSize(); i++) {
+ SymbolContext sc_ctx;
+ sc_list.GetContextAtIndex(i, sc_ctx);
+ std::string name(
+ sc_ctx
+ .GetFunctionName(
+ Mangled::NamePreference::ePreferDemangledWithoutArguments)
+ .AsCString());
+ if (!m_function_names.count(name)) {
+ sc_to_remove.push_back(i);
+ }
+ }
+
+ if (!sc_to_remove.empty()) {
+ std::vector<size_t>::reverse_iterator iter;
+ std::vector<size_t>::reverse_iterator rend = sc_to_remove.rend();
+ for (iter = sc_to_remove.rbegin(); iter != rend; iter++) {
+ sc_list.RemoveContextAtIndex(*iter);
}
-
- const bool skip_prologue = true;
-
- BreakpointResolver::SetSCMatchesByLine (filter, sc_list, skip_prologue, m_regex.GetText());
+ }
}
- assert (m_breakpoint != NULL);
- return Searcher::eCallbackReturnContinue;
-}
+ const bool skip_prologue = true;
-Searcher::Depth
-BreakpointResolverFileRegex::GetDepth()
-{
- return Searcher::eDepthCompUnit;
-}
+ BreakpointResolver::SetSCMatchesByLine(filter, sc_list, skip_prologue,
+ m_regex.GetText());
+ }
+ assert(m_breakpoint != NULL);
-void
-BreakpointResolverFileRegex::GetDescription (Stream *s)
-{
- s->Printf ("source regex = \"%s\", exact_match = %d", m_regex.GetText(), m_exact_match);
+ return Searcher::eCallbackReturnContinue;
}
-void
-BreakpointResolverFileRegex::Dump (Stream *s) const
-{
+Searcher::Depth BreakpointResolverFileRegex::GetDepth() {
+ return Searcher::eDepthCompUnit;
+}
+void BreakpointResolverFileRegex::GetDescription(Stream *s) {
+ s->Printf("source regex = \"%s\", exact_match = %d", m_regex.GetText(),
+ m_exact_match);
}
+void BreakpointResolverFileRegex::Dump(Stream *s) const {}
+
lldb::BreakpointResolverSP
-BreakpointResolverFileRegex::CopyForBreakpoint (Breakpoint &breakpoint)
-{
- lldb::BreakpointResolverSP ret_sp(new BreakpointResolverFileRegex(&breakpoint, m_regex, m_function_names, m_exact_match));
- return ret_sp;
+BreakpointResolverFileRegex::CopyForBreakpoint(Breakpoint &breakpoint) {
+ lldb::BreakpointResolverSP ret_sp(new BreakpointResolverFileRegex(
+ &breakpoint, m_regex, m_function_names, m_exact_match));
+ return ret_sp;
}
-void
-BreakpointResolverFileRegex::AddFunctionName(const char *func_name)
-{
- m_function_names.insert(func_name);
+void BreakpointResolverFileRegex::AddFunctionName(const char *func_name) {
+ m_function_names.insert(func_name);
}
-
diff --git a/lldb/source/Breakpoint/BreakpointResolverName.cpp b/lldb/source/Breakpoint/BreakpointResolverName.cpp
index dfa09c2..64d0318 100644
--- a/lldb/source/Breakpoint/BreakpointResolverName.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverName.cpp
@@ -13,6 +13,8 @@
// Project includes
#include "lldb/Breakpoint/BreakpointResolverName.h"
+#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
+#include "Plugins/Language/ObjC/ObjCLanguage.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
@@ -21,372 +23,288 @@
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/SymbolContext.h"
-#include "Plugins/Language/ObjC/ObjCLanguage.h"
-#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
using namespace lldb;
using namespace lldb_private;
-BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt,
- const char *name_cstr,
- uint32_t name_type_mask,
- LanguageType language,
- Breakpoint::MatchType type,
- lldb::addr_t offset,
- bool skip_prologue) :
- BreakpointResolver (bkpt, BreakpointResolver::NameResolver, offset),
- m_class_name (),
- m_regex (),
- m_match_type (type),
- m_language (language),
- m_skip_prologue (skip_prologue)
-{
- if (m_match_type == Breakpoint::Regexp)
- {
- if (!m_regex.Compile (name_cstr))
- {
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
-
- if (log)
- log->Warning ("function name regexp: \"%s\" did not compile.", name_cstr);
- }
- }
- else
- {
- AddNameLookup (ConstString(name_cstr), name_type_mask);
- }
-}
+BreakpointResolverName::BreakpointResolverName(
+ Breakpoint *bkpt, const char *name_cstr, uint32_t name_type_mask,
+ LanguageType language, Breakpoint::MatchType type, lldb::addr_t offset,
+ bool skip_prologue)
+ : BreakpointResolver(bkpt, BreakpointResolver::NameResolver, offset),
+ m_class_name(), m_regex(), m_match_type(type), m_language(language),
+ m_skip_prologue(skip_prologue) {
+ if (m_match_type == Breakpoint::Regexp) {
+ if (!m_regex.Compile(name_cstr)) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
-BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt,
- const char *names[],
- size_t num_names,
- uint32_t name_type_mask,
- LanguageType language,
- lldb::addr_t offset,
- bool skip_prologue) :
- BreakpointResolver (bkpt, BreakpointResolver::NameResolver, offset),
- m_match_type (Breakpoint::Exact),
- m_language (language),
- m_skip_prologue (skip_prologue)
-{
- for (size_t i = 0; i < num_names; i++)
- {
- AddNameLookup (ConstString (names[i]), name_type_mask);
+ if (log)
+ log->Warning("function name regexp: \"%s\" did not compile.",
+ name_cstr);
}
+ } else {
+ AddNameLookup(ConstString(name_cstr), name_type_mask);
+ }
}
-BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt,
- std::vector<std::string> names,
- uint32_t name_type_mask,
- LanguageType language,
- lldb::addr_t offset,
- bool skip_prologue) :
- BreakpointResolver (bkpt, BreakpointResolver::NameResolver, offset),
- m_match_type (Breakpoint::Exact),
- m_language (language),
- m_skip_prologue (skip_prologue)
-{
- for (const std::string& name : names)
- {
- AddNameLookup (ConstString (name.c_str(), name.size()), name_type_mask);
- }
+BreakpointResolverName::BreakpointResolverName(
+ Breakpoint *bkpt, const char *names[], size_t num_names,
+ uint32_t name_type_mask, LanguageType language, lldb::addr_t offset,
+ bool skip_prologue)
+ : BreakpointResolver(bkpt, BreakpointResolver::NameResolver, offset),
+ m_match_type(Breakpoint::Exact), m_language(language),
+ m_skip_prologue(skip_prologue) {
+ for (size_t i = 0; i < num_names; i++) {
+ AddNameLookup(ConstString(names[i]), name_type_mask);
+ }
}
-BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt,
- RegularExpression &func_regex,
- lldb::LanguageType language,
- lldb::addr_t offset,
- bool skip_prologue) :
- BreakpointResolver (bkpt, BreakpointResolver::NameResolver, offset),
- m_class_name (nullptr),
- m_regex (func_regex),
- m_match_type (Breakpoint::Regexp),
- m_language (language),
- m_skip_prologue (skip_prologue)
-{
+BreakpointResolverName::BreakpointResolverName(
+ Breakpoint *bkpt, std::vector<std::string> names, uint32_t name_type_mask,
+ LanguageType language, lldb::addr_t offset, bool skip_prologue)
+ : BreakpointResolver(bkpt, BreakpointResolver::NameResolver, offset),
+ m_match_type(Breakpoint::Exact), m_language(language),
+ m_skip_prologue(skip_prologue) {
+ for (const std::string &name : names) {
+ AddNameLookup(ConstString(name.c_str(), name.size()), name_type_mask);
+ }
}
-BreakpointResolverName::BreakpointResolverName
-(
- Breakpoint *bkpt,
- const char *class_name,
- const char *method,
- Breakpoint::MatchType type,
- lldb::addr_t offset,
- bool skip_prologue
-) :
- BreakpointResolver (bkpt, BreakpointResolver::NameResolver, offset),
- m_class_name (class_name),
- m_regex (),
- m_match_type (type),
- m_language (eLanguageTypeUnknown),
- m_skip_prologue (skip_prologue)
-{
- Module::LookupInfo lookup;
- lookup.SetName(ConstString(method));
- lookup.SetLookupName(lookup.GetName());
- lookup.SetNameTypeMask(eFunctionNameTypeMethod);
- m_lookups.push_back (lookup);
+BreakpointResolverName::BreakpointResolverName(Breakpoint *bkpt,
+ RegularExpression &func_regex,
+ lldb::LanguageType language,
+ lldb::addr_t offset,
+ bool skip_prologue)
+ : BreakpointResolver(bkpt, BreakpointResolver::NameResolver, offset),
+ m_class_name(nullptr), m_regex(func_regex),
+ m_match_type(Breakpoint::Regexp), m_language(language),
+ m_skip_prologue(skip_prologue) {}
+
+BreakpointResolverName::BreakpointResolverName(
+ Breakpoint *bkpt, const char *class_name, const char *method,
+ Breakpoint::MatchType type, lldb::addr_t offset, bool skip_prologue)
+ : BreakpointResolver(bkpt, BreakpointResolver::NameResolver, offset),
+ m_class_name(class_name), m_regex(), m_match_type(type),
+ m_language(eLanguageTypeUnknown), m_skip_prologue(skip_prologue) {
+ Module::LookupInfo lookup;
+ lookup.SetName(ConstString(method));
+ lookup.SetLookupName(lookup.GetName());
+ lookup.SetNameTypeMask(eFunctionNameTypeMethod);
+ m_lookups.push_back(lookup);
}
BreakpointResolverName::~BreakpointResolverName() = default;
-BreakpointResolverName::BreakpointResolverName(const BreakpointResolverName &rhs) :
- BreakpointResolver(rhs.m_breakpoint, BreakpointResolver::NameResolver, rhs.m_offset),
- m_lookups(rhs.m_lookups),
- m_class_name(rhs.m_class_name),
- m_regex(rhs.m_regex),
- m_match_type (rhs.m_match_type),
- m_language (rhs.m_language),
- m_skip_prologue (rhs.m_skip_prologue)
-{
-}
+BreakpointResolverName::BreakpointResolverName(
+ const BreakpointResolverName &rhs)
+ : BreakpointResolver(rhs.m_breakpoint, BreakpointResolver::NameResolver,
+ rhs.m_offset),
+ m_lookups(rhs.m_lookups), m_class_name(rhs.m_class_name),
+ m_regex(rhs.m_regex), m_match_type(rhs.m_match_type),
+ m_language(rhs.m_language), m_skip_prologue(rhs.m_skip_prologue) {}
-void
-BreakpointResolverName::AddNameLookup (const ConstString &name, uint32_t name_type_mask)
-{
- ObjCLanguage::MethodName objc_method(name.GetCString(), false);
- if (objc_method.IsValid(false))
- {
- std::vector<ConstString> objc_names;
- objc_method.GetFullNames(objc_names, true);
- for (ConstString objc_name : objc_names)
- {
- Module::LookupInfo lookup;
- lookup.SetName(name);
- lookup.SetLookupName(objc_name);
- lookup.SetNameTypeMask(eFunctionNameTypeFull);
- m_lookups.push_back (lookup);
- }
- }
- else
- {
- Module::LookupInfo lookup(name, name_type_mask, m_language);
- m_lookups.push_back (lookup);
+void BreakpointResolverName::AddNameLookup(const ConstString &name,
+ uint32_t name_type_mask) {
+ ObjCLanguage::MethodName objc_method(name.GetCString(), false);
+ if (objc_method.IsValid(false)) {
+ std::vector<ConstString> objc_names;
+ objc_method.GetFullNames(objc_names, true);
+ for (ConstString objc_name : objc_names) {
+ Module::LookupInfo lookup;
+ lookup.SetName(name);
+ lookup.SetLookupName(objc_name);
+ lookup.SetNameTypeMask(eFunctionNameTypeFull);
+ m_lookups.push_back(lookup);
}
+ } else {
+ Module::LookupInfo lookup(name, name_type_mask, m_language);
+ m_lookups.push_back(lookup);
+ }
}
-// FIXME: Right now we look at the module level, and call the module's "FindFunctions".
-// Greg says he will add function tables, maybe at the CompileUnit level to accelerate function
-// lookup. At that point, we should switch the depth to CompileUnit, and look in these tables.
+// FIXME: Right now we look at the module level, and call the module's
+// "FindFunctions".
+// Greg says he will add function tables, maybe at the CompileUnit level to
+// accelerate function
+// lookup. At that point, we should switch the depth to CompileUnit, and look
+// in these tables.
Searcher::CallbackReturn
BreakpointResolverName::SearchCallback(SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool containing)
-{
- SymbolContextList func_list;
- //SymbolContextList sym_list;
-
- uint32_t i;
- bool new_location;
- Address break_addr;
- assert (m_breakpoint != nullptr);
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
-
- if (m_class_name)
- {
- if (log)
- log->Warning ("Class/method function specification not supported yet.\n");
- return Searcher::eCallbackReturnStop;
+ SymbolContext &context, Address *addr,
+ bool containing) {
+ SymbolContextList func_list;
+ // SymbolContextList sym_list;
+
+ uint32_t i;
+ bool new_location;
+ Address break_addr;
+ assert(m_breakpoint != nullptr);
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+
+ if (m_class_name) {
+ if (log)
+ log->Warning("Class/method function specification not supported yet.\n");
+ return Searcher::eCallbackReturnStop;
+ }
+ bool filter_by_cu =
+ (filter.GetFilterRequiredItems() & eSymbolContextCompUnit) != 0;
+ bool filter_by_language = (m_language != eLanguageTypeUnknown);
+ const bool include_symbols = !filter_by_cu;
+ const bool include_inlines = true;
+ const bool append = true;
+
+ switch (m_match_type) {
+ case Breakpoint::Exact:
+ if (context.module_sp) {
+ for (const auto &lookup : m_lookups) {
+ const size_t start_func_idx = func_list.GetSize();
+ context.module_sp->FindFunctions(
+ lookup.GetLookupName(), nullptr, lookup.GetNameTypeMask(),
+ include_symbols, include_inlines, append, func_list);
+
+ const size_t end_func_idx = func_list.GetSize();
+
+ if (start_func_idx < end_func_idx)
+ lookup.Prune(func_list, start_func_idx);
+ }
}
- bool filter_by_cu = (filter.GetFilterRequiredItems() & eSymbolContextCompUnit) != 0;
- bool filter_by_language = (m_language != eLanguageTypeUnknown);
- const bool include_symbols = !filter_by_cu;
- const bool include_inlines = true;
- const bool append = true;
-
- switch (m_match_type)
- {
- case Breakpoint::Exact:
- if (context.module_sp)
- {
- for (const auto &lookup : m_lookups)
- {
- const size_t start_func_idx = func_list.GetSize();
- context.module_sp->FindFunctions(lookup.GetLookupName(),
- nullptr,
- lookup.GetNameTypeMask(),
- include_symbols,
- include_inlines,
- append,
- func_list);
-
- const size_t end_func_idx = func_list.GetSize();
-
- if (start_func_idx < end_func_idx)
- lookup.Prune (func_list, start_func_idx);
- }
- }
- break;
- case Breakpoint::Regexp:
- if (context.module_sp)
- {
- context.module_sp->FindFunctions (m_regex,
- !filter_by_cu, // include symbols only if we aren't filtering by CU
- include_inlines,
- append,
- func_list);
- }
- break;
- case Breakpoint::Glob:
- if (log)
- log->Warning ("glob is not supported yet.");
- break;
+ break;
+ case Breakpoint::Regexp:
+ if (context.module_sp) {
+ context.module_sp->FindFunctions(
+ m_regex,
+ !filter_by_cu, // include symbols only if we aren't filtering by CU
+ include_inlines, append, func_list);
}
+ break;
+ case Breakpoint::Glob:
+ if (log)
+ log->Warning("glob is not supported yet.");
+ break;
+ }
- // If the filter specifies a Compilation Unit, remove the ones that don't pass at this point.
- if (filter_by_cu || filter_by_language)
- {
- uint32_t num_functions = func_list.GetSize();
-
- for (size_t idx = 0; idx < num_functions; idx++)
- {
- bool remove_it = false;
- SymbolContext sc;
- func_list.GetContextAtIndex(idx, sc);
- if (filter_by_cu)
- {
- if (!sc.comp_unit || !filter.CompUnitPasses(*sc.comp_unit))
- remove_it = true;
- }
-
- if (filter_by_language)
- {
- LanguageType sym_language = sc.GetLanguage();
- if ((Language::GetPrimaryLanguage(sym_language) !=
- Language::GetPrimaryLanguage(m_language)) &&
- (sym_language != eLanguageTypeUnknown))
- {
- remove_it = true;
- }
- }
-
- if (remove_it)
- {
- func_list.RemoveContextAtIndex(idx);
- num_functions--;
- idx--;
- }
+ // If the filter specifies a Compilation Unit, remove the ones that don't pass
+ // at this point.
+ if (filter_by_cu || filter_by_language) {
+ uint32_t num_functions = func_list.GetSize();
+
+ for (size_t idx = 0; idx < num_functions; idx++) {
+ bool remove_it = false;
+ SymbolContext sc;
+ func_list.GetContextAtIndex(idx, sc);
+ if (filter_by_cu) {
+ if (!sc.comp_unit || !filter.CompUnitPasses(*sc.comp_unit))
+ remove_it = true;
+ }
+
+ if (filter_by_language) {
+ LanguageType sym_language = sc.GetLanguage();
+ if ((Language::GetPrimaryLanguage(sym_language) !=
+ Language::GetPrimaryLanguage(m_language)) &&
+ (sym_language != eLanguageTypeUnknown)) {
+ remove_it = true;
}
+ }
+
+ if (remove_it) {
+ func_list.RemoveContextAtIndex(idx);
+ num_functions--;
+ idx--;
+ }
}
+ }
+
+ // Remove any duplicates between the function list and the symbol list
+ SymbolContext sc;
+ if (func_list.GetSize()) {
+ for (i = 0; i < func_list.GetSize(); i++) {
+ if (func_list.GetContextAtIndex(i, sc)) {
+ bool is_reexported = false;
- // Remove any duplicates between the function list and the symbol list
- SymbolContext sc;
- if (func_list.GetSize())
- {
- for (i = 0; i < func_list.GetSize(); i++)
- {
- if (func_list.GetContextAtIndex(i, sc))
- {
- bool is_reexported = false;
-
- if (sc.block && sc.block->GetInlinedFunctionInfo())
- {
- if (!sc.block->GetStartAddress(break_addr))
- break_addr.Clear();
- }
- else if (sc.function)
- {
- break_addr = sc.function->GetAddressRange().GetBaseAddress();
- if (m_skip_prologue && break_addr.IsValid())
- {
- const uint32_t prologue_byte_size = sc.function->GetPrologueByteSize();
- if (prologue_byte_size)
- break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size);
- }
- }
- else if (sc.symbol)
- {
- if (sc.symbol->GetType() == eSymbolTypeReExported)
- {
- const Symbol *actual_symbol = sc.symbol->ResolveReExportedSymbol(m_breakpoint->GetTarget());
- if (actual_symbol)
- {
- is_reexported = true;
- break_addr = actual_symbol->GetAddress();
- }
- }
- else
- {
- break_addr = sc.symbol->GetAddress();
- }
-
- if (m_skip_prologue && break_addr.IsValid())
- {
- const uint32_t prologue_byte_size = sc.symbol->GetPrologueByteSize();
- if (prologue_byte_size)
- break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size);
- }
- }
-
- if (break_addr.IsValid())
- {
- if (filter.AddressPasses(break_addr))
- {
- BreakpointLocationSP bp_loc_sp (AddLocation(break_addr, &new_location));
- bp_loc_sp->SetIsReExported(is_reexported);
- if (bp_loc_sp && new_location && !m_breakpoint->IsInternal())
- {
- if (log)
- {
- StreamString s;
- bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
- log->Printf ("Added location: %s\n", s.GetData());
- }
- }
- }
- }
+ if (sc.block && sc.block->GetInlinedFunctionInfo()) {
+ if (!sc.block->GetStartAddress(break_addr))
+ break_addr.Clear();
+ } else if (sc.function) {
+ break_addr = sc.function->GetAddressRange().GetBaseAddress();
+ if (m_skip_prologue && break_addr.IsValid()) {
+ const uint32_t prologue_byte_size =
+ sc.function->GetPrologueByteSize();
+ if (prologue_byte_size)
+ break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size);
+ }
+ } else if (sc.symbol) {
+ if (sc.symbol->GetType() == eSymbolTypeReExported) {
+ const Symbol *actual_symbol =
+ sc.symbol->ResolveReExportedSymbol(m_breakpoint->GetTarget());
+ if (actual_symbol) {
+ is_reexported = true;
+ break_addr = actual_symbol->GetAddress();
}
+ } else {
+ break_addr = sc.symbol->GetAddress();
+ }
+
+ if (m_skip_prologue && break_addr.IsValid()) {
+ const uint32_t prologue_byte_size =
+ sc.symbol->GetPrologueByteSize();
+ if (prologue_byte_size)
+ break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size);
+ }
}
+
+ if (break_addr.IsValid()) {
+ if (filter.AddressPasses(break_addr)) {
+ BreakpointLocationSP bp_loc_sp(
+ AddLocation(break_addr, &new_location));
+ bp_loc_sp->SetIsReExported(is_reexported);
+ if (bp_loc_sp && new_location && !m_breakpoint->IsInternal()) {
+ if (log) {
+ StreamString s;
+ bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
+ log->Printf("Added location: %s\n", s.GetData());
+ }
+ }
+ }
+ }
+ }
}
-
- return Searcher::eCallbackReturnContinue;
+ }
+
+ return Searcher::eCallbackReturnContinue;
}
-Searcher::Depth
-BreakpointResolverName::GetDepth()
-{
- return Searcher::eDepthModule;
+Searcher::Depth BreakpointResolverName::GetDepth() {
+ return Searcher::eDepthModule;
}
-void
-BreakpointResolverName::GetDescription (Stream *s)
-{
- if (m_match_type == Breakpoint::Regexp)
- s->Printf("regex = '%s'", m_regex.GetText());
- else
- {
- size_t num_names = m_lookups.size();
- if (num_names == 1)
- s->Printf("name = '%s'", m_lookups[0].GetName().GetCString());
- else
- {
- s->Printf("names = {");
- for (size_t i = 0; i < num_names; i++)
- {
- s->Printf ("%s'%s'", (i == 0 ? "" : ", "), m_lookups[i].GetName().GetCString());
- }
- s->Printf ("}");
- }
- }
- if (m_language != eLanguageTypeUnknown)
- {
- s->Printf (", language = %s", Language::GetNameForLanguageType(m_language));
+void BreakpointResolverName::GetDescription(Stream *s) {
+ if (m_match_type == Breakpoint::Regexp)
+ s->Printf("regex = '%s'", m_regex.GetText());
+ else {
+ size_t num_names = m_lookups.size();
+ if (num_names == 1)
+ s->Printf("name = '%s'", m_lookups[0].GetName().GetCString());
+ else {
+ s->Printf("names = {");
+ for (size_t i = 0; i < num_names; i++) {
+ s->Printf("%s'%s'", (i == 0 ? "" : ", "),
+ m_lookups[i].GetName().GetCString());
+ }
+ s->Printf("}");
}
+ }
+ if (m_language != eLanguageTypeUnknown) {
+ s->Printf(", language = %s", Language::GetNameForLanguageType(m_language));
+ }
}
-void
-BreakpointResolverName::Dump (Stream *s) const
-{
-}
+void BreakpointResolverName::Dump(Stream *s) const {}
lldb::BreakpointResolverSP
-BreakpointResolverName::CopyForBreakpoint (Breakpoint &breakpoint)
-{
- lldb::BreakpointResolverSP ret_sp(new BreakpointResolverName(*this));
- ret_sp->SetBreakpoint(&breakpoint);
- return ret_sp;
+BreakpointResolverName::CopyForBreakpoint(Breakpoint &breakpoint) {
+ lldb::BreakpointResolverSP ret_sp(new BreakpointResolverName(*this));
+ ret_sp->SetBreakpoint(&breakpoint);
+ return ret_sp;
}
diff --git a/lldb/source/Breakpoint/BreakpointSite.cpp b/lldb/source/Breakpoint/BreakpointSite.cpp
index b4112f7..28ba37b 100644
--- a/lldb/source/Breakpoint/BreakpointSite.cpp
+++ b/lldb/source/Breakpoint/BreakpointSite.cpp
@@ -23,240 +23,181 @@
using namespace lldb;
using namespace lldb_private;
-BreakpointSite::BreakpointSite(BreakpointSiteList *list, const BreakpointLocationSP &owner, lldb::addr_t addr,
- bool use_hardware)
+BreakpointSite::BreakpointSite(BreakpointSiteList *list,
+ const BreakpointLocationSP &owner,
+ lldb::addr_t addr, bool use_hardware)
: StoppointLocation(GetNextID(), addr, 0, use_hardware),
- m_type(eSoftware), // Process subclasses need to set this correctly using SetType()
- m_saved_opcode(),
- m_trap_opcode(),
- m_enabled(false), // Need to create it disabled, so the first enable turns it on.
- m_owners(),
- m_owners_mutex()
-{
- m_owners.Add(owner);
+ m_type(eSoftware), // Process subclasses need to set this correctly using
+ // SetType()
+ m_saved_opcode(), m_trap_opcode(),
+ m_enabled(false), // Need to create it disabled, so the first enable turns
+ // it on.
+ m_owners(), m_owners_mutex() {
+ m_owners.Add(owner);
}
-BreakpointSite::~BreakpointSite()
-{
- BreakpointLocationSP bp_loc_sp;
- const size_t owner_count = m_owners.GetSize();
- for (size_t i = 0; i < owner_count; i++)
- {
- m_owners.GetByIndex(i)->ClearBreakpointSite();
- }
+BreakpointSite::~BreakpointSite() {
+ BreakpointLocationSP bp_loc_sp;
+ const size_t owner_count = m_owners.GetSize();
+ for (size_t i = 0; i < owner_count; i++) {
+ m_owners.GetByIndex(i)->ClearBreakpointSite();
+ }
}
-break_id_t
-BreakpointSite::GetNextID()
-{
- static break_id_t g_next_id = 0;
- return ++g_next_id;
+break_id_t BreakpointSite::GetNextID() {
+ static break_id_t g_next_id = 0;
+ return ++g_next_id;
}
// RETURNS - true if we should stop at this breakpoint, false if we
// should continue.
-bool
-BreakpointSite::ShouldStop (StoppointCallbackContext *context)
-{
- std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
- IncrementHitCount();
- return m_owners.ShouldStop (context);
+bool BreakpointSite::ShouldStop(StoppointCallbackContext *context) {
+ std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
+ IncrementHitCount();
+ return m_owners.ShouldStop(context);
}
-bool
-BreakpointSite::IsBreakpointAtThisSite (lldb::break_id_t bp_id)
-{
- std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
- const size_t owner_count = m_owners.GetSize();
- for (size_t i = 0; i < owner_count; i++)
- {
- if (m_owners.GetByIndex(i)->GetBreakpoint().GetID() == bp_id)
- return true;
- }
- return false;
+bool BreakpointSite::IsBreakpointAtThisSite(lldb::break_id_t bp_id) {
+ std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
+ const size_t owner_count = m_owners.GetSize();
+ for (size_t i = 0; i < owner_count; i++) {
+ if (m_owners.GetByIndex(i)->GetBreakpoint().GetID() == bp_id)
+ return true;
+ }
+ return false;
}
-void
-BreakpointSite::Dump(Stream *s) const
-{
- if (s == nullptr)
- return;
+void BreakpointSite::Dump(Stream *s) const {
+ if (s == nullptr)
+ return;
- s->Printf("BreakpointSite %u: addr = 0x%8.8" PRIx64 " type = %s breakpoint hw_index = %i hit_count = %-4u",
- GetID(),
- (uint64_t)m_addr,
- IsHardware() ? "hardware" : "software",
- GetHardwareIndex(),
- GetHitCount());
+ s->Printf("BreakpointSite %u: addr = 0x%8.8" PRIx64
+ " type = %s breakpoint hw_index = %i hit_count = %-4u",
+ GetID(), (uint64_t)m_addr, IsHardware() ? "hardware" : "software",
+ GetHardwareIndex(), GetHitCount());
}
-void
-BreakpointSite::GetDescription (Stream *s, lldb::DescriptionLevel level)
-{
- std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
- if (level != lldb::eDescriptionLevelBrief)
- s->Printf ("breakpoint site: %d at 0x%8.8" PRIx64, GetID(), GetLoadAddress());
- m_owners.GetDescription (s, level);
+void BreakpointSite::GetDescription(Stream *s, lldb::DescriptionLevel level) {
+ std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
+ if (level != lldb::eDescriptionLevelBrief)
+ s->Printf("breakpoint site: %d at 0x%8.8" PRIx64, GetID(),
+ GetLoadAddress());
+ m_owners.GetDescription(s, level);
}
-bool
-BreakpointSite::IsInternal() const
-{
- return m_owners.IsInternal();
-}
+bool BreakpointSite::IsInternal() const { return m_owners.IsInternal(); }
-uint8_t *
-BreakpointSite::GetTrapOpcodeBytes()
-{
- return &m_trap_opcode[0];
-}
+uint8_t *BreakpointSite::GetTrapOpcodeBytes() { return &m_trap_opcode[0]; }
-const uint8_t *
-BreakpointSite::GetTrapOpcodeBytes() const
-{
- return &m_trap_opcode[0];
+const uint8_t *BreakpointSite::GetTrapOpcodeBytes() const {
+ return &m_trap_opcode[0];
}
-size_t
-BreakpointSite::GetTrapOpcodeMaxByteSize() const
-{
- return sizeof(m_trap_opcode);
+size_t BreakpointSite::GetTrapOpcodeMaxByteSize() const {
+ return sizeof(m_trap_opcode);
}
-bool
-BreakpointSite::SetTrapOpcode (const uint8_t *trap_opcode, uint32_t trap_opcode_size)
-{
- if (trap_opcode_size > 0 && trap_opcode_size <= sizeof(m_trap_opcode))
- {
- m_byte_size = trap_opcode_size;
- ::memcpy (m_trap_opcode, trap_opcode, trap_opcode_size);
- return true;
- }
- m_byte_size = 0;
- return false;
+bool BreakpointSite::SetTrapOpcode(const uint8_t *trap_opcode,
+ uint32_t trap_opcode_size) {
+ if (trap_opcode_size > 0 && trap_opcode_size <= sizeof(m_trap_opcode)) {
+ m_byte_size = trap_opcode_size;
+ ::memcpy(m_trap_opcode, trap_opcode, trap_opcode_size);
+ return true;
+ }
+ m_byte_size = 0;
+ return false;
}
-uint8_t *
-BreakpointSite::GetSavedOpcodeBytes()
-{
- return &m_saved_opcode[0];
-}
+uint8_t *BreakpointSite::GetSavedOpcodeBytes() { return &m_saved_opcode[0]; }
-const uint8_t *
-BreakpointSite::GetSavedOpcodeBytes() const
-{
- return &m_saved_opcode[0];
+const uint8_t *BreakpointSite::GetSavedOpcodeBytes() const {
+ return &m_saved_opcode[0];
}
-bool
-BreakpointSite::IsEnabled () const
-{
- return m_enabled;
-}
+bool BreakpointSite::IsEnabled() const { return m_enabled; }
-void
-BreakpointSite::SetEnabled (bool enabled)
-{
- m_enabled = enabled;
-}
+void BreakpointSite::SetEnabled(bool enabled) { m_enabled = enabled; }
-void
-BreakpointSite::AddOwner (const BreakpointLocationSP &owner)
-{
- std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
- m_owners.Add(owner);
+void BreakpointSite::AddOwner(const BreakpointLocationSP &owner) {
+ std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
+ m_owners.Add(owner);
}
-size_t
-BreakpointSite::RemoveOwner (lldb::break_id_t break_id, lldb::break_id_t break_loc_id)
-{
- std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
- m_owners.Remove(break_id, break_loc_id);
- return m_owners.GetSize();
+size_t BreakpointSite::RemoveOwner(lldb::break_id_t break_id,
+ lldb::break_id_t break_loc_id) {
+ std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
+ m_owners.Remove(break_id, break_loc_id);
+ return m_owners.GetSize();
}
-size_t
-BreakpointSite::GetNumberOfOwners ()
-{
- std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
- return m_owners.GetSize();
+size_t BreakpointSite::GetNumberOfOwners() {
+ std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
+ return m_owners.GetSize();
}
-BreakpointLocationSP
-BreakpointSite::GetOwnerAtIndex (size_t index)
-{
- std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
- return m_owners.GetByIndex (index);
+BreakpointLocationSP BreakpointSite::GetOwnerAtIndex(size_t index) {
+ std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
+ return m_owners.GetByIndex(index);
}
-bool
-BreakpointSite::ValidForThisThread (Thread *thread)
-{
- std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
- return m_owners.ValidForThisThread(thread);
+bool BreakpointSite::ValidForThisThread(Thread *thread) {
+ std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
+ return m_owners.ValidForThisThread(thread);
}
-void
-BreakpointSite::BumpHitCounts()
-{
- std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
- for (BreakpointLocationSP loc_sp : m_owners.BreakpointLocations())
- {
- loc_sp->BumpHitCount();
- }
+void BreakpointSite::BumpHitCounts() {
+ std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
+ for (BreakpointLocationSP loc_sp : m_owners.BreakpointLocations()) {
+ loc_sp->BumpHitCount();
+ }
}
-bool
-BreakpointSite::IntersectsRange(lldb::addr_t addr, size_t size, lldb::addr_t *intersect_addr, size_t *intersect_size, size_t *opcode_offset) const
-{
- // We only use software traps for software breakpoints
- if (!IsHardware())
- {
- if (m_byte_size > 0)
- {
- const lldb::addr_t bp_end_addr = m_addr + m_byte_size;
- const lldb::addr_t end_addr = addr + size;
- // Is the breakpoint end address before the passed in start address?
- if (bp_end_addr <= addr)
- return false;
- // Is the breakpoint start address after passed in end address?
- if (end_addr <= m_addr)
- return false;
- if (intersect_addr || intersect_size || opcode_offset)
- {
- if (m_addr < addr)
- {
- if (intersect_addr)
- *intersect_addr = addr;
- if (intersect_size)
- *intersect_size = std::min<lldb::addr_t>(bp_end_addr, end_addr) - addr;
- if (opcode_offset)
- *opcode_offset = addr - m_addr;
- }
- else
- {
- if (intersect_addr)
- *intersect_addr = m_addr;
- if (intersect_size)
- *intersect_size = std::min<lldb::addr_t>(bp_end_addr, end_addr) - m_addr;
- if (opcode_offset)
- *opcode_offset = 0;
- }
- }
- return true;
+bool BreakpointSite::IntersectsRange(lldb::addr_t addr, size_t size,
+ lldb::addr_t *intersect_addr,
+ size_t *intersect_size,
+ size_t *opcode_offset) const {
+ // We only use software traps for software breakpoints
+ if (!IsHardware()) {
+ if (m_byte_size > 0) {
+ const lldb::addr_t bp_end_addr = m_addr + m_byte_size;
+ const lldb::addr_t end_addr = addr + size;
+ // Is the breakpoint end address before the passed in start address?
+ if (bp_end_addr <= addr)
+ return false;
+ // Is the breakpoint start address after passed in end address?
+ if (end_addr <= m_addr)
+ return false;
+ if (intersect_addr || intersect_size || opcode_offset) {
+ if (m_addr < addr) {
+ if (intersect_addr)
+ *intersect_addr = addr;
+ if (intersect_size)
+ *intersect_size =
+ std::min<lldb::addr_t>(bp_end_addr, end_addr) - addr;
+ if (opcode_offset)
+ *opcode_offset = addr - m_addr;
+ } else {
+ if (intersect_addr)
+ *intersect_addr = m_addr;
+ if (intersect_size)
+ *intersect_size =
+ std::min<lldb::addr_t>(bp_end_addr, end_addr) - m_addr;
+ if (opcode_offset)
+ *opcode_offset = 0;
}
+ }
+ return true;
}
- return false;
+ }
+ return false;
}
size_t
-BreakpointSite::CopyOwnersList (BreakpointLocationCollection &out_collection)
-{
- std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
- for (BreakpointLocationSP loc_sp : m_owners.BreakpointLocations())
- {
- out_collection.Add(loc_sp);
- }
- return out_collection.GetSize();
+BreakpointSite::CopyOwnersList(BreakpointLocationCollection &out_collection) {
+ std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
+ for (BreakpointLocationSP loc_sp : m_owners.BreakpointLocations()) {
+ out_collection.Add(loc_sp);
+ }
+ return out_collection.GetSize();
}
diff --git a/lldb/source/Breakpoint/BreakpointSiteList.cpp b/lldb/source/Breakpoint/BreakpointSiteList.cpp
index de9a5ad..06155ee 100644
--- a/lldb/source/Breakpoint/BreakpointSiteList.cpp
+++ b/lldb/source/Breakpoint/BreakpointSiteList.cpp
@@ -19,220 +19,188 @@
using namespace lldb;
using namespace lldb_private;
-BreakpointSiteList::BreakpointSiteList() : m_mutex(), m_bp_site_list()
-{
-}
+BreakpointSiteList::BreakpointSiteList() : m_mutex(), m_bp_site_list() {}
-BreakpointSiteList::~BreakpointSiteList()
-{
-}
+BreakpointSiteList::~BreakpointSiteList() {}
-// Add breakpoint site to the list. However, if the element already exists in the
+// Add breakpoint site to the list. However, if the element already exists in
+// the
// list, then we don't add it, and return LLDB_INVALID_BREAK_ID.
-lldb::break_id_t
-BreakpointSiteList::Add(const BreakpointSiteSP &bp)
-{
- lldb::addr_t bp_site_load_addr = bp->GetLoadAddress();
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- collection::iterator iter = m_bp_site_list.find (bp_site_load_addr);
-
- if (iter == m_bp_site_list.end())
- {
- m_bp_site_list.insert (iter, collection::value_type (bp_site_load_addr, bp));
- return bp->GetID();
- }
- else
- {
- return LLDB_INVALID_BREAK_ID;
- }
-}
+lldb::break_id_t BreakpointSiteList::Add(const BreakpointSiteSP &bp) {
+ lldb::addr_t bp_site_load_addr = bp->GetLoadAddress();
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ collection::iterator iter = m_bp_site_list.find(bp_site_load_addr);
-bool
-BreakpointSiteList::ShouldStop (StoppointCallbackContext *context, lldb::break_id_t site_id)
-{
- BreakpointSiteSP site_sp (FindByID (site_id));
- if (site_sp)
- {
- // Let the BreakpointSite decide if it should stop here (could not have
- // reached it's target hit count yet, or it could have a callback
- // that decided it shouldn't stop (shared library loads/unloads).
- return site_sp->ShouldStop (context);
- }
- // We should stop here since this BreakpointSite isn't valid anymore or it
- // doesn't exist.
- return true;
-}
-lldb::break_id_t
-BreakpointSiteList::FindIDByAddress (lldb::addr_t addr)
-{
- BreakpointSiteSP bp = FindByAddress (addr);
- if (bp)
- {
- //DBLogIf(PD_LOG_BREAKPOINTS, "BreakpointSiteList::%s ( addr = 0x%8.8" PRIx64 " ) => %u", __FUNCTION__, (uint64_t)addr, bp->GetID());
- return bp.get()->GetID();
- }
- //DBLogIf(PD_LOG_BREAKPOINTS, "BreakpointSiteList::%s ( addr = 0x%8.8" PRIx64 " ) => NONE", __FUNCTION__, (uint64_t)addr);
+ if (iter == m_bp_site_list.end()) {
+ m_bp_site_list.insert(iter, collection::value_type(bp_site_load_addr, bp));
+ return bp->GetID();
+ } else {
return LLDB_INVALID_BREAK_ID;
+ }
+}
+
+bool BreakpointSiteList::ShouldStop(StoppointCallbackContext *context,
+ lldb::break_id_t site_id) {
+ BreakpointSiteSP site_sp(FindByID(site_id));
+ if (site_sp) {
+ // Let the BreakpointSite decide if it should stop here (could not have
+ // reached it's target hit count yet, or it could have a callback
+ // that decided it shouldn't stop (shared library loads/unloads).
+ return site_sp->ShouldStop(context);
+ }
+ // We should stop here since this BreakpointSite isn't valid anymore or it
+ // doesn't exist.
+ return true;
+}
+lldb::break_id_t BreakpointSiteList::FindIDByAddress(lldb::addr_t addr) {
+ BreakpointSiteSP bp = FindByAddress(addr);
+ if (bp) {
+ // DBLogIf(PD_LOG_BREAKPOINTS, "BreakpointSiteList::%s ( addr = 0x%8.8"
+ // PRIx64 " ) => %u", __FUNCTION__, (uint64_t)addr, bp->GetID());
+ return bp.get()->GetID();
+ }
+ // DBLogIf(PD_LOG_BREAKPOINTS, "BreakpointSiteList::%s ( addr = 0x%8.8" PRIx64
+ // " ) => NONE", __FUNCTION__, (uint64_t)addr);
+ return LLDB_INVALID_BREAK_ID;
+}
+
+bool BreakpointSiteList::Remove(lldb::break_id_t break_id) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ collection::iterator pos = GetIDIterator(break_id); // Predicate
+ if (pos != m_bp_site_list.end()) {
+ m_bp_site_list.erase(pos);
+ return true;
+ }
+ return false;
}
-bool
-BreakpointSiteList::Remove (lldb::break_id_t break_id)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- collection::iterator pos = GetIDIterator(break_id); // Predicate
- if (pos != m_bp_site_list.end())
- {
- m_bp_site_list.erase(pos);
- return true;
- }
- return false;
-}
-
-bool
-BreakpointSiteList::RemoveByAddress (lldb::addr_t address)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- collection::iterator pos = m_bp_site_list.find(address);
- if (pos != m_bp_site_list.end())
- {
- m_bp_site_list.erase(pos);
- return true;
- }
- return false;
+bool BreakpointSiteList::RemoveByAddress(lldb::addr_t address) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ collection::iterator pos = m_bp_site_list.find(address);
+ if (pos != m_bp_site_list.end()) {
+ m_bp_site_list.erase(pos);
+ return true;
+ }
+ return false;
}
-class BreakpointSiteIDMatches
-{
+class BreakpointSiteIDMatches {
public:
- BreakpointSiteIDMatches (lldb::break_id_t break_id) :
- m_break_id(break_id)
- {
- }
+ BreakpointSiteIDMatches(lldb::break_id_t break_id) : m_break_id(break_id) {}
- bool operator() (std::pair <lldb::addr_t, BreakpointSiteSP> val_pair) const
- {
- return m_break_id == val_pair.second.get()->GetID();
- }
+ bool operator()(std::pair<lldb::addr_t, BreakpointSiteSP> val_pair) const {
+ return m_break_id == val_pair.second.get()->GetID();
+ }
private:
- const lldb::break_id_t m_break_id;
+ const lldb::break_id_t m_break_id;
};
BreakpointSiteList::collection::iterator
-BreakpointSiteList::GetIDIterator (lldb::break_id_t break_id)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return std::find_if(m_bp_site_list.begin(), m_bp_site_list.end(), // Search full range
- BreakpointSiteIDMatches(break_id)); // Predicate
+BreakpointSiteList::GetIDIterator(lldb::break_id_t break_id) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return std::find_if(m_bp_site_list.begin(),
+ m_bp_site_list.end(), // Search full range
+ BreakpointSiteIDMatches(break_id)); // Predicate
}
BreakpointSiteList::collection::const_iterator
-BreakpointSiteList::GetIDConstIterator (lldb::break_id_t break_id) const
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return std::find_if(m_bp_site_list.begin(), m_bp_site_list.end(), // Search full range
- BreakpointSiteIDMatches(break_id)); // Predicate
+BreakpointSiteList::GetIDConstIterator(lldb::break_id_t break_id) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return std::find_if(m_bp_site_list.begin(),
+ m_bp_site_list.end(), // Search full range
+ BreakpointSiteIDMatches(break_id)); // Predicate
}
-BreakpointSiteSP
-BreakpointSiteList::FindByID (lldb::break_id_t break_id)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- BreakpointSiteSP stop_sp;
- collection::iterator pos = GetIDIterator(break_id);
- if (pos != m_bp_site_list.end())
- stop_sp = pos->second;
+BreakpointSiteSP BreakpointSiteList::FindByID(lldb::break_id_t break_id) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ BreakpointSiteSP stop_sp;
+ collection::iterator pos = GetIDIterator(break_id);
+ if (pos != m_bp_site_list.end())
+ stop_sp = pos->second;
- return stop_sp;
+ return stop_sp;
}
const BreakpointSiteSP
-BreakpointSiteList::FindByID (lldb::break_id_t break_id) const
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- BreakpointSiteSP stop_sp;
- collection::const_iterator pos = GetIDConstIterator(break_id);
- if (pos != m_bp_site_list.end())
- stop_sp = pos->second;
-
- return stop_sp;
-}
-
-BreakpointSiteSP
-BreakpointSiteList::FindByAddress (lldb::addr_t addr)
-{
- BreakpointSiteSP found_sp;
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- collection::iterator iter = m_bp_site_list.find(addr);
- if (iter != m_bp_site_list.end())
- found_sp = iter->second;
- return found_sp;
-}
-
-bool
-BreakpointSiteList::BreakpointSiteContainsBreakpoint (lldb::break_id_t bp_site_id, lldb::break_id_t bp_id)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- collection::const_iterator pos = GetIDConstIterator(bp_site_id);
- if (pos != m_bp_site_list.end())
- return pos->second->IsBreakpointAtThisSite (bp_id);
-
+BreakpointSiteList::FindByID(lldb::break_id_t break_id) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ BreakpointSiteSP stop_sp;
+ collection::const_iterator pos = GetIDConstIterator(break_id);
+ if (pos != m_bp_site_list.end())
+ stop_sp = pos->second;
+
+ return stop_sp;
+}
+
+BreakpointSiteSP BreakpointSiteList::FindByAddress(lldb::addr_t addr) {
+ BreakpointSiteSP found_sp;
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ collection::iterator iter = m_bp_site_list.find(addr);
+ if (iter != m_bp_site_list.end())
+ found_sp = iter->second;
+ return found_sp;
+}
+
+bool BreakpointSiteList::BreakpointSiteContainsBreakpoint(
+ lldb::break_id_t bp_site_id, lldb::break_id_t bp_id) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ collection::const_iterator pos = GetIDConstIterator(bp_site_id);
+ if (pos != m_bp_site_list.end())
+ return pos->second->IsBreakpointAtThisSite(bp_id);
+
+ return false;
+}
+
+void BreakpointSiteList::Dump(Stream *s) const {
+ s->Printf("%p: ", static_cast<const void *>(this));
+ // s->Indent();
+ s->Printf("BreakpointSiteList with %u BreakpointSites:\n",
+ (uint32_t)m_bp_site_list.size());
+ s->IndentMore();
+ collection::const_iterator pos;
+ collection::const_iterator end = m_bp_site_list.end();
+ for (pos = m_bp_site_list.begin(); pos != end; ++pos)
+ pos->second.get()->Dump(s);
+ s->IndentLess();
+}
+
+void BreakpointSiteList::ForEach(
+ std::function<void(BreakpointSite *)> const &callback) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ for (auto pair : m_bp_site_list)
+ callback(pair.second.get());
+}
+
+bool BreakpointSiteList::FindInRange(lldb::addr_t lower_bound,
+ lldb::addr_t upper_bound,
+ BreakpointSiteList &bp_site_list) const {
+ if (lower_bound > upper_bound)
return false;
-}
-void
-BreakpointSiteList::Dump (Stream *s) const
-{
- s->Printf("%p: ", static_cast<const void*>(this));
- //s->Indent();
- s->Printf("BreakpointSiteList with %u BreakpointSites:\n", (uint32_t)m_bp_site_list.size());
- s->IndentMore();
- collection::const_iterator pos;
- collection::const_iterator end = m_bp_site_list.end();
- for (pos = m_bp_site_list.begin(); pos != end; ++pos)
- pos->second.get()->Dump(s);
- s->IndentLess();
-}
-
-void
-BreakpointSiteList::ForEach (std::function <void(BreakpointSite *)> const &callback)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- for (auto pair : m_bp_site_list)
- callback (pair.second.get());
-}
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ collection::const_iterator lower, upper, pos;
+ lower = m_bp_site_list.lower_bound(lower_bound);
+ if (lower == m_bp_site_list.end() || (*lower).first >= upper_bound)
+ return false;
-bool
-BreakpointSiteList::FindInRange (lldb::addr_t lower_bound, lldb::addr_t upper_bound, BreakpointSiteList &bp_site_list) const
-{
- if (lower_bound > upper_bound)
- return false;
-
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- collection::const_iterator lower, upper, pos;
- lower = m_bp_site_list.lower_bound(lower_bound);
- if (lower == m_bp_site_list.end()
- || (*lower).first >= upper_bound)
- return false;
-
- // This is one tricky bit. The breakpoint might overlap the bottom end of the range. So we grab the
- // breakpoint prior to the lower bound, and check that that + its byte size isn't in our range.
- if (lower != m_bp_site_list.begin())
- {
- collection::const_iterator prev_pos = lower;
- prev_pos--;
- const BreakpointSiteSP &prev_bp = (*prev_pos).second;
- if (prev_bp->GetLoadAddress() + prev_bp->GetByteSize() > lower_bound)
- bp_site_list.Add (prev_bp);
-
- }
-
- upper = m_bp_site_list.upper_bound(upper_bound);
-
- for (pos = lower; pos != upper; pos++)
- {
- bp_site_list.Add ((*pos).second);
- }
- return true;
+ // This is one tricky bit. The breakpoint might overlap the bottom end of the
+ // range. So we grab the
+ // breakpoint prior to the lower bound, and check that that + its byte size
+ // isn't in our range.
+ if (lower != m_bp_site_list.begin()) {
+ collection::const_iterator prev_pos = lower;
+ prev_pos--;
+ const BreakpointSiteSP &prev_bp = (*prev_pos).second;
+ if (prev_bp->GetLoadAddress() + prev_bp->GetByteSize() > lower_bound)
+ bp_site_list.Add(prev_bp);
+ }
+
+ upper = m_bp_site_list.upper_bound(upper_bound);
+
+ for (pos = lower; pos != upper; pos++) {
+ bp_site_list.Add((*pos).second);
+ }
+ return true;
}
diff --git a/lldb/source/Breakpoint/Stoppoint.cpp b/lldb/source/Breakpoint/Stoppoint.cpp
index 583ab47..dbc832b 100644
--- a/lldb/source/Breakpoint/Stoppoint.cpp
+++ b/lldb/source/Breakpoint/Stoppoint.cpp
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-private.h"
#include "lldb/Breakpoint/Stoppoint.h"
+#include "lldb/lldb-private.h"
// C Includes
// C++ Includes
@@ -21,26 +21,13 @@ using namespace lldb_private;
//----------------------------------------------------------------------
// Stoppoint constructor
//----------------------------------------------------------------------
-Stoppoint::Stoppoint() :
- m_bid (LLDB_INVALID_BREAK_ID)
-{
-}
+Stoppoint::Stoppoint() : m_bid(LLDB_INVALID_BREAK_ID) {}
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
-Stoppoint::~Stoppoint()
-{
-}
+Stoppoint::~Stoppoint() {}
-break_id_t
-Stoppoint::GetID () const
-{
- return m_bid;
-}
+break_id_t Stoppoint::GetID() const { return m_bid; }
-void
-Stoppoint::SetID (break_id_t bid)
-{
- m_bid = bid;
-}
+void Stoppoint::SetID(break_id_t bid) { m_bid = bid; }
diff --git a/lldb/source/Breakpoint/StoppointCallbackContext.cpp b/lldb/source/Breakpoint/StoppointCallbackContext.cpp
index 9932843..3d24eb7 100644
--- a/lldb/source/Breakpoint/StoppointCallbackContext.cpp
+++ b/lldb/source/Breakpoint/StoppointCallbackContext.cpp
@@ -15,24 +15,15 @@
using namespace lldb_private;
-StoppointCallbackContext::StoppointCallbackContext() :
- event (nullptr),
- exe_ctx_ref (),
- is_synchronous (false)
-{
-}
+StoppointCallbackContext::StoppointCallbackContext()
+ : event(nullptr), exe_ctx_ref(), is_synchronous(false) {}
-StoppointCallbackContext::StoppointCallbackContext(Event *e, const ExecutionContext &exe_ctx, bool synchronously) :
- event (e),
- exe_ctx_ref (exe_ctx),
- is_synchronous(synchronously)
-{
-}
+StoppointCallbackContext::StoppointCallbackContext(
+ Event *e, const ExecutionContext &exe_ctx, bool synchronously)
+ : event(e), exe_ctx_ref(exe_ctx), is_synchronous(synchronously) {}
-void
-StoppointCallbackContext::Clear()
-{
- event = nullptr;
- exe_ctx_ref.Clear();
- is_synchronous = false;
+void StoppointCallbackContext::Clear() {
+ event = nullptr;
+ exe_ctx_ref.Clear();
+ is_synchronous = false;
}
diff --git a/lldb/source/Breakpoint/StoppointLocation.cpp b/lldb/source/Breakpoint/StoppointLocation.cpp
index 35e5979..d624ddb 100644
--- a/lldb/source/Breakpoint/StoppointLocation.cpp
+++ b/lldb/source/Breakpoint/StoppointLocation.cpp
@@ -20,36 +20,22 @@ using namespace lldb_private;
//----------------------------------------------------------------------
// StoppointLocation constructor
//----------------------------------------------------------------------
-StoppointLocation::StoppointLocation (break_id_t bid, addr_t addr, bool hardware) :
- m_loc_id(bid),
- m_addr(addr),
- m_hardware(hardware),
- m_hardware_index(LLDB_INVALID_INDEX32),
- m_byte_size(0),
- m_hit_count(0)
-{
-}
+StoppointLocation::StoppointLocation(break_id_t bid, addr_t addr, bool hardware)
+ : m_loc_id(bid), m_addr(addr), m_hardware(hardware),
+ m_hardware_index(LLDB_INVALID_INDEX32), m_byte_size(0), m_hit_count(0) {}
-StoppointLocation::StoppointLocation (break_id_t bid, addr_t addr, uint32_t byte_size, bool hardware) :
- m_loc_id(bid),
- m_addr(addr),
- m_hardware(hardware),
- m_hardware_index(LLDB_INVALID_INDEX32),
- m_byte_size(byte_size),
- m_hit_count(0)
-{
-}
+StoppointLocation::StoppointLocation(break_id_t bid, addr_t addr,
+ uint32_t byte_size, bool hardware)
+ : m_loc_id(bid), m_addr(addr), m_hardware(hardware),
+ m_hardware_index(LLDB_INVALID_INDEX32), m_byte_size(byte_size),
+ m_hit_count(0) {}
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
-StoppointLocation::~StoppointLocation()
-{
-}
+StoppointLocation::~StoppointLocation() {}
-void
-StoppointLocation::DecrementHitCount ()
-{
- assert (m_hit_count > 0);
- --m_hit_count;
+void StoppointLocation::DecrementHitCount() {
+ assert(m_hit_count > 0);
+ --m_hit_count;
}
diff --git a/lldb/source/Breakpoint/Watchpoint.cpp b/lldb/source/Breakpoint/Watchpoint.cpp
index 00a328e..15fcff6 100644
--- a/lldb/source/Breakpoint/Watchpoint.cpp
+++ b/lldb/source/Breakpoint/Watchpoint.cpp
@@ -18,487 +18,370 @@
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectMemory.h"
+#include "lldb/Expression/UserExpression.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadSpec.h"
-#include "lldb/Expression/UserExpression.h"
using namespace lldb;
using namespace lldb_private;
-Watchpoint::Watchpoint (Target& target, lldb::addr_t addr, uint32_t size, const CompilerType *type, bool hardware) :
- StoppointLocation (0, addr, size, hardware),
- m_target(target),
- m_enabled(false),
- m_is_hardware(hardware),
- m_is_watch_variable(false),
- m_is_ephemeral(false),
- m_disabled_count(0),
- m_watch_read(0),
- m_watch_write(0),
- m_watch_was_read(0),
- m_watch_was_written(0),
- m_ignore_count(0),
- m_false_alarms(0),
- m_decl_str(),
- m_watch_spec_str(),
- m_type(),
- m_error(),
- m_options (),
- m_being_created(true)
-{
- if (type && type->IsValid())
- m_type = *type;
- else
- {
- // If we don't have a known type, then we force it to unsigned int of the right size.
- ClangASTContext *ast_context = target.GetScratchClangASTContext();
- m_type = ast_context->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, 8 * size);
- }
-
- // Set the initial value of the watched variable:
- if (m_target.GetProcessSP())
- {
- ExecutionContext exe_ctx;
- m_target.GetProcessSP()->CalculateExecutionContext(exe_ctx);
- CaptureWatchedValue (exe_ctx);
- }
- m_being_created = false;
+Watchpoint::Watchpoint(Target &target, lldb::addr_t addr, uint32_t size,
+ const CompilerType *type, bool hardware)
+ : StoppointLocation(0, addr, size, hardware), m_target(target),
+ m_enabled(false), m_is_hardware(hardware), m_is_watch_variable(false),
+ m_is_ephemeral(false), m_disabled_count(0), m_watch_read(0),
+ m_watch_write(0), m_watch_was_read(0), m_watch_was_written(0),
+ m_ignore_count(0), m_false_alarms(0), m_decl_str(), m_watch_spec_str(),
+ m_type(), m_error(), m_options(), m_being_created(true) {
+ if (type && type->IsValid())
+ m_type = *type;
+ else {
+ // If we don't have a known type, then we force it to unsigned int of the
+ // right size.
+ ClangASTContext *ast_context = target.GetScratchClangASTContext();
+ m_type = ast_context->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint,
+ 8 * size);
+ }
+
+ // Set the initial value of the watched variable:
+ if (m_target.GetProcessSP()) {
+ ExecutionContext exe_ctx;
+ m_target.GetProcessSP()->CalculateExecutionContext(exe_ctx);
+ CaptureWatchedValue(exe_ctx);
+ }
+ m_being_created = false;
}
Watchpoint::~Watchpoint() = default;
// This function is used when "baton" doesn't need to be freed
-void
-Watchpoint::SetCallback (WatchpointHitCallback callback, void *baton, bool is_synchronous)
-{
- // The default "Baton" class will keep a copy of "baton" and won't free
- // or delete it when it goes goes out of scope.
- m_options.SetCallback(callback, BatonSP (new Baton(baton)), is_synchronous);
-
- SendWatchpointChangedEvent (eWatchpointEventTypeCommandChanged);
+void Watchpoint::SetCallback(WatchpointHitCallback callback, void *baton,
+ bool is_synchronous) {
+ // The default "Baton" class will keep a copy of "baton" and won't free
+ // or delete it when it goes goes out of scope.
+ m_options.SetCallback(callback, BatonSP(new Baton(baton)), is_synchronous);
+
+ SendWatchpointChangedEvent(eWatchpointEventTypeCommandChanged);
}
-// This function is used when a baton needs to be freed and therefore is
+// This function is used when a baton needs to be freed and therefore is
// contained in a "Baton" subclass.
-void
-Watchpoint::SetCallback (WatchpointHitCallback callback, const BatonSP &callback_baton_sp, bool is_synchronous)
-{
- m_options.SetCallback(callback, callback_baton_sp, is_synchronous);
- SendWatchpointChangedEvent (eWatchpointEventTypeCommandChanged);
+void Watchpoint::SetCallback(WatchpointHitCallback callback,
+ const BatonSP &callback_baton_sp,
+ bool is_synchronous) {
+ m_options.SetCallback(callback, callback_baton_sp, is_synchronous);
+ SendWatchpointChangedEvent(eWatchpointEventTypeCommandChanged);
}
-void
-Watchpoint::ClearCallback ()
-{
- m_options.ClearCallback ();
- SendWatchpointChangedEvent (eWatchpointEventTypeCommandChanged);
+void Watchpoint::ClearCallback() {
+ m_options.ClearCallback();
+ SendWatchpointChangedEvent(eWatchpointEventTypeCommandChanged);
}
-void
-Watchpoint::SetDeclInfo (const std::string &str)
-{
- m_decl_str = str;
-}
+void Watchpoint::SetDeclInfo(const std::string &str) { m_decl_str = str; }
-std::string
-Watchpoint::GetWatchSpec()
-{
- return m_watch_spec_str;
-}
+std::string Watchpoint::GetWatchSpec() { return m_watch_spec_str; }
-void
-Watchpoint::SetWatchSpec (const std::string &str)
-{
- m_watch_spec_str = str;
+void Watchpoint::SetWatchSpec(const std::string &str) {
+ m_watch_spec_str = str;
}
// Override default impl of StoppointLocation::IsHardware() since m_is_hardware
// member field is more accurate.
-bool
-Watchpoint::IsHardware () const
-{
- return m_is_hardware;
-}
-
-bool
-Watchpoint::IsWatchVariable() const
-{
- return m_is_watch_variable;
-}
-
-void
-Watchpoint::SetWatchVariable(bool val)
-{
- m_is_watch_variable = val;
-}
-
-bool
-Watchpoint::CaptureWatchedValue (const ExecutionContext &exe_ctx)
-{
- ConstString watch_name("$__lldb__watch_value");
- m_old_value_sp = m_new_value_sp;
- Address watch_address(GetLoadAddress());
- if (!m_type.IsValid())
- {
- // Don't know how to report new & old values, since we couldn't make a scalar type for this watchpoint.
- // This works around an assert in ValueObjectMemory::Create.
- // FIXME: This should not happen, but if it does in some case we care about,
- // we can go grab the value raw and print it as unsigned.
- return false;
- }
- m_new_value_sp = ValueObjectMemory::Create (exe_ctx.GetBestExecutionContextScope(), watch_name.AsCString(), watch_address, m_type);
- m_new_value_sp = m_new_value_sp->CreateConstantValue(watch_name);
- return (m_new_value_sp && m_new_value_sp->GetError().Success());
-}
-
-void
-Watchpoint::IncrementFalseAlarmsAndReviseHitCount()
-{
- ++m_false_alarms;
- if (m_false_alarms)
- {
- if (m_hit_count >= m_false_alarms)
- {
- m_hit_count -= m_false_alarms;
- m_false_alarms = 0;
- }
- else
- {
- m_false_alarms -= m_hit_count;
- m_hit_count = 0;
- }
+bool Watchpoint::IsHardware() const { return m_is_hardware; }
+
+bool Watchpoint::IsWatchVariable() const { return m_is_watch_variable; }
+
+void Watchpoint::SetWatchVariable(bool val) { m_is_watch_variable = val; }
+
+bool Watchpoint::CaptureWatchedValue(const ExecutionContext &exe_ctx) {
+ ConstString watch_name("$__lldb__watch_value");
+ m_old_value_sp = m_new_value_sp;
+ Address watch_address(GetLoadAddress());
+ if (!m_type.IsValid()) {
+ // Don't know how to report new & old values, since we couldn't make a
+ // scalar type for this watchpoint.
+ // This works around an assert in ValueObjectMemory::Create.
+ // FIXME: This should not happen, but if it does in some case we care about,
+ // we can go grab the value raw and print it as unsigned.
+ return false;
+ }
+ m_new_value_sp =
+ ValueObjectMemory::Create(exe_ctx.GetBestExecutionContextScope(),
+ watch_name.AsCString(), watch_address, m_type);
+ m_new_value_sp = m_new_value_sp->CreateConstantValue(watch_name);
+ return (m_new_value_sp && m_new_value_sp->GetError().Success());
+}
+
+void Watchpoint::IncrementFalseAlarmsAndReviseHitCount() {
+ ++m_false_alarms;
+ if (m_false_alarms) {
+ if (m_hit_count >= m_false_alarms) {
+ m_hit_count -= m_false_alarms;
+ m_false_alarms = 0;
+ } else {
+ m_false_alarms -= m_hit_count;
+ m_hit_count = 0;
}
+ }
}
// RETURNS - true if we should stop at this breakpoint, false if we
// should continue.
-bool
-Watchpoint::ShouldStop (StoppointCallbackContext *context)
-{
- IncrementHitCount();
+bool Watchpoint::ShouldStop(StoppointCallbackContext *context) {
+ IncrementHitCount();
- if (!IsEnabled())
- return false;
+ if (!IsEnabled())
+ return false;
- return true;
+ return true;
}
-void
-Watchpoint::GetDescription (Stream *s, lldb::DescriptionLevel level)
-{
- DumpWithLevel(s, level);
+void Watchpoint::GetDescription(Stream *s, lldb::DescriptionLevel level) {
+ DumpWithLevel(s, level);
}
-void
-Watchpoint::Dump(Stream *s) const
-{
- DumpWithLevel(s, lldb::eDescriptionLevelBrief);
+void Watchpoint::Dump(Stream *s) const {
+ DumpWithLevel(s, lldb::eDescriptionLevelBrief);
}
-// If prefix is nullptr, we display the watch id and ignore the prefix altogether.
-void
-Watchpoint::DumpSnapshots(Stream *s, const char *prefix) const
-{
- if (!prefix)
- {
- s->Printf("\nWatchpoint %u hit:", GetID());
- prefix = "";
- }
+// If prefix is nullptr, we display the watch id and ignore the prefix
+// altogether.
+void Watchpoint::DumpSnapshots(Stream *s, const char *prefix) const {
+ if (!prefix) {
+ s->Printf("\nWatchpoint %u hit:", GetID());
+ prefix = "";
+ }
- if (m_old_value_sp)
- {
- const char *old_value_cstr = m_old_value_sp->GetValueAsCString();
- if (old_value_cstr && old_value_cstr[0])
- s->Printf("\n%sold value: %s", prefix, old_value_cstr);
- else
- {
- const char *old_summary_cstr = m_old_value_sp-> GetSummaryAsCString();
- if (old_summary_cstr && old_summary_cstr[0])
- s->Printf("\n%sold value: %s", prefix, old_summary_cstr);
- }
+ if (m_old_value_sp) {
+ const char *old_value_cstr = m_old_value_sp->GetValueAsCString();
+ if (old_value_cstr && old_value_cstr[0])
+ s->Printf("\n%sold value: %s", prefix, old_value_cstr);
+ else {
+ const char *old_summary_cstr = m_old_value_sp->GetSummaryAsCString();
+ if (old_summary_cstr && old_summary_cstr[0])
+ s->Printf("\n%sold value: %s", prefix, old_summary_cstr);
}
-
- if (m_new_value_sp)
- {
- const char *new_value_cstr = m_new_value_sp->GetValueAsCString();
- if (new_value_cstr && new_value_cstr[0])
- s->Printf("\n%snew value: %s", prefix, new_value_cstr);
- else
- {
- const char *new_summary_cstr = m_new_value_sp-> GetSummaryAsCString();
- if (new_summary_cstr && new_summary_cstr[0])
- s->Printf("\n%snew value: %s", prefix, new_summary_cstr);
- }
+ }
+
+ if (m_new_value_sp) {
+ const char *new_value_cstr = m_new_value_sp->GetValueAsCString();
+ if (new_value_cstr && new_value_cstr[0])
+ s->Printf("\n%snew value: %s", prefix, new_value_cstr);
+ else {
+ const char *new_summary_cstr = m_new_value_sp->GetSummaryAsCString();
+ if (new_summary_cstr && new_summary_cstr[0])
+ s->Printf("\n%snew value: %s", prefix, new_summary_cstr);
}
+ }
}
-void
-Watchpoint::DumpWithLevel(Stream *s, lldb::DescriptionLevel description_level) const
-{
- if (s == nullptr)
- return;
-
- assert(description_level >= lldb::eDescriptionLevelBrief &&
- description_level <= lldb::eDescriptionLevelVerbose);
-
- s->Printf("Watchpoint %u: addr = 0x%8.8" PRIx64 " size = %u state = %s type = %s%s",
- GetID(),
- GetLoadAddress(),
- m_byte_size,
- IsEnabled() ? "enabled" : "disabled",
- m_watch_read ? "r" : "",
- m_watch_write ? "w" : "");
-
- if (description_level >= lldb::eDescriptionLevelFull) {
- if (!m_decl_str.empty())
- s->Printf("\n declare @ '%s'", m_decl_str.c_str());
- if (!m_watch_spec_str.empty())
- s->Printf("\n watchpoint spec = '%s'", m_watch_spec_str.c_str());
-
- // Dump the snapshots we have taken.
- DumpSnapshots(s, " ");
-
- if (GetConditionText())
- s->Printf("\n condition = '%s'", GetConditionText());
- m_options.GetCallbackDescription(s, description_level);
- }
+void Watchpoint::DumpWithLevel(Stream *s,
+ lldb::DescriptionLevel description_level) const {
+ if (s == nullptr)
+ return;
- if (description_level >= lldb::eDescriptionLevelVerbose)
- {
- s->Printf("\n hw_index = %i hit_count = %-4u ignore_count = %-4u",
- GetHardwareIndex(),
- GetHitCount(),
- GetIgnoreCount());
- }
-}
+ assert(description_level >= lldb::eDescriptionLevelBrief &&
+ description_level <= lldb::eDescriptionLevelVerbose);
-bool
-Watchpoint::IsEnabled() const
-{
- return m_enabled;
-}
+ s->Printf("Watchpoint %u: addr = 0x%8.8" PRIx64
+ " size = %u state = %s type = %s%s",
+ GetID(), GetLoadAddress(), m_byte_size,
+ IsEnabled() ? "enabled" : "disabled", m_watch_read ? "r" : "",
+ m_watch_write ? "w" : "");
-// Within StopInfo.cpp, we purposely turn on the ephemeral mode right before temporarily disable the watchpoint
-// in order to perform possible watchpoint actions without triggering further watchpoint events.
-// After the temporary disabled watchpoint is enabled, we then turn off the ephemeral mode.
+ if (description_level >= lldb::eDescriptionLevelFull) {
+ if (!m_decl_str.empty())
+ s->Printf("\n declare @ '%s'", m_decl_str.c_str());
+ if (!m_watch_spec_str.empty())
+ s->Printf("\n watchpoint spec = '%s'", m_watch_spec_str.c_str());
-void
-Watchpoint::TurnOnEphemeralMode()
-{
- m_is_ephemeral = true;
-}
+ // Dump the snapshots we have taken.
+ DumpSnapshots(s, " ");
-void
-Watchpoint::TurnOffEphemeralMode()
-{
- m_is_ephemeral = false;
- // Leaving ephemeral mode, reset the m_disabled_count!
- m_disabled_count = 0;
-}
+ if (GetConditionText())
+ s->Printf("\n condition = '%s'", GetConditionText());
+ m_options.GetCallbackDescription(s, description_level);
+ }
-bool
-Watchpoint::IsDisabledDuringEphemeralMode()
-{
- return m_disabled_count > 1;
+ if (description_level >= lldb::eDescriptionLevelVerbose) {
+ s->Printf("\n hw_index = %i hit_count = %-4u ignore_count = %-4u",
+ GetHardwareIndex(), GetHitCount(), GetIgnoreCount());
+ }
}
-void
-Watchpoint::SetEnabled(bool enabled, bool notify)
-{
- if (!enabled)
- {
- if (!m_is_ephemeral)
- SetHardwareIndex(LLDB_INVALID_INDEX32);
- else
- ++m_disabled_count;
-
- // Don't clear the snapshots for now.
- // Within StopInfo.cpp, we purposely do disable/enable watchpoint while performing watchpoint actions.
- }
- bool changed = enabled != m_enabled;
- m_enabled = enabled;
- if (notify && !m_is_ephemeral && changed)
- SendWatchpointChangedEvent (enabled ? eWatchpointEventTypeEnabled : eWatchpointEventTypeDisabled);
-}
+bool Watchpoint::IsEnabled() const { return m_enabled; }
-void
-Watchpoint::SetWatchpointType (uint32_t type, bool notify)
-{
- int old_watch_read = m_watch_read;
- int old_watch_write = m_watch_write;
- m_watch_read = (type & LLDB_WATCH_TYPE_READ) != 0;
- m_watch_write = (type & LLDB_WATCH_TYPE_WRITE) != 0;
- if (notify && (old_watch_read != m_watch_read || old_watch_write != m_watch_write))
- SendWatchpointChangedEvent (eWatchpointEventTypeTypeChanged);
-}
+// Within StopInfo.cpp, we purposely turn on the ephemeral mode right before
+// temporarily disable the watchpoint
+// in order to perform possible watchpoint actions without triggering further
+// watchpoint events.
+// After the temporary disabled watchpoint is enabled, we then turn off the
+// ephemeral mode.
+
+void Watchpoint::TurnOnEphemeralMode() { m_is_ephemeral = true; }
-bool
-Watchpoint::WatchpointRead () const
-{
- return m_watch_read != 0;
+void Watchpoint::TurnOffEphemeralMode() {
+ m_is_ephemeral = false;
+ // Leaving ephemeral mode, reset the m_disabled_count!
+ m_disabled_count = 0;
}
-bool
-Watchpoint::WatchpointWrite () const
-{
- return m_watch_write != 0;
+bool Watchpoint::IsDisabledDuringEphemeralMode() {
+ return m_disabled_count > 1;
}
-uint32_t
-Watchpoint::GetIgnoreCount () const
-{
- return m_ignore_count;
+void Watchpoint::SetEnabled(bool enabled, bool notify) {
+ if (!enabled) {
+ if (!m_is_ephemeral)
+ SetHardwareIndex(LLDB_INVALID_INDEX32);
+ else
+ ++m_disabled_count;
+
+ // Don't clear the snapshots for now.
+ // Within StopInfo.cpp, we purposely do disable/enable watchpoint while
+ // performing watchpoint actions.
+ }
+ bool changed = enabled != m_enabled;
+ m_enabled = enabled;
+ if (notify && !m_is_ephemeral && changed)
+ SendWatchpointChangedEvent(enabled ? eWatchpointEventTypeEnabled
+ : eWatchpointEventTypeDisabled);
}
-void
-Watchpoint::SetIgnoreCount (uint32_t n)
-{
- bool changed = m_ignore_count != n;
- m_ignore_count = n;
- if (changed)
- SendWatchpointChangedEvent (eWatchpointEventTypeIgnoreChanged);
+void Watchpoint::SetWatchpointType(uint32_t type, bool notify) {
+ int old_watch_read = m_watch_read;
+ int old_watch_write = m_watch_write;
+ m_watch_read = (type & LLDB_WATCH_TYPE_READ) != 0;
+ m_watch_write = (type & LLDB_WATCH_TYPE_WRITE) != 0;
+ if (notify &&
+ (old_watch_read != m_watch_read || old_watch_write != m_watch_write))
+ SendWatchpointChangedEvent(eWatchpointEventTypeTypeChanged);
}
-bool
-Watchpoint::InvokeCallback (StoppointCallbackContext *context)
-{
- return m_options.InvokeCallback (context, GetID());
+bool Watchpoint::WatchpointRead() const { return m_watch_read != 0; }
+
+bool Watchpoint::WatchpointWrite() const { return m_watch_write != 0; }
+
+uint32_t Watchpoint::GetIgnoreCount() const { return m_ignore_count; }
+
+void Watchpoint::SetIgnoreCount(uint32_t n) {
+ bool changed = m_ignore_count != n;
+ m_ignore_count = n;
+ if (changed)
+ SendWatchpointChangedEvent(eWatchpointEventTypeIgnoreChanged);
}
-void
-Watchpoint::SetCondition (const char *condition)
-{
- if (condition == nullptr || condition[0] == '\0')
- {
- if (m_condition_ap.get())
- m_condition_ap.reset();
- }
- else
- {
- // Pass nullptr for expr_prefix (no translation-unit level definitions).
- Error error;
- m_condition_ap.reset(m_target.GetUserExpressionForLanguage(condition,
- nullptr,
- lldb::eLanguageTypeUnknown,
- UserExpression::eResultTypeAny,
- EvaluateExpressionOptions(),
- error));
- if (error.Fail())
- {
- // FIXME: Log something...
- m_condition_ap.reset();
- }
- }
- SendWatchpointChangedEvent (eWatchpointEventTypeConditionChanged);
+bool Watchpoint::InvokeCallback(StoppointCallbackContext *context) {
+ return m_options.InvokeCallback(context, GetID());
}
-const char *
-Watchpoint::GetConditionText () const
-{
+void Watchpoint::SetCondition(const char *condition) {
+ if (condition == nullptr || condition[0] == '\0') {
if (m_condition_ap.get())
- return m_condition_ap->GetUserText();
- else
- return nullptr;
+ m_condition_ap.reset();
+ } else {
+ // Pass nullptr for expr_prefix (no translation-unit level definitions).
+ Error error;
+ m_condition_ap.reset(m_target.GetUserExpressionForLanguage(
+ condition, nullptr, lldb::eLanguageTypeUnknown,
+ UserExpression::eResultTypeAny, EvaluateExpressionOptions(), error));
+ if (error.Fail()) {
+ // FIXME: Log something...
+ m_condition_ap.reset();
+ }
+ }
+ SendWatchpointChangedEvent(eWatchpointEventTypeConditionChanged);
}
-void
-Watchpoint::SendWatchpointChangedEvent (lldb::WatchpointEventType eventKind)
-{
- if (!m_being_created
- && GetTarget().EventTypeHasListeners(Target::eBroadcastBitWatchpointChanged))
- {
- WatchpointEventData *data = new Watchpoint::WatchpointEventData (eventKind, shared_from_this());
- GetTarget().BroadcastEvent (Target::eBroadcastBitWatchpointChanged, data);
- }
+const char *Watchpoint::GetConditionText() const {
+ if (m_condition_ap.get())
+ return m_condition_ap->GetUserText();
+ else
+ return nullptr;
}
-void
-Watchpoint::SendWatchpointChangedEvent (WatchpointEventData *data)
-{
- if (data == nullptr)
- return;
-
- if (!m_being_created
- && GetTarget().EventTypeHasListeners(Target::eBroadcastBitWatchpointChanged))
- GetTarget().BroadcastEvent (Target::eBroadcastBitWatchpointChanged, data);
- else
- delete data;
+void Watchpoint::SendWatchpointChangedEvent(
+ lldb::WatchpointEventType eventKind) {
+ if (!m_being_created &&
+ GetTarget().EventTypeHasListeners(
+ Target::eBroadcastBitWatchpointChanged)) {
+ WatchpointEventData *data =
+ new Watchpoint::WatchpointEventData(eventKind, shared_from_this());
+ GetTarget().BroadcastEvent(Target::eBroadcastBitWatchpointChanged, data);
+ }
}
-Watchpoint::WatchpointEventData::WatchpointEventData (WatchpointEventType sub_type,
- const WatchpointSP &new_watchpoint_sp) :
- EventData (),
- m_watchpoint_event (sub_type),
- m_new_watchpoint_sp (new_watchpoint_sp)
-{
+void Watchpoint::SendWatchpointChangedEvent(WatchpointEventData *data) {
+ if (data == nullptr)
+ return;
+
+ if (!m_being_created &&
+ GetTarget().EventTypeHasListeners(Target::eBroadcastBitWatchpointChanged))
+ GetTarget().BroadcastEvent(Target::eBroadcastBitWatchpointChanged, data);
+ else
+ delete data;
}
+Watchpoint::WatchpointEventData::WatchpointEventData(
+ WatchpointEventType sub_type, const WatchpointSP &new_watchpoint_sp)
+ : EventData(), m_watchpoint_event(sub_type),
+ m_new_watchpoint_sp(new_watchpoint_sp) {}
+
Watchpoint::WatchpointEventData::~WatchpointEventData() = default;
-const ConstString &
-Watchpoint::WatchpointEventData::GetFlavorString ()
-{
- static ConstString g_flavor ("Watchpoint::WatchpointEventData");
- return g_flavor;
+const ConstString &Watchpoint::WatchpointEventData::GetFlavorString() {
+ static ConstString g_flavor("Watchpoint::WatchpointEventData");
+ return g_flavor;
}
-const ConstString &
-Watchpoint::WatchpointEventData::GetFlavor () const
-{
- return WatchpointEventData::GetFlavorString ();
+const ConstString &Watchpoint::WatchpointEventData::GetFlavor() const {
+ return WatchpointEventData::GetFlavorString();
}
-WatchpointSP &
-Watchpoint::WatchpointEventData::GetWatchpoint ()
-{
- return m_new_watchpoint_sp;
+WatchpointSP &Watchpoint::WatchpointEventData::GetWatchpoint() {
+ return m_new_watchpoint_sp;
}
WatchpointEventType
-Watchpoint::WatchpointEventData::GetWatchpointEventType () const
-{
- return m_watchpoint_event;
+Watchpoint::WatchpointEventData::GetWatchpointEventType() const {
+ return m_watchpoint_event;
}
-void
-Watchpoint::WatchpointEventData::Dump (Stream *s) const
-{
-}
+void Watchpoint::WatchpointEventData::Dump(Stream *s) const {}
const Watchpoint::WatchpointEventData *
-Watchpoint::WatchpointEventData::GetEventDataFromEvent (const Event *event)
-{
- if (event)
- {
- const EventData *event_data = event->GetData();
- if (event_data && event_data->GetFlavor() == WatchpointEventData::GetFlavorString())
- return static_cast <const WatchpointEventData *> (event->GetData());
- }
- return nullptr;
+Watchpoint::WatchpointEventData::GetEventDataFromEvent(const Event *event) {
+ if (event) {
+ const EventData *event_data = event->GetData();
+ if (event_data &&
+ event_data->GetFlavor() == WatchpointEventData::GetFlavorString())
+ return static_cast<const WatchpointEventData *>(event->GetData());
+ }
+ return nullptr;
}
WatchpointEventType
-Watchpoint::WatchpointEventData::GetWatchpointEventTypeFromEvent (const EventSP &event_sp)
-{
- const WatchpointEventData *data = GetEventDataFromEvent (event_sp.get());
+Watchpoint::WatchpointEventData::GetWatchpointEventTypeFromEvent(
+ const EventSP &event_sp) {
+ const WatchpointEventData *data = GetEventDataFromEvent(event_sp.get());
- if (data == nullptr)
- return eWatchpointEventTypeInvalidType;
- else
- return data->GetWatchpointEventType();
+ if (data == nullptr)
+ return eWatchpointEventTypeInvalidType;
+ else
+ return data->GetWatchpointEventType();
}
-WatchpointSP
-Watchpoint::WatchpointEventData::GetWatchpointFromEvent (const EventSP &event_sp)
-{
- WatchpointSP wp_sp;
+WatchpointSP Watchpoint::WatchpointEventData::GetWatchpointFromEvent(
+ const EventSP &event_sp) {
+ WatchpointSP wp_sp;
- const WatchpointEventData *data = GetEventDataFromEvent (event_sp.get());
- if (data)
- wp_sp = data->m_new_watchpoint_sp;
+ const WatchpointEventData *data = GetEventDataFromEvent(event_sp.get());
+ if (data)
+ wp_sp = data->m_new_watchpoint_sp;
- return wp_sp;
+ return wp_sp;
}
diff --git a/lldb/source/Breakpoint/WatchpointList.cpp b/lldb/source/Breakpoint/WatchpointList.cpp
index f662c24..6ec3bd0 100644
--- a/lldb/source/Breakpoint/WatchpointList.cpp
+++ b/lldb/source/Breakpoint/WatchpointList.cpp
@@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//
-
// C Includes
// C++ Includes
// Other libraries and framework includes
@@ -18,291 +17,241 @@
using namespace lldb;
using namespace lldb_private;
-WatchpointList::WatchpointList() : m_watchpoints(), m_mutex(), m_next_wp_id(0)
-{
-}
+WatchpointList::WatchpointList()
+ : m_watchpoints(), m_mutex(), m_next_wp_id(0) {}
-WatchpointList::~WatchpointList()
-{
-}
+WatchpointList::~WatchpointList() {}
// Add a watchpoint to the list.
-lldb::watch_id_t
-WatchpointList::Add (const WatchpointSP &wp_sp, bool notify)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- wp_sp->SetID(++m_next_wp_id);
- m_watchpoints.push_back(wp_sp);
- if (notify)
- {
- if (wp_sp->GetTarget().EventTypeHasListeners(Target::eBroadcastBitWatchpointChanged))
- wp_sp->GetTarget().BroadcastEvent (Target::eBroadcastBitWatchpointChanged,
- new Watchpoint::WatchpointEventData (eWatchpointEventTypeAdded, wp_sp));
- }
- return wp_sp->GetID();
+lldb::watch_id_t WatchpointList::Add(const WatchpointSP &wp_sp, bool notify) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ wp_sp->SetID(++m_next_wp_id);
+ m_watchpoints.push_back(wp_sp);
+ if (notify) {
+ if (wp_sp->GetTarget().EventTypeHasListeners(
+ Target::eBroadcastBitWatchpointChanged))
+ wp_sp->GetTarget().BroadcastEvent(Target::eBroadcastBitWatchpointChanged,
+ new Watchpoint::WatchpointEventData(
+ eWatchpointEventTypeAdded, wp_sp));
+ }
+ return wp_sp->GetID();
}
-void
-WatchpointList::Dump (Stream *s) const
-{
- DumpWithLevel(s, lldb::eDescriptionLevelBrief);
+void WatchpointList::Dump(Stream *s) const {
+ DumpWithLevel(s, lldb::eDescriptionLevelBrief);
}
-void
-WatchpointList::DumpWithLevel (Stream *s, lldb::DescriptionLevel description_level) const
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- s->Printf("%p: ", static_cast<const void*>(this));
- //s->Indent();
- s->Printf("WatchpointList with %" PRIu64 " Watchpoints:\n",
- (uint64_t)m_watchpoints.size());
- s->IndentMore();
- wp_collection::const_iterator pos, end = m_watchpoints.end();
- for (pos = m_watchpoints.begin(); pos != end; ++pos)
- (*pos)->DumpWithLevel(s, description_level);
- s->IndentLess();
+void WatchpointList::DumpWithLevel(
+ Stream *s, lldb::DescriptionLevel description_level) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ s->Printf("%p: ", static_cast<const void *>(this));
+ // s->Indent();
+ s->Printf("WatchpointList with %" PRIu64 " Watchpoints:\n",
+ (uint64_t)m_watchpoints.size());
+ s->IndentMore();
+ wp_collection::const_iterator pos, end = m_watchpoints.end();
+ for (pos = m_watchpoints.begin(); pos != end; ++pos)
+ (*pos)->DumpWithLevel(s, description_level);
+ s->IndentLess();
}
-const WatchpointSP
-WatchpointList::FindByAddress (lldb::addr_t addr) const
-{
- WatchpointSP wp_sp;
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- if (!m_watchpoints.empty())
- {
- wp_collection::const_iterator pos, end = m_watchpoints.end();
- for (pos = m_watchpoints.begin(); pos != end; ++pos)
- {
- lldb::addr_t wp_addr = (*pos)->GetLoadAddress();
- uint32_t wp_bytesize = (*pos)->GetByteSize();
- if ((wp_addr <= addr) && ((wp_addr + wp_bytesize) > addr))
- {
- wp_sp = *pos;
- break;
- }
- }
+const WatchpointSP WatchpointList::FindByAddress(lldb::addr_t addr) const {
+ WatchpointSP wp_sp;
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ if (!m_watchpoints.empty()) {
+ wp_collection::const_iterator pos, end = m_watchpoints.end();
+ for (pos = m_watchpoints.begin(); pos != end; ++pos) {
+ lldb::addr_t wp_addr = (*pos)->GetLoadAddress();
+ uint32_t wp_bytesize = (*pos)->GetByteSize();
+ if ((wp_addr <= addr) && ((wp_addr + wp_bytesize) > addr)) {
+ wp_sp = *pos;
+ break;
+ }
}
+ }
- return wp_sp;
+ return wp_sp;
}
-const WatchpointSP
-WatchpointList::FindBySpec (std::string spec) const
-{
- WatchpointSP wp_sp;
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- if (!m_watchpoints.empty())
- {
- wp_collection::const_iterator pos, end = m_watchpoints.end();
- for (pos = m_watchpoints.begin(); pos != end; ++pos)
- if ((*pos)->GetWatchSpec() == spec) {
- wp_sp = *pos;
- break;
- }
- }
+const WatchpointSP WatchpointList::FindBySpec(std::string spec) const {
+ WatchpointSP wp_sp;
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ if (!m_watchpoints.empty()) {
+ wp_collection::const_iterator pos, end = m_watchpoints.end();
+ for (pos = m_watchpoints.begin(); pos != end; ++pos)
+ if ((*pos)->GetWatchSpec() == spec) {
+ wp_sp = *pos;
+ break;
+ }
+ }
- return wp_sp;
+ return wp_sp;
}
-class WatchpointIDMatches
-{
+class WatchpointIDMatches {
public:
- WatchpointIDMatches (lldb::watch_id_t watch_id) :
- m_watch_id(watch_id)
- {
- }
+ WatchpointIDMatches(lldb::watch_id_t watch_id) : m_watch_id(watch_id) {}
- bool operator() (const WatchpointSP &wp) const
- {
- return m_watch_id == wp->GetID();
- }
+ bool operator()(const WatchpointSP &wp) const {
+ return m_watch_id == wp->GetID();
+ }
private:
- const lldb::watch_id_t m_watch_id;
+ const lldb::watch_id_t m_watch_id;
};
WatchpointList::wp_collection::iterator
-WatchpointList::GetIDIterator (lldb::watch_id_t watch_id)
-{
- return std::find_if(m_watchpoints.begin(), m_watchpoints.end(), // Search full range
- WatchpointIDMatches(watch_id)); // Predicate
+WatchpointList::GetIDIterator(lldb::watch_id_t watch_id) {
+ return std::find_if(m_watchpoints.begin(),
+ m_watchpoints.end(), // Search full range
+ WatchpointIDMatches(watch_id)); // Predicate
}
WatchpointList::wp_collection::const_iterator
-WatchpointList::GetIDConstIterator (lldb::watch_id_t watch_id) const
-{
- return std::find_if(m_watchpoints.begin(), m_watchpoints.end(), // Search full range
- WatchpointIDMatches(watch_id)); // Predicate
+WatchpointList::GetIDConstIterator(lldb::watch_id_t watch_id) const {
+ return std::find_if(m_watchpoints.begin(),
+ m_watchpoints.end(), // Search full range
+ WatchpointIDMatches(watch_id)); // Predicate
}
-WatchpointSP
-WatchpointList::FindByID (lldb::watch_id_t watch_id) const
-{
- WatchpointSP wp_sp;
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- wp_collection::const_iterator pos = GetIDConstIterator(watch_id);
- if (pos != m_watchpoints.end())
- wp_sp = *pos;
+WatchpointSP WatchpointList::FindByID(lldb::watch_id_t watch_id) const {
+ WatchpointSP wp_sp;
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ wp_collection::const_iterator pos = GetIDConstIterator(watch_id);
+ if (pos != m_watchpoints.end())
+ wp_sp = *pos;
- return wp_sp;
+ return wp_sp;
}
-lldb::watch_id_t
-WatchpointList::FindIDByAddress (lldb::addr_t addr)
-{
- WatchpointSP wp_sp = FindByAddress (addr);
- if (wp_sp)
- {
- return wp_sp->GetID();
- }
- return LLDB_INVALID_WATCH_ID;
+lldb::watch_id_t WatchpointList::FindIDByAddress(lldb::addr_t addr) {
+ WatchpointSP wp_sp = FindByAddress(addr);
+ if (wp_sp) {
+ return wp_sp->GetID();
+ }
+ return LLDB_INVALID_WATCH_ID;
}
-lldb::watch_id_t
-WatchpointList::FindIDBySpec (std::string spec)
-{
- WatchpointSP wp_sp = FindBySpec (spec);
- if (wp_sp)
- {
- return wp_sp->GetID();
- }
- return LLDB_INVALID_WATCH_ID;
+lldb::watch_id_t WatchpointList::FindIDBySpec(std::string spec) {
+ WatchpointSP wp_sp = FindBySpec(spec);
+ if (wp_sp) {
+ return wp_sp->GetID();
+ }
+ return LLDB_INVALID_WATCH_ID;
}
-WatchpointSP
-WatchpointList::GetByIndex (uint32_t i)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- WatchpointSP wp_sp;
- if (i < m_watchpoints.size())
- {
- wp_collection::const_iterator pos = m_watchpoints.begin();
- std::advance(pos, i);
- wp_sp = *pos;
- }
- return wp_sp;
+WatchpointSP WatchpointList::GetByIndex(uint32_t i) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ WatchpointSP wp_sp;
+ if (i < m_watchpoints.size()) {
+ wp_collection::const_iterator pos = m_watchpoints.begin();
+ std::advance(pos, i);
+ wp_sp = *pos;
+ }
+ return wp_sp;
}
-const WatchpointSP
-WatchpointList::GetByIndex (uint32_t i) const
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- WatchpointSP wp_sp;
- if (i < m_watchpoints.size())
- {
- wp_collection::const_iterator pos = m_watchpoints.begin();
- std::advance(pos, i);
- wp_sp = *pos;
- }
- return wp_sp;
+const WatchpointSP WatchpointList::GetByIndex(uint32_t i) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ WatchpointSP wp_sp;
+ if (i < m_watchpoints.size()) {
+ wp_collection::const_iterator pos = m_watchpoints.begin();
+ std::advance(pos, i);
+ wp_sp = *pos;
+ }
+ return wp_sp;
}
-std::vector<lldb::watch_id_t>
-WatchpointList::GetWatchpointIDs() const
-{
- std::vector<lldb::watch_id_t> IDs;
- wp_collection::const_iterator pos, end = m_watchpoints.end();
- for (pos = m_watchpoints.begin(); pos != end; ++pos)
- IDs.push_back((*pos)->GetID());
- return IDs;
+std::vector<lldb::watch_id_t> WatchpointList::GetWatchpointIDs() const {
+ std::vector<lldb::watch_id_t> IDs;
+ wp_collection::const_iterator pos, end = m_watchpoints.end();
+ for (pos = m_watchpoints.begin(); pos != end; ++pos)
+ IDs.push_back((*pos)->GetID());
+ return IDs;
}
-bool
-WatchpointList::Remove (lldb::watch_id_t watch_id, bool notify)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- wp_collection::iterator pos = GetIDIterator(watch_id);
- if (pos != m_watchpoints.end())
- {
- WatchpointSP wp_sp = *pos;
- if (notify)
- {
- if (wp_sp->GetTarget().EventTypeHasListeners(Target::eBroadcastBitWatchpointChanged))
- wp_sp->GetTarget().BroadcastEvent (Target::eBroadcastBitWatchpointChanged,
- new Watchpoint::WatchpointEventData (eWatchpointEventTypeRemoved, wp_sp));
- }
- m_watchpoints.erase(pos);
- return true;
+bool WatchpointList::Remove(lldb::watch_id_t watch_id, bool notify) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ wp_collection::iterator pos = GetIDIterator(watch_id);
+ if (pos != m_watchpoints.end()) {
+ WatchpointSP wp_sp = *pos;
+ if (notify) {
+ if (wp_sp->GetTarget().EventTypeHasListeners(
+ Target::eBroadcastBitWatchpointChanged))
+ wp_sp->GetTarget().BroadcastEvent(
+ Target::eBroadcastBitWatchpointChanged,
+ new Watchpoint::WatchpointEventData(eWatchpointEventTypeRemoved,
+ wp_sp));
}
- return false;
+ m_watchpoints.erase(pos);
+ return true;
+ }
+ return false;
}
-uint32_t
-WatchpointList::GetHitCount () const
-{
- uint32_t hit_count = 0;
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- wp_collection::const_iterator pos, end = m_watchpoints.end();
- for (pos = m_watchpoints.begin(); pos != end; ++pos)
- hit_count += (*pos)->GetHitCount();
- return hit_count;
+uint32_t WatchpointList::GetHitCount() const {
+ uint32_t hit_count = 0;
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ wp_collection::const_iterator pos, end = m_watchpoints.end();
+ for (pos = m_watchpoints.begin(); pos != end; ++pos)
+ hit_count += (*pos)->GetHitCount();
+ return hit_count;
}
-bool
-WatchpointList::ShouldStop (StoppointCallbackContext *context, lldb::watch_id_t watch_id)
-{
-
- WatchpointSP wp_sp = FindByID (watch_id);
- if (wp_sp)
- {
- // Let the Watchpoint decide if it should stop here (could not have
- // reached it's target hit count yet, or it could have a callback
- // that decided it shouldn't stop.
- return wp_sp->ShouldStop (context);
- }
- // We should stop here since this Watchpoint isn't valid anymore or it
- // doesn't exist.
- return true;
+bool WatchpointList::ShouldStop(StoppointCallbackContext *context,
+ lldb::watch_id_t watch_id) {
+
+ WatchpointSP wp_sp = FindByID(watch_id);
+ if (wp_sp) {
+ // Let the Watchpoint decide if it should stop here (could not have
+ // reached it's target hit count yet, or it could have a callback
+ // that decided it shouldn't stop.
+ return wp_sp->ShouldStop(context);
+ }
+ // We should stop here since this Watchpoint isn't valid anymore or it
+ // doesn't exist.
+ return true;
}
-void
-WatchpointList::GetDescription (Stream *s, lldb::DescriptionLevel level)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- wp_collection::iterator pos, end = m_watchpoints.end();
+void WatchpointList::GetDescription(Stream *s, lldb::DescriptionLevel level) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ wp_collection::iterator pos, end = m_watchpoints.end();
- for (pos = m_watchpoints.begin(); pos != end; ++pos)
- {
- s->Printf(" ");
- (*pos)->Dump(s);
- }
+ for (pos = m_watchpoints.begin(); pos != end; ++pos) {
+ s->Printf(" ");
+ (*pos)->Dump(s);
+ }
}
-void
-WatchpointList::SetEnabledAll (bool enabled)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
+void WatchpointList::SetEnabledAll(bool enabled) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
- wp_collection::iterator pos, end = m_watchpoints.end();
- for (pos = m_watchpoints.begin(); pos != end; ++pos)
- (*pos)->SetEnabled (enabled);
+ wp_collection::iterator pos, end = m_watchpoints.end();
+ for (pos = m_watchpoints.begin(); pos != end; ++pos)
+ (*pos)->SetEnabled(enabled);
}
-void
-WatchpointList::RemoveAll (bool notify)
-{
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- if (notify)
+void WatchpointList::RemoveAll(bool notify) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ if (notify) {
+
{
-
- {
- wp_collection::iterator pos, end = m_watchpoints.end();
- for (pos = m_watchpoints.begin(); pos != end; ++pos)
- {
- if ((*pos)->GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged))
- {
- (*pos)->GetTarget().BroadcastEvent (Target::eBroadcastBitWatchpointChanged,
- new Watchpoint::WatchpointEventData (eWatchpointEventTypeRemoved,
- *pos));
- }
- }
+ wp_collection::iterator pos, end = m_watchpoints.end();
+ for (pos = m_watchpoints.begin(); pos != end; ++pos) {
+ if ((*pos)->GetTarget().EventTypeHasListeners(
+ Target::eBroadcastBitBreakpointChanged)) {
+ (*pos)->GetTarget().BroadcastEvent(
+ Target::eBroadcastBitWatchpointChanged,
+ new Watchpoint::WatchpointEventData(eWatchpointEventTypeRemoved,
+ *pos));
}
+ }
}
- m_watchpoints.clear();
+ }
+ m_watchpoints.clear();
}
-void
-WatchpointList::GetListMutex(std::unique_lock<std::recursive_mutex> &lock)
-{
- lock = std::unique_lock<std::recursive_mutex>(m_mutex);
+void WatchpointList::GetListMutex(
+ std::unique_lock<std::recursive_mutex> &lock) {
+ lock = std::unique_lock<std::recursive_mutex>(m_mutex);
}
diff --git a/lldb/source/Breakpoint/WatchpointOptions.cpp b/lldb/source/Breakpoint/WatchpointOptions.cpp
index 365d884..1108f44 100644
--- a/lldb/source/Breakpoint/WatchpointOptions.cpp
+++ b/lldb/source/Breakpoint/WatchpointOptions.cpp
@@ -13,10 +13,10 @@
// Project includes
#include "lldb/Breakpoint/WatchpointOptions.h"
+#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StringList.h"
#include "lldb/Core/Value.h"
-#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadSpec.h"
@@ -24,63 +24,55 @@
using namespace lldb;
using namespace lldb_private;
-bool
-WatchpointOptions::NullCallback (void *baton, StoppointCallbackContext *context, lldb::user_id_t watch_id)
-{
- return true;
+bool WatchpointOptions::NullCallback(void *baton,
+ StoppointCallbackContext *context,
+ lldb::user_id_t watch_id) {
+ return true;
}
//----------------------------------------------------------------------
// WatchpointOptions constructor
//----------------------------------------------------------------------
-WatchpointOptions::WatchpointOptions() :
- m_callback (WatchpointOptions::NullCallback),
- m_callback_baton_sp (),
- m_callback_is_synchronous (false),
- m_thread_spec_ap ()
-{
-}
+WatchpointOptions::WatchpointOptions()
+ : m_callback(WatchpointOptions::NullCallback), m_callback_baton_sp(),
+ m_callback_is_synchronous(false), m_thread_spec_ap() {}
//----------------------------------------------------------------------
// WatchpointOptions copy constructor
//----------------------------------------------------------------------
-WatchpointOptions::WatchpointOptions(const WatchpointOptions& rhs) :
- m_callback (rhs.m_callback),
- m_callback_baton_sp (rhs.m_callback_baton_sp),
- m_callback_is_synchronous (rhs.m_callback_is_synchronous),
- m_thread_spec_ap ()
-{
- if (rhs.m_thread_spec_ap.get() != nullptr)
- m_thread_spec_ap.reset (new ThreadSpec(*rhs.m_thread_spec_ap.get()));
+WatchpointOptions::WatchpointOptions(const WatchpointOptions &rhs)
+ : m_callback(rhs.m_callback), m_callback_baton_sp(rhs.m_callback_baton_sp),
+ m_callback_is_synchronous(rhs.m_callback_is_synchronous),
+ m_thread_spec_ap() {
+ if (rhs.m_thread_spec_ap.get() != nullptr)
+ m_thread_spec_ap.reset(new ThreadSpec(*rhs.m_thread_spec_ap.get()));
}
//----------------------------------------------------------------------
// WatchpointOptions assignment operator
//----------------------------------------------------------------------
-const WatchpointOptions&
-WatchpointOptions::operator=(const WatchpointOptions& rhs)
-{
- m_callback = rhs.m_callback;
- m_callback_baton_sp = rhs.m_callback_baton_sp;
- m_callback_is_synchronous = rhs.m_callback_is_synchronous;
- if (rhs.m_thread_spec_ap.get() != nullptr)
- m_thread_spec_ap.reset(new ThreadSpec(*rhs.m_thread_spec_ap.get()));
- return *this;
+const WatchpointOptions &WatchpointOptions::
+operator=(const WatchpointOptions &rhs) {
+ m_callback = rhs.m_callback;
+ m_callback_baton_sp = rhs.m_callback_baton_sp;
+ m_callback_is_synchronous = rhs.m_callback_is_synchronous;
+ if (rhs.m_thread_spec_ap.get() != nullptr)
+ m_thread_spec_ap.reset(new ThreadSpec(*rhs.m_thread_spec_ap.get()));
+ return *this;
}
WatchpointOptions *
-WatchpointOptions::CopyOptionsNoCallback (WatchpointOptions &orig)
-{
- WatchpointHitCallback orig_callback = orig.m_callback;
- lldb::BatonSP orig_callback_baton_sp = orig.m_callback_baton_sp;
- bool orig_is_sync = orig.m_callback_is_synchronous;
-
- orig.ClearCallback();
- WatchpointOptions *ret_val = new WatchpointOptions(orig);
-
- orig.SetCallback (orig_callback, orig_callback_baton_sp, orig_is_sync);
-
- return ret_val;
+WatchpointOptions::CopyOptionsNoCallback(WatchpointOptions &orig) {
+ WatchpointHitCallback orig_callback = orig.m_callback;
+ lldb::BatonSP orig_callback_baton_sp = orig.m_callback_baton_sp;
+ bool orig_is_sync = orig.m_callback_is_synchronous;
+
+ orig.ClearCallback();
+ WatchpointOptions *ret_val = new WatchpointOptions(orig);
+
+ orig.SetCallback(orig_callback, orig_callback_baton_sp, orig_is_sync);
+
+ return ret_val;
}
//----------------------------------------------------------------------
@@ -91,147 +83,117 @@ WatchpointOptions::~WatchpointOptions() = default;
//------------------------------------------------------------------
// Callbacks
//------------------------------------------------------------------
-void
-WatchpointOptions::SetCallback (WatchpointHitCallback callback, const BatonSP &callback_baton_sp, bool callback_is_synchronous)
-{
- m_callback_is_synchronous = callback_is_synchronous;
- m_callback = callback;
- m_callback_baton_sp = callback_baton_sp;
+void WatchpointOptions::SetCallback(WatchpointHitCallback callback,
+ const BatonSP &callback_baton_sp,
+ bool callback_is_synchronous) {
+ m_callback_is_synchronous = callback_is_synchronous;
+ m_callback = callback;
+ m_callback_baton_sp = callback_baton_sp;
}
-void
-WatchpointOptions::ClearCallback ()
-{
- m_callback = WatchpointOptions::NullCallback;
- m_callback_is_synchronous = false;
- m_callback_baton_sp.reset();
+void WatchpointOptions::ClearCallback() {
+ m_callback = WatchpointOptions::NullCallback;
+ m_callback_is_synchronous = false;
+ m_callback_baton_sp.reset();
}
-Baton *
-WatchpointOptions::GetBaton ()
-{
- return m_callback_baton_sp.get();
-}
+Baton *WatchpointOptions::GetBaton() { return m_callback_baton_sp.get(); }
-const Baton *
-WatchpointOptions::GetBaton () const
-{
- return m_callback_baton_sp.get();
+const Baton *WatchpointOptions::GetBaton() const {
+ return m_callback_baton_sp.get();
}
-bool
-WatchpointOptions::InvokeCallback (StoppointCallbackContext *context,
- lldb::user_id_t watch_id)
-{
- if (m_callback && context->is_synchronous == IsCallbackSynchronous())
- {
- return m_callback(m_callback_baton_sp ? m_callback_baton_sp->m_data : nullptr,
- context,
- watch_id);
- }
- else
- return true;
+bool WatchpointOptions::InvokeCallback(StoppointCallbackContext *context,
+ lldb::user_id_t watch_id) {
+ if (m_callback && context->is_synchronous == IsCallbackSynchronous()) {
+ return m_callback(m_callback_baton_sp ? m_callback_baton_sp->m_data
+ : nullptr,
+ context, watch_id);
+ } else
+ return true;
}
-bool
-WatchpointOptions::HasCallback ()
-{
- return m_callback != WatchpointOptions::NullCallback;
+bool WatchpointOptions::HasCallback() {
+ return m_callback != WatchpointOptions::NullCallback;
}
-const ThreadSpec *
-WatchpointOptions::GetThreadSpecNoCreate () const
-{
- return m_thread_spec_ap.get();
+const ThreadSpec *WatchpointOptions::GetThreadSpecNoCreate() const {
+ return m_thread_spec_ap.get();
}
-ThreadSpec *
-WatchpointOptions::GetThreadSpec ()
-{
- if (m_thread_spec_ap.get() == nullptr)
- m_thread_spec_ap.reset (new ThreadSpec());
-
- return m_thread_spec_ap.get();
+ThreadSpec *WatchpointOptions::GetThreadSpec() {
+ if (m_thread_spec_ap.get() == nullptr)
+ m_thread_spec_ap.reset(new ThreadSpec());
+
+ return m_thread_spec_ap.get();
}
-void
-WatchpointOptions::SetThreadID (lldb::tid_t thread_id)
-{
- GetThreadSpec()->SetTID(thread_id);
+void WatchpointOptions::SetThreadID(lldb::tid_t thread_id) {
+ GetThreadSpec()->SetTID(thread_id);
}
-void
-WatchpointOptions::GetCallbackDescription (Stream *s, lldb::DescriptionLevel level) const
-{
- if (m_callback_baton_sp.get())
- {
- s->EOL();
- m_callback_baton_sp->GetDescription (s, level);
- }
+void WatchpointOptions::GetCallbackDescription(
+ Stream *s, lldb::DescriptionLevel level) const {
+ if (m_callback_baton_sp.get()) {
+ s->EOL();
+ m_callback_baton_sp->GetDescription(s, level);
+ }
}
-void
-WatchpointOptions::GetDescription (Stream *s, lldb::DescriptionLevel level) const
-{
- // Figure out if there are any options not at their default value, and only print
- // anything if there are:
-
- if ((GetThreadSpecNoCreate() != nullptr && GetThreadSpecNoCreate()->HasSpecification ()))
- {
- if (level == lldb::eDescriptionLevelVerbose)
- {
- s->EOL ();
- s->IndentMore();
- s->Indent();
- s->PutCString("Watchpoint Options:\n");
- s->IndentMore();
- s->Indent();
- }
- else
- s->PutCString(" Options: ");
-
- if (m_thread_spec_ap.get())
- m_thread_spec_ap->GetDescription (s, level);
- else if (level == eDescriptionLevelBrief)
- s->PutCString ("thread spec: no ");
- if (level == lldb::eDescriptionLevelFull)
- {
- s->IndentLess();
- s->IndentMore();
- }
+void WatchpointOptions::GetDescription(Stream *s,
+ lldb::DescriptionLevel level) const {
+ // Figure out if there are any options not at their default value, and only
+ // print
+ // anything if there are:
+
+ if ((GetThreadSpecNoCreate() != nullptr &&
+ GetThreadSpecNoCreate()->HasSpecification())) {
+ if (level == lldb::eDescriptionLevelVerbose) {
+ s->EOL();
+ s->IndentMore();
+ s->Indent();
+ s->PutCString("Watchpoint Options:\n");
+ s->IndentMore();
+ s->Indent();
+ } else
+ s->PutCString(" Options: ");
+
+ if (m_thread_spec_ap.get())
+ m_thread_spec_ap->GetDescription(s, level);
+ else if (level == eDescriptionLevelBrief)
+ s->PutCString("thread spec: no ");
+ if (level == lldb::eDescriptionLevelFull) {
+ s->IndentLess();
+ s->IndentMore();
}
-
- GetCallbackDescription(s, level);
+ }
+
+ GetCallbackDescription(s, level);
}
-void
-WatchpointOptions::CommandBaton::GetDescription (Stream *s, lldb::DescriptionLevel level) const
-{
- CommandData *data = (CommandData *)m_data;
+void WatchpointOptions::CommandBaton::GetDescription(
+ Stream *s, lldb::DescriptionLevel level) const {
+ CommandData *data = (CommandData *)m_data;
- if (level == eDescriptionLevelBrief)
- {
- s->Printf (", commands = %s", (data && data->user_source.GetSize() > 0) ? "yes" : "no");
- return;
- }
-
- s->IndentMore ();
- s->Indent("watchpoint commands:\n");
-
- s->IndentMore ();
- if (data && data->user_source.GetSize() > 0)
- {
- const size_t num_strings = data->user_source.GetSize();
- for (size_t i = 0; i < num_strings; ++i)
- {
- s->Indent(data->user_source.GetStringAtIndex(i));
- s->EOL();
- }
- }
- else
- {
- s->PutCString ("No commands.\n");
+ if (level == eDescriptionLevelBrief) {
+ s->Printf(", commands = %s",
+ (data && data->user_source.GetSize() > 0) ? "yes" : "no");
+ return;
+ }
+
+ s->IndentMore();
+ s->Indent("watchpoint commands:\n");
+
+ s->IndentMore();
+ if (data && data->user_source.GetSize() > 0) {
+ const size_t num_strings = data->user_source.GetSize();
+ for (size_t i = 0; i < num_strings; ++i) {
+ s->Indent(data->user_source.GetStringAtIndex(i));
+ s->EOL();
}
- s->IndentLess ();
- s->IndentLess ();
+ } else {
+ s->PutCString("No commands.\n");
+ }
+ s->IndentLess();
+ s->IndentLess();
}