diff options
author | Greg Clayton <gclayton@apple.com> | 2010-11-18 18:52:36 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2010-11-18 18:52:36 +0000 |
commit | 4e78f60660890d36c01e882339cc3f0ddb62a993 (patch) | |
tree | d53650386e238ca07777793abdc4c51e059462ec /lldb/source/API/SBThread.cpp | |
parent | 745f9996d0b35d5dd21622c19e61f633038409b9 (diff) | |
download | bcm5719-llvm-4e78f60660890d36c01e882339cc3f0ddb62a993.tar.gz bcm5719-llvm-4e78f60660890d36c01e882339cc3f0ddb62a993.zip |
Added the ability to get more information on the SBThread's stop reason
by being able to get the data count and data. Each thread stop reason
has one or more data words that can help describe the stop. To do this
I added:
size_t
SBThread::GetStopReasonDataCount();
uint64_t
SBThread::GetStopReasonDataAtIndex(uint32_t idx);
llvm-svn: 119720
Diffstat (limited to 'lldb/source/API/SBThread.cpp')
-rw-r--r-- | lldb/source/API/SBThread.cpp | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp index 9470a8b7110..a2dde2d376c 100644 --- a/lldb/source/API/SBThread.cpp +++ b/lldb/source/API/SBThread.cpp @@ -12,6 +12,7 @@ #include "lldb/API/SBSymbolContext.h" #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBStream.h" +#include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Stream.h" #include "lldb/Core/StreamFile.h" @@ -109,6 +110,109 @@ SBThread::GetStopReason() } size_t +SBThread::GetStopReasonDataCount () +{ + if (m_opaque_sp) + { + StopInfoSP stop_info_sp = m_opaque_sp->GetStopInfo (); + if (stop_info_sp) + { + StopReason reason = stop_info_sp->GetStopReason(); + switch (reason) + { + case eStopReasonInvalid: + case eStopReasonNone: + case eStopReasonTrace: + case eStopReasonPlanComplete: + // There is no data for these stop reasons. + return 0; + + case eStopReasonBreakpoint: + { + break_id_t site_id = stop_info_sp->GetValue(); + lldb::BreakpointSiteSP bp_site_sp (m_opaque_sp->GetProcess().GetBreakpointSiteList().FindByID (site_id)); + if (bp_site_sp) + return bp_site_sp->GetNumberOfOwners () * 2; + else + return 0; // Breakpoint must have cleared itself... + } + break; + + case eStopReasonWatchpoint: + assert (!"implement watchpoint support in SBThread::GetStopReasonDataCount ()"); + return 0; // We don't have watchpoint support yet... + + case eStopReasonSignal: + return 1; + + case eStopReasonException: + return 1; + } + } + } + return 0; +} + +uint64_t +SBThread::GetStopReasonDataAtIndex (uint32_t idx) +{ + if (m_opaque_sp) + { + StopInfoSP stop_info_sp = m_opaque_sp->GetStopInfo (); + if (stop_info_sp) + { + StopReason reason = stop_info_sp->GetStopReason(); + switch (reason) + { + case eStopReasonInvalid: + case eStopReasonNone: + case eStopReasonTrace: + case eStopReasonPlanComplete: + // There is no data for these stop reasons. + return 0; + + case eStopReasonBreakpoint: + { + break_id_t site_id = stop_info_sp->GetValue(); + lldb::BreakpointSiteSP bp_site_sp (m_opaque_sp->GetProcess().GetBreakpointSiteList().FindByID (site_id)); + if (bp_site_sp) + { + uint32_t bp_index = idx / 2; + BreakpointLocationSP bp_loc_sp (bp_site_sp->GetOwnerAtIndex (bp_index)); + if (bp_loc_sp) + { + if (bp_index & 1) + { + // Odd idx, return the breakpoint location ID + return bp_loc_sp->GetID(); + } + else + { + // Even idx, return the breakpoint ID + return bp_loc_sp->GetBreakpoint().GetID(); + } + } + } + return LLDB_INVALID_BREAK_ID; + } + break; + + case eStopReasonWatchpoint: + assert (!"implement watchpoint support in SBThread::GetStopReasonDataCount ()"); + return 0; // We don't have watchpoint support yet... + + case eStopReasonSignal: + return stop_info_sp->GetValue(); + + case eStopReasonException: + return stop_info_sp->GetValue(); + } + } + } + return 0; +} + +size_t SBThread::GetStopDescription (char *dst, size_t dst_len) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |