diff options
author | Greg Clayton <gclayton@apple.com> | 2010-08-04 01:40:35 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2010-08-04 01:40:35 +0000 |
commit | f4b47e15799f16cef4baef4c3ee2519878b0f37a (patch) | |
tree | 44271b117f0b87f44f903c5eb471448dd17f5e93 /lldb/source/Target/ThreadPlanBase.cpp | |
parent | 5cae10339208cdf484d67df5d65995a5338f097d (diff) | |
download | bcm5719-llvm-f4b47e15799f16cef4baef4c3ee2519878b0f37a.tar.gz bcm5719-llvm-f4b47e15799f16cef4baef4c3ee2519878b0f37a.zip |
Abtracted the old "lldb_private::Thread::StopInfo" into an abtract class.
This will allow debugger plug-ins to make any instance of "lldb_private::StopInfo"
that can completely describe any stop reason. It also provides a framework for
doing intelligent things with the stop info at important times in the lifetime
of the inferior.
Examples include the signal stop info in StopInfoUnixSignal. It will check with
the process to see that the current action is for the signal. These actions
include wether to stop for the signal, wether the notify that the signal was
hit, and wether to pass the signal along to the inferior process. The
StopInfoUnixSignal class overrides the "ShouldStop()" method of StopInfo and
this allows the stop info to determine if it should stop at the signal or
continue the process.
StopInfo subclasses must override the following functions:
virtual lldb::StopReason
GetStopReason () const = 0;
virtual const char *
GetDescription () = 0;
StopInfo subclasses can override the following functions:
// If the subclass returns "false", the inferior will resume. The default
// version of this function returns "true" which means the default stop
// info will stop the process. The breakpoint subclass will check if
// the breakpoint wants us to stop by calling any installed callback on
// the breakpoint, and also checking if the breakpoint is for the current
// thread. Signals will check if they should stop based off of the
// UnixSignal settings in the process.
virtual bool
ShouldStop (Event *event_ptr);
// Sublasses can state if they want to notify the debugger when "ShouldStop"
// returns false. This would be handy for breakpoints where you want to
// log information and continue and is also used by the signal stop info
// to notify that a signal was received (after it checks with the process
// signal settings).
virtual bool
ShouldNotify (Event *event_ptr)
{
return false;
}
// Allow subclasses to do something intelligent right before we resume.
// The signal class will figure out if the signal should be propagated
// to the inferior process and pass that along to the debugger plug-ins.
virtual void
WillResume (lldb::StateType resume_state)
{
// By default, don't do anything
}
The support the Mach exceptions was moved into the lldb/source/Plugins/Process/Utility
folder and now doesn't polute the lldb_private::Thread class with platform
specific code.
llvm-svn: 110184
Diffstat (limited to 'lldb/source/Target/ThreadPlanBase.cpp')
-rw-r--r-- | lldb/source/Target/ThreadPlanBase.cpp | 149 |
1 files changed, 60 insertions, 89 deletions
diff --git a/lldb/source/Target/ThreadPlanBase.cpp b/lldb/source/Target/ThreadPlanBase.cpp index 5f5845429c0..81fe21550f2 100644 --- a/lldb/source/Target/ThreadPlanBase.cpp +++ b/lldb/source/Target/ThreadPlanBase.cpp @@ -21,6 +21,7 @@ #include "lldb/Core/Stream.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" +#include "lldb/Target/StopInfo.h" using namespace lldb; using namespace lldb_private; @@ -66,110 +67,80 @@ ThreadPlanBase::ShouldStop (Event *event_ptr) m_stop_vote = eVoteYes; m_run_vote = eVoteYes; - Thread::StopInfo stop_info; - if (m_thread.GetStopInfo(&stop_info)) + StopInfo *stop_info = m_thread.GetStopInfo(); + if (stop_info) { - StopReason reason = stop_info.GetStopReason(); + StopReason reason = stop_info->GetStopReason(); switch (reason) { - case eStopReasonInvalid: - case eStopReasonNone: + case eStopReasonInvalid: + case eStopReasonNone: + m_run_vote = eVoteNo; + m_stop_vote = eVoteNo; + return false; + + case eStopReasonBreakpoint: + if (stop_info->ShouldStop(event_ptr)) { - m_run_vote = eVoteNo; - m_stop_vote = eVoteNo; - return false; + // If we are going to stop for a breakpoint, then unship the other plans + // at this point. Don't force the discard, however, so Master plans can stay + // in place if they want to. + m_thread.DiscardThreadPlans(false); + return true; } - case eStopReasonBreakpoint: + // If we aren't going to stop at this breakpoint, and it is internal, + // don't report this stop or the subsequent running event. + // Otherwise we will post the stopped & running, but the stopped event will get marked + // with "restarted" so the UI will know to wait and expect the consequent "running". + if (stop_info->ShouldNotify (event_ptr)) { - // The base plan checks for breakpoint hits. - - BreakpointSiteSP bp_site_sp; - //RegisterContext *reg_ctx = m_thread.GetRegisterContext(); - //lldb::addr_t pc = reg_ctx->GetPC(); - bp_site_sp = m_thread.GetProcess().GetBreakpointSiteList().FindByID (stop_info.GetBreakpointSiteID()); - - if (bp_site_sp && bp_site_sp->IsEnabled()) - { - // We want to step over the breakpoint and then continue. So push these two plans. - - StoppointCallbackContext hit_context(event_ptr, &m_thread.GetProcess(), &m_thread, - m_thread.GetStackFrameAtIndex(0).get()); - bool should_stop = m_thread.GetProcess().GetBreakpointSiteList().ShouldStop(&hit_context, - bp_site_sp->GetID()); - - if (!should_stop) - { - // If we aren't going to stop at this breakpoint, and it is internal, - // don't report this stop or the subsequent running event. - // Otherwise we will post the stopped & running, but the stopped event will get marked - // with "restarted" so the UI will know to wait and expect the consequent "running". - uint32_t i; - bool is_wholly_internal = true; - - for (i = 0; i < bp_site_sp->GetNumberOfOwners(); i++) - { - if (!bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint().IsInternal()) - { - is_wholly_internal = false; - break; - } - } - if (is_wholly_internal) - { - m_stop_vote = eVoteNo; - m_run_vote = eVoteNo; - } - else - { - m_stop_vote = eVoteYes; - m_run_vote = eVoteYes; - } - - } - else - { - // If we are going to stop for a breakpoint, then unship the other plans - // at this point. Don't force the discard, however, so Master plans can stay - // in place if they want to. - m_thread.DiscardThreadPlans(false); - } - - return should_stop; - } + m_stop_vote = eVoteYes; + m_run_vote = eVoteYes; + } + else + { + m_stop_vote = eVoteNo; + m_run_vote = eVoteNo; } - case eStopReasonException: - // If we crashed, discard thread plans and stop. Don't force the discard, however, - // since on rerun the target may clean up this exception and continue normally from there. + return false; + + // TODO: the break below was missing, was this intentional??? If so + // please mention it + break; + + case eStopReasonException: + // If we crashed, discard thread plans and stop. Don't force the discard, however, + // since on rerun the target may clean up this exception and continue normally from there. + m_thread.DiscardThreadPlans(false); + return true; + + case eStopReasonSignal: + if (stop_info->ShouldStop(event_ptr)) + { m_thread.DiscardThreadPlans(false); return true; - case eStopReasonSignal: + } + else { - // Check the signal handling, and if we are stopping for the signal, - // discard the plans and stop. - UnixSignals &signals = m_thread.GetProcess().GetUnixSignals(); - uint32_t signo = stop_info.GetSignal(); - if (signals.GetShouldStop(signo)) - { - m_thread.DiscardThreadPlans(false); - return true; - } + // We're not going to stop, but while we are here, let's figure out + // whether to report this. + if (stop_info->ShouldNotify(event_ptr)) + m_stop_vote = eVoteYes; else - { - // We're not going to stop, but while we are here, let's figure out - // whether to report this. - if (signals.GetShouldNotify(signo)) - m_stop_vote = eVoteYes; - else - m_stop_vote = eVoteNo; - - return false; - } + m_stop_vote = eVoteNo; } - default: - return true; + return false; + + default: + return true; } } + else + { + m_run_vote = eVoteNo; + m_stop_vote = eVoteNo; + } // If there's no explicit reason to stop, then we will continue. return false; |