diff options
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Target/StopInfo.cpp')
-rw-r--r-- | contrib/llvm/tools/lldb/source/Target/StopInfo.cpp | 237 |
1 files changed, 111 insertions, 126 deletions
diff --git a/contrib/llvm/tools/lldb/source/Target/StopInfo.cpp b/contrib/llvm/tools/lldb/source/Target/StopInfo.cpp index 9bbb00d..e88b646 100644 --- a/contrib/llvm/tools/lldb/source/Target/StopInfo.cpp +++ b/contrib/llvm/tools/lldb/source/Target/StopInfo.cpp @@ -1,4 +1,4 @@ -//===-- StopInfo.cpp ---------------------------------------------*- C++ -*-===// +//===-- StopInfo.cpp --------------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,14 +7,13 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Target/StopInfo.h" - // C Includes // C++ Includes #include <string> // Other libraries and framework includes // Project includes +#include "lldb/Target/StopInfo.h" #include "lldb/Core/Log.h" #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" @@ -23,7 +22,7 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/StreamString.h" #include "lldb/Core/ValueObject.h" -#include "lldb/Expression/ClangUserExpression.h" +#include "lldb/Expression/UserExpression.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" @@ -133,6 +132,8 @@ public: StoreBPInfo(); } + ~StopInfoBreakpoint() override = default; + void StoreBPInfo () { @@ -156,12 +157,8 @@ public: } } - virtual ~StopInfoBreakpoint () - { - } - - virtual bool - IsValidForOperatingSystemThread (Thread &thread) + bool + IsValidForOperatingSystemThread(Thread &thread) override { ProcessSP process_sp (thread.GetProcess()); if (process_sp) @@ -173,14 +170,14 @@ public: return false; } - virtual StopReason - GetStopReason () const + StopReason + GetStopReason() const override { return eStopReasonBreakpoint; } - virtual bool - ShouldStopSynchronous (Event *event_ptr) + bool + ShouldStopSynchronous(Event *event_ptr) override { ThreadSP thread_sp (m_thread_wp.lock()); if (thread_sp) @@ -212,8 +209,8 @@ public: return false; } - virtual bool - DoShouldNotify (Event *event_ptr) + bool + DoShouldNotify(Event *event_ptr) override { ThreadSP thread_sp (m_thread_wp.lock()); if (thread_sp) @@ -237,8 +234,8 @@ public: return true; } - virtual const char * - GetDescription () + const char * + GetDescription() override { if (m_description.empty()) { @@ -312,7 +309,7 @@ public: protected: bool - ShouldStop (Event *event_ptr) + ShouldStop(Event *event_ptr) override { // This just reports the work done by PerformAction or the synchronous stop. It should // only ever get called after they have had a chance to run. @@ -320,8 +317,8 @@ protected: return m_should_stop; } - virtual void - PerformAction (Event *event_ptr) + void + PerformAction(Event *event_ptr) override { if (!m_should_perform_action) return; @@ -350,7 +347,10 @@ protected: if (bp_site_sp) { - size_t num_owners = bp_site_sp->GetNumberOfOwners(); + // Let's copy the owners list out of the site and store them in a local list. That way if + // one of the breakpoint actions changes the site, then we won't be operating on a bad list. + BreakpointLocationCollection site_locations; + size_t num_owners = bp_site_sp->CopyOwnersList(site_locations); if (num_owners == 0) { @@ -416,20 +416,16 @@ protected: StoppointCallbackContext context (event_ptr, exe_ctx, false); - // Let's copy the breakpoint locations out of the site and store them in a local list. That way if - // one of the breakpoint actions changes the site, then we won't be operating on a bad list. // For safety's sake let's also grab an extra reference to the breakpoint owners of the locations we're // going to examine, since the locations are going to have to get back to their breakpoints, and the // locations don't keep their owners alive. I'm just sticking the BreakpointSP's in a vector since - // I'm only really using it to locally increment their retain counts. + // I'm only using it to locally increment their retain counts. - BreakpointLocationCollection site_locations; std::vector<lldb::BreakpointSP> location_owners; for (size_t j = 0; j < num_owners; j++) { - BreakpointLocationSP loc(bp_site_sp->GetOwnerAtIndex(j)); - site_locations.Add(loc); + BreakpointLocationSP loc(site_locations.GetByIndex(j)); location_owners.push_back(loc->GetBreakpoint().shared_from_this()); } @@ -576,7 +572,6 @@ private: bool m_was_one_shot; }; - //---------------------------------------------------------------------- // StopInfoWatchpoint //---------------------------------------------------------------------- @@ -598,6 +593,7 @@ public: process->DisableWatchpoint(watchpoint, notify); } } + ~WatchpointSentry() { if (process && watchpoint) @@ -610,6 +606,7 @@ public: watchpoint->TurnOffEphemeralMode(); } } + private: Process *process; Watchpoint *watchpoint; @@ -622,19 +619,17 @@ public: m_watch_hit_addr(watch_hit_addr) { } - - virtual ~StopInfoWatchpoint () - { - } - virtual StopReason - GetStopReason () const + ~StopInfoWatchpoint() override = default; + + StopReason + GetStopReason() const override { return eStopReasonWatchpoint; } - virtual const char * - GetDescription () + const char * + GetDescription() override { if (m_description.empty()) { @@ -646,8 +641,8 @@ public: } protected: - virtual bool - ShouldStopSynchronous (Event *event_ptr) + bool + ShouldStopSynchronous(Event *event_ptr) override { // ShouldStop() method is idempotent and should not affect hit count. // See Process::RunPrivateStateThread()->Process()->HandlePrivateEvent() @@ -686,7 +681,7 @@ protected: } bool - ShouldStop (Event *event_ptr) + ShouldStop(Event *event_ptr) override { // This just reports the work done by PerformAction or the synchronous stop. It should // only ever get called after they have had a chance to run. @@ -694,8 +689,8 @@ protected: return m_should_stop; } - virtual void - PerformAction (Event *event_ptr) + void + PerformAction(Event *event_ptr) override { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS); // We're going to calculate if we should stop or not in some way during the course of @@ -758,9 +753,22 @@ protected: { WatchpointSP wp_hit_sp = thread_sp->CalculateTarget()->GetWatchpointList().FindByAddress(m_watch_hit_addr); if (!wp_hit_sp) + { m_should_stop = false; + wp_sp->IncrementFalseAlarmsAndReviseHitCount(); + } } - + + // TODO: This condition should be checked in the synchronous part of the watchpoint code + // (Watchpoint::ShouldStop), so that we avoid pulling an event even if the watchpoint fails + // the ignore count condition. It is moved here temporarily, because for archs with + // watchpoint_exceptions_received=before, the code in the previous lines takes care of moving + // the inferior to next PC. We have to check the ignore count condition after this is done, + // otherwise we will hit same watchpoint multiple times until we pass ignore condition, but we + // won't actually be ignoring them. + if (wp_sp->GetHitCount() <= wp_sp->GetIgnoreCount()) + m_should_stop = false; + if (m_should_stop && wp_sp->GetConditionText() != NULL) { // We need to make sure the user sees any parse errors in their condition, so we'll hook the @@ -771,12 +779,13 @@ protected: expr_options.SetIgnoreBreakpoints(true); ValueObjectSP result_value_sp; Error error; - result_code = ClangUserExpression::Evaluate (exe_ctx, - expr_options, - wp_sp->GetConditionText(), - NULL, - result_value_sp, - error); + result_code = UserExpression::Evaluate (exe_ctx, + expr_options, + wp_sp->GetConditionText(), + NULL, + result_value_sp, + error); + if (result_code == eExpressionCompleted) { if (result_value_sp) @@ -876,8 +885,6 @@ private: lldb::addr_t m_watch_hit_addr; }; - - //---------------------------------------------------------------------- // StopInfoUnixSignal //---------------------------------------------------------------------- @@ -885,26 +892,22 @@ private: class StopInfoUnixSignal : public StopInfo { public: - StopInfoUnixSignal (Thread &thread, int signo, const char *description) : StopInfo (thread, signo) { SetDescription (description); } - - virtual ~StopInfoUnixSignal () - { - } + ~StopInfoUnixSignal() override = default; - virtual StopReason - GetStopReason () const + StopReason + GetStopReason() const override { return eStopReasonSignal; } - virtual bool - ShouldStopSynchronous (Event *event_ptr) + bool + ShouldStopSynchronous(Event *event_ptr) override { ThreadSP thread_sp (m_thread_wp.lock()); if (thread_sp) @@ -912,19 +915,18 @@ public: return false; } - virtual bool - ShouldStop (Event *event_ptr) + bool + ShouldStop(Event *event_ptr) override { ThreadSP thread_sp (m_thread_wp.lock()); if (thread_sp) return thread_sp->GetProcess()->GetUnixSignals()->GetShouldStop(m_value); return false; } - - + // If should stop returns false, check if we should notify of this event - virtual bool - DoShouldNotify (Event *event_ptr) + bool + DoShouldNotify(Event *event_ptr) override { ThreadSP thread_sp (m_thread_wp.lock()); if (thread_sp) @@ -943,9 +945,8 @@ public: return true; } - - virtual void - WillResume (lldb::StateType resume_state) + void + WillResume(lldb::StateType resume_state) override { ThreadSP thread_sp (m_thread_wp.lock()); if (thread_sp) @@ -955,8 +956,8 @@ public: } } - virtual const char * - GetDescription () + const char * + GetDescription() override { if (m_description.empty()) { @@ -983,33 +984,29 @@ public: class StopInfoTrace : public StopInfo { public: - StopInfoTrace (Thread &thread) : StopInfo (thread, LLDB_INVALID_UID) { } - - virtual ~StopInfoTrace () - { - } - - virtual StopReason - GetStopReason () const + + ~StopInfoTrace() override = default; + + StopReason + GetStopReason() const override { return eStopReasonTrace; } - virtual const char * - GetDescription () + const char * + GetDescription() override { if (m_description.empty()) - return "trace"; + return "trace"; else return m_description.c_str(); } }; - //---------------------------------------------------------------------- // StopInfoException //---------------------------------------------------------------------- @@ -1017,27 +1014,23 @@ public: class StopInfoException : public StopInfo { public: - StopInfoException (Thread &thread, const char *description) : StopInfo (thread, LLDB_INVALID_UID) { if (description) SetDescription (description); } - - virtual - ~StopInfoException () - { - } - - virtual StopReason - GetStopReason () const + + ~StopInfoException() override = default; + + StopReason + GetStopReason() const override { return eStopReasonException; } - virtual const char * - GetDescription () + const char * + GetDescription() override { if (m_description.empty()) return "exception"; @@ -1046,7 +1039,6 @@ public: } }; - //---------------------------------------------------------------------- // StopInfoThreadPlan //---------------------------------------------------------------------- @@ -1054,27 +1046,24 @@ public: class StopInfoThreadPlan : public StopInfo { public: - - StopInfoThreadPlan (ThreadPlanSP &plan_sp, ValueObjectSP &return_valobj_sp, ClangExpressionVariableSP &expression_variable_sp) : + StopInfoThreadPlan (ThreadPlanSP &plan_sp, ValueObjectSP &return_valobj_sp, ExpressionVariableSP &expression_variable_sp) : StopInfo (plan_sp->GetThread(), LLDB_INVALID_UID), m_plan_sp (plan_sp), m_return_valobj_sp (return_valobj_sp), m_expression_variable_sp (expression_variable_sp) { } - - virtual ~StopInfoThreadPlan () - { - } - virtual StopReason - GetStopReason () const + ~StopInfoThreadPlan() override = default; + + StopReason + GetStopReason() const override { return eStopReasonPlanComplete; } - virtual const char * - GetDescription () + const char * + GetDescription() override { if (m_description.empty()) { @@ -1091,15 +1080,15 @@ public: return m_return_valobj_sp; } - ClangExpressionVariableSP + ExpressionVariableSP GetExpressionVariable() { return m_expression_variable_sp; } protected: - virtual bool - ShouldStop (Event *event_ptr) + bool + ShouldStop(Event *event_ptr) override { if (m_plan_sp) return m_plan_sp->ShouldStop(event_ptr); @@ -1110,39 +1099,35 @@ protected: private: ThreadPlanSP m_plan_sp; ValueObjectSP m_return_valobj_sp; - ClangExpressionVariableSP m_expression_variable_sp; + ExpressionVariableSP m_expression_variable_sp; }; class StopInfoExec : public StopInfo { public: - StopInfoExec (Thread &thread) : StopInfo (thread, LLDB_INVALID_UID), m_performed_action (false) { } - - virtual - ~StopInfoExec () - { - } - - virtual StopReason - GetStopReason () const + + ~StopInfoExec() override = default; + + StopReason + GetStopReason() const override { return eStopReasonExec; } - virtual const char * - GetDescription () + const char * + GetDescription() override { return "exec"; } + protected: - - virtual void - PerformAction (Event *event_ptr) + void + PerformAction(Event *event_ptr) override { // Only perform the action once if (m_performed_action) @@ -1191,7 +1176,7 @@ StopInfo::CreateStopReasonToTrace (Thread &thread) StopInfoSP StopInfo::CreateStopReasonWithPlan (ThreadPlanSP &plan_sp, ValueObjectSP return_valobj_sp, - ClangExpressionVariableSP expression_variable_sp) + ExpressionVariableSP expression_variable_sp) { return StopInfoSP (new StopInfoThreadPlan (plan_sp, return_valobj_sp, expression_variable_sp)); } @@ -1220,7 +1205,7 @@ StopInfo::GetReturnValueObject(StopInfoSP &stop_info_sp) return ValueObjectSP(); } -ClangExpressionVariableSP +ExpressionVariableSP StopInfo::GetExpressionVariable(StopInfoSP &stop_info_sp) { if (stop_info_sp && stop_info_sp->GetStopReason() == eStopReasonPlanComplete) @@ -1229,5 +1214,5 @@ StopInfo::GetExpressionVariable(StopInfoSP &stop_info_sp) return plan_stop_info->GetExpressionVariable(); } else - return ClangExpressionVariableSP(); + return ExpressionVariableSP(); } |