diff options
author | Jim Ingham <jingham@apple.com> | 2010-06-16 02:00:15 +0000 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2010-06-16 02:00:15 +0000 |
commit | 1b54c88cc4f8582222644d65dfd61703206430ef (patch) | |
tree | 8f720e2946e32ece13de194e4ccfafffa21d9b3f /lldb/source/Breakpoint | |
parent | babff2ce5644a5f2af3a9cac323c1a97f39a90a1 (diff) | |
download | bcm5719-llvm-1b54c88cc4f8582222644d65dfd61703206430ef.tar.gz bcm5719-llvm-1b54c88cc4f8582222644d65dfd61703206430ef.zip |
Add a "thread specification" class that specifies thread specific breakpoints by name, index, queue or TID.
Push this through all the breakpoint management code. Allow this to be set when the breakpoint is created.
Fix the Process classes so that a breakpoint hit that is not for a particular thread is not reported as a
breakpoint hit event for that thread.
Added a "breakpoint configure" command to allow you to reset any of the thread
specific options (or the ignore count.)
llvm-svn: 106078
Diffstat (limited to 'lldb/source/Breakpoint')
-rw-r--r-- | lldb/source/Breakpoint/Breakpoint.cpp | 8 | ||||
-rw-r--r-- | lldb/source/Breakpoint/BreakpointList.cpp | 6 | ||||
-rw-r--r-- | lldb/source/Breakpoint/BreakpointLocation.cpp | 40 | ||||
-rw-r--r-- | lldb/source/Breakpoint/BreakpointLocationCollection.cpp | 18 | ||||
-rw-r--r-- | lldb/source/Breakpoint/BreakpointOptions.cpp | 37 | ||||
-rw-r--r-- | lldb/source/Breakpoint/BreakpointSite.cpp | 9 | ||||
-rw-r--r-- | lldb/source/Breakpoint/StoppointLocation.cpp | 12 | ||||
-rw-r--r-- | lldb/source/Breakpoint/WatchpointLocation.cpp | 1 |
8 files changed, 90 insertions, 41 deletions
diff --git a/lldb/source/Breakpoint/Breakpoint.cpp b/lldb/source/Breakpoint/Breakpoint.cpp index c475cf0f0d7..b3576b6a5da 100644 --- a/lldb/source/Breakpoint/Breakpoint.cpp +++ b/lldb/source/Breakpoint/Breakpoint.cpp @@ -24,6 +24,7 @@ #include "lldb/Core/StreamString.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Target/Target.h" +#include "lldb/Target/ThreadSpec.h" #include "lldb/lldb-private-log.h" using namespace lldb; @@ -166,13 +167,16 @@ Breakpoint::GetIgnoreCount () const void Breakpoint::SetThreadID (lldb::tid_t thread_id) { - m_options.SetThreadID(thread_id); + m_options.GetThreadSpec()->SetTID(thread_id); } lldb::tid_t Breakpoint::GetThreadID () { - return m_options.GetThreadID(); + if (m_options.GetThreadSpec() == NULL) + return LLDB_INVALID_THREAD_ID; + else + return m_options.GetThreadSpec()->GetTID(); } // This function is used when "baton" doesn't need to be freed diff --git a/lldb/source/Breakpoint/BreakpointList.cpp b/lldb/source/Breakpoint/BreakpointList.cpp index c10aa770b82..0d9444f7371 100644 --- a/lldb/source/Breakpoint/BreakpointList.cpp +++ b/lldb/source/Breakpoint/BreakpointList.cpp @@ -196,3 +196,9 @@ BreakpointList::ClearAllBreakpointSites () (*pos)->ClearAllBreakpointSites (); } + +void +BreakpointList::GetListMutex (Mutex::Locker &locker) +{ + return locker.Reset (m_mutex.GetMutex()); +} diff --git a/lldb/source/Breakpoint/BreakpointLocation.cpp b/lldb/source/Breakpoint/BreakpointLocation.cpp index 0f82829bdd7..e00afcad750 100644 --- a/lldb/source/Breakpoint/BreakpointLocation.cpp +++ b/lldb/source/Breakpoint/BreakpointLocation.cpp @@ -22,6 +22,7 @@ #include "lldb/Core/StreamString.h" #include "lldb/lldb-private-log.h" #include "lldb/Target/Thread.h" +#include "lldb/Target/ThreadSpec.h" using namespace lldb; using namespace lldb_private; @@ -34,12 +35,13 @@ BreakpointLocation::BreakpointLocation lldb::tid_t tid, bool hardware ) : - StoppointLocation (loc_id, addr.GetLoadAddress(owner.GetTarget().GetProcessSP().get()), tid, hardware), + StoppointLocation (loc_id, addr.GetLoadAddress(owner.GetTarget().GetProcessSP().get()), hardware), m_address (addr), m_owner (owner), m_options_ap (), m_bp_site_sp () { + SetThreadID (tid); } BreakpointLocation::~BreakpointLocation() @@ -93,13 +95,15 @@ BreakpointLocation::SetEnabled (bool enabled) void BreakpointLocation::SetThreadID (lldb::tid_t thread_id) { - GetLocationOptions()->SetThreadID(thread_id); -} - -lldb::tid_t -BreakpointLocation::GetThreadID () -{ - return GetOptionsNoCopy()->GetThreadID(); + 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() != NULL) + m_options_ap->SetThreadID (thread_id); + } } bool @@ -150,8 +154,8 @@ BreakpointLocation::SetIgnoreCount (int32_t n) GetLocationOptions()->SetIgnoreCount(n); } -BreakpointOptions * -BreakpointLocation::GetOptionsNoCopy () +const BreakpointOptions * +BreakpointLocation::GetOptionsNoCopy () const { if (m_options_ap.get() != NULL) return m_options_ap.get(); @@ -168,8 +172,16 @@ BreakpointLocation::GetLocationOptions () return m_options_ap.get(); } +bool +BreakpointLocation::ValidForThisThread (Thread *thread) +{ + return thread->MatchesSpec(GetOptionsNoCopy()->GetThreadSpec()); +} + // RETURNS - true if we should stop at this breakpoint, false if we -// should continue. +// should continue. Note, we don't check the thread spec for the breakpoint +// 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) @@ -181,10 +193,6 @@ BreakpointLocation::ShouldStop (StoppointCallbackContext *context) if (!IsEnabled()) return false; - if (GetThreadID() != LLDB_INVALID_THREAD_ID - && context->context.thread->GetID() != GetThreadID()) - return false; - if (m_hit_count <= GetIgnoreCount()) return false; @@ -379,7 +387,7 @@ BreakpointLocation::Dump(Stream *s) const s->Printf("BreakpointLocation %u: tid = %4.4x load addr = 0x%8.8llx state = %s type = %s breakpoint hw_index = %i hit_count = %-4u ignore_count = %-4u", GetID(), - m_tid, + GetOptionsNoCopy()->GetThreadSpec()->GetTID(), (uint64_t) m_address.GetLoadAddress(m_owner.GetTarget().GetProcessSP().get()), (m_options_ap.get() ? m_options_ap->IsEnabled() : m_owner.IsEnabled()) ? "enabled " : "disabled", IsHardware() ? "hardware" : "software", diff --git a/lldb/source/Breakpoint/BreakpointLocationCollection.cpp b/lldb/source/Breakpoint/BreakpointLocationCollection.cpp index 7b574263003..464d38f1d78 100644 --- a/lldb/source/Breakpoint/BreakpointLocationCollection.cpp +++ b/lldb/source/Breakpoint/BreakpointLocationCollection.cpp @@ -16,6 +16,8 @@ #include "lldb/Core/ModuleList.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/BreakpointLocationList.h" +#include "lldb/Target/Thread.h" +#include "lldb/Target/ThreadSpec.h" using namespace lldb; using namespace lldb_private; @@ -145,6 +147,22 @@ BreakpointLocationCollection::ShouldStop (StoppointCallbackContext *context) return shouldStop; } +bool +BreakpointLocationCollection::ValidForThisThread (Thread *thread) +{ + 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) { diff --git a/lldb/source/Breakpoint/BreakpointOptions.cpp b/lldb/source/Breakpoint/BreakpointOptions.cpp index 4f664c4692f..695f4ee5ccd 100644 --- a/lldb/source/Breakpoint/BreakpointOptions.cpp +++ b/lldb/source/Breakpoint/BreakpointOptions.cpp @@ -16,6 +16,7 @@ #include "lldb/Core/Stream.h" #include "lldb/Core/StringList.h" #include "lldb/Breakpoint/StoppointCallbackContext.h" +#include "lldb/Target/ThreadSpec.h" using namespace lldb; using namespace lldb_private; @@ -35,7 +36,7 @@ BreakpointOptions::BreakpointOptions() : m_callback_baton_sp (), m_enabled (true), m_ignore_count (0), - m_thread_id (LLDB_INVALID_THREAD_ID) + m_thread_spec_ap (NULL) { } @@ -48,8 +49,10 @@ BreakpointOptions::BreakpointOptions(const BreakpointOptions& rhs) : m_callback_is_synchronous (rhs.m_callback_is_synchronous), m_enabled (rhs.m_enabled), m_ignore_count (rhs.m_ignore_count), - m_thread_id (rhs.m_thread_id) + m_thread_spec_ap (NULL) { + if (rhs.m_thread_spec_ap.get() != NULL) + m_thread_spec_ap.reset (new ThreadSpec(*rhs.m_thread_spec_ap.get())); } //---------------------------------------------------------------------- @@ -63,7 +66,8 @@ BreakpointOptions::operator=(const BreakpointOptions& rhs) m_callback_is_synchronous = rhs.m_callback_is_synchronous; m_enabled = rhs.m_enabled; m_ignore_count = rhs.m_ignore_count; - m_thread_id = rhs.m_thread_id; + if (rhs.m_thread_spec_ap.get() != NULL) + m_thread_spec_ap.reset(new ThreadSpec(*rhs.m_thread_spec_ap.get())); return *this; } @@ -98,6 +102,12 @@ BreakpointOptions::GetBaton () 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, @@ -141,19 +151,26 @@ BreakpointOptions::SetIgnoreCount (int32_t n) m_ignore_count = n; } -void -BreakpointOptions::SetThreadID (lldb::tid_t thread_id) +const ThreadSpec * +BreakpointOptions::GetThreadSpec () const { - m_thread_id = thread_id; + return m_thread_spec_ap.get(); } -lldb::tid_t -BreakpointOptions::GetThreadID () const +ThreadSpec * +BreakpointOptions::GetThreadSpec () { - return m_thread_id; + if (m_thread_spec_ap.get() == NULL) + 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::CommandBaton::GetDescription (Stream *s, lldb::DescriptionLevel level) const diff --git a/lldb/source/Breakpoint/BreakpointSite.cpp b/lldb/source/Breakpoint/BreakpointSite.cpp index cd0920d07c7..d9397fcb412 100644 --- a/lldb/source/Breakpoint/BreakpointSite.cpp +++ b/lldb/source/Breakpoint/BreakpointSite.cpp @@ -80,9 +80,8 @@ BreakpointSite::Dump(Stream *s) const if (s == NULL) return; - s->Printf("BreakpointSite %u: tid = %4.4x addr = 0x%8.8llx type = %s breakpoint hw_index = %i hit_count = %-4u", + s->Printf("BreakpointSite %u: addr = 0x%8.8llx type = %s breakpoint hw_index = %i hit_count = %-4u", GetID(), - m_tid, (uint64_t)m_addr, IsHardware() ? "hardware" : "software", GetHardwareIndex(), @@ -178,6 +177,12 @@ BreakpointSite::GetOwnerAtIndex (uint32_t index) } bool +BreakpointSite::ValidForThisThread (Thread *thread) +{ + return m_owners.ValidForThisThread(thread); +} + +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 diff --git a/lldb/source/Breakpoint/StoppointLocation.cpp b/lldb/source/Breakpoint/StoppointLocation.cpp index 999ad536ab8..60280ef2748 100644 --- a/lldb/source/Breakpoint/StoppointLocation.cpp +++ b/lldb/source/Breakpoint/StoppointLocation.cpp @@ -20,9 +20,8 @@ using namespace lldb_private; //---------------------------------------------------------------------- // StoppointLocation constructor //---------------------------------------------------------------------- -StoppointLocation::StoppointLocation (break_id_t bid, addr_t addr, tid_t tid, bool hardware) : +StoppointLocation::StoppointLocation (break_id_t bid, addr_t addr, bool hardware) : m_loc_id(bid), - m_tid(tid), m_byte_size(0), m_addr(addr), m_hit_count(0), @@ -31,9 +30,8 @@ StoppointLocation::StoppointLocation (break_id_t bid, addr_t addr, tid_t tid, bo { } -StoppointLocation::StoppointLocation (break_id_t bid, addr_t addr, tid_t tid, size_t size, bool hardware) : +StoppointLocation::StoppointLocation (break_id_t bid, addr_t addr, size_t size, bool hardware) : m_loc_id(bid), - m_tid(tid), m_byte_size(size), m_addr(addr), m_hit_count(0), @@ -62,12 +60,6 @@ StoppointLocation::GetLoadAddress() const return m_addr; } -tid_t -StoppointLocation::GetThreadID() const -{ - return m_tid; -} - uint32_t StoppointLocation::GetHitCount () const { diff --git a/lldb/source/Breakpoint/WatchpointLocation.cpp b/lldb/source/Breakpoint/WatchpointLocation.cpp index f765ef43202..bf24421a091 100644 --- a/lldb/source/Breakpoint/WatchpointLocation.cpp +++ b/lldb/source/Breakpoint/WatchpointLocation.cpp @@ -79,7 +79,6 @@ WatchpointLocation::Dump(Stream *s) const s->Printf("WatchpointLocation %u: tid = %4.4x addr = 0x%8.8llx size = %zu state = %s type = %s watchpoint (%s%s) hw_index = %i hit_count = %-4u ignore_count = %-4u callback = %8p baton = %8p", GetID(), - m_tid, (uint64_t)m_addr, m_byte_size, m_enabled ? "enabled " : "disabled", |