diff options
Diffstat (limited to 'source/Target/StopInfo.cpp')
-rw-r--r-- | source/Target/StopInfo.cpp | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/source/Target/StopInfo.cpp b/source/Target/StopInfo.cpp index 457b94c1dc20..76e5f374f952 100644 --- a/source/Target/StopInfo.cpp +++ b/source/Target/StopInfo.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "lldb/Target/StopInfo.h" // C Includes @@ -24,6 +22,7 @@ #include "lldb/Breakpoint/Watchpoint.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/StreamString.h" +#include "lldb/Core/ValueObject.h" #include "lldb/Expression/ClangUserExpression.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" @@ -39,6 +38,7 @@ StopInfo::StopInfo (Thread &thread, uint64_t value) : m_stop_id (thread.GetProcess()->GetStopID()), m_resume_id (thread.GetProcess()->GetResumeID()), m_value (value), + m_description (), m_override_should_notify (eLazyBoolCalculate), m_override_should_stop (eLazyBoolCalculate), m_extended_info() @@ -111,7 +111,6 @@ class StopInfoBreakpoint : public StopInfo public: StopInfoBreakpoint (Thread &thread, break_id_t break_id) : StopInfo (thread, break_id), - m_description(), m_should_stop (false), m_should_stop_is_valid (false), m_should_perform_action (true), @@ -124,7 +123,6 @@ public: StopInfoBreakpoint (Thread &thread, break_id_t break_id, bool should_stop) : StopInfo (thread, break_id), - m_description(), m_should_stop (should_stop), m_should_stop_is_valid (true), m_should_perform_action (true), @@ -162,6 +160,19 @@ public: { } + virtual bool + IsValidForOperatingSystemThread (Thread &thread) + { + ProcessSP process_sp (thread.GetProcess()); + if (process_sp) + { + BreakpointSiteSP bp_site_sp (process_sp->GetBreakpointSiteList().FindByID (m_value)); + if (bp_site_sp) + return bp_site_sp->ValidForThisThread (&thread); + } + return false; + } + virtual StopReason GetStopReason () const { @@ -335,6 +346,7 @@ protected: } BreakpointSiteSP bp_site_sp (thread_sp->GetProcess()->GetBreakpointSiteList().FindByID (m_value)); + std::unordered_set<break_id_t> precondition_breakpoints; if (bp_site_sp) { @@ -346,7 +358,9 @@ protected: } else { - // We go through each location, and test first its condition. If the condition says to stop, + // We go through each location, and test first its precondition - this overrides everything. Note, + // we only do this once per breakpoint - not once per location... + // Then check the condition. If the condition says to stop, // then we run the callback for that location. If that callback says to stop as well, then // we set m_should_stop to true; we are going to stop. // But we still want to give all the breakpoints whose conditions say we are going to stop a @@ -442,7 +456,19 @@ protected: } continue; } - // First run the condition for the breakpoint. If that says we should stop, then we'll run + + // First run the precondition, but since the precondition is per breakpoint, only run it once + // per breakpoint. + std::pair<std::unordered_set<break_id_t>::iterator, bool> result + = precondition_breakpoints.insert(bp_loc_sp->GetBreakpoint().GetID()); + if (!result.second) + continue; + + bool precondition_result = bp_loc_sp->GetBreakpoint().EvaluatePrecondition(context); + if (!precondition_result) + continue; + + // Next run the condition for the breakpoint. If that says we should stop, then we'll run // the callback for the breakpoint. If the callback says we shouldn't stop that will win. if (bp_loc_sp->GetConditionText() != NULL) @@ -539,7 +565,6 @@ protected: } private: - std::string m_description; bool m_should_stop; bool m_should_stop_is_valid; bool m_should_perform_action; // Since we are trying to preserve the "state" of the system even if we run functions @@ -592,7 +617,6 @@ public: StopInfoWatchpoint (Thread &thread, break_id_t watch_id) : StopInfo(thread, watch_id), - m_description(), m_should_stop(false), m_should_stop_is_valid(false) { @@ -831,7 +855,6 @@ protected: } private: - std::string m_description; bool m_should_stop; bool m_should_stop_is_valid; }; @@ -846,9 +869,10 @@ class StopInfoUnixSignal : public StopInfo { public: - StopInfoUnixSignal (Thread &thread, int signo) : + StopInfoUnixSignal (Thread &thread, int signo, const char *description) : StopInfo (thread, signo) { + SetDescription (description); } virtual ~StopInfoUnixSignal () @@ -1136,9 +1160,9 @@ StopInfo::CreateStopReasonWithWatchpointID (Thread &thread, break_id_t watch_id) } StopInfoSP -StopInfo::CreateStopReasonWithSignal (Thread &thread, int signo) +StopInfo::CreateStopReasonWithSignal (Thread &thread, int signo, const char *description) { - return StopInfoSP (new StopInfoUnixSignal (thread, signo)); + return StopInfoSP (new StopInfoUnixSignal (thread, signo, description)); } StopInfoSP |