2010-08-04 09:40:35 +08:00
|
|
|
//===-- StopInfo.cpp ---------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2012-12-05 08:20:57 +08:00
|
|
|
#include "lldb/lldb-python.h"
|
|
|
|
|
2010-08-04 09:40:35 +08:00
|
|
|
#include "lldb/Target/StopInfo.h"
|
|
|
|
|
|
|
|
// C Includes
|
|
|
|
// C++ Includes
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
// Other libraries and framework includes
|
|
|
|
// Project includes
|
|
|
|
#include "lldb/Core/Log.h"
|
2010-11-19 02:52:36 +08:00
|
|
|
#include "lldb/Breakpoint/Breakpoint.h"
|
2010-08-04 09:40:35 +08:00
|
|
|
#include "lldb/Breakpoint/BreakpointLocation.h"
|
|
|
|
#include "lldb/Breakpoint/StoppointCallbackContext.h"
|
2011-10-14 08:42:25 +08:00
|
|
|
#include "lldb/Breakpoint/Watchpoint.h"
|
2011-08-09 10:12:22 +08:00
|
|
|
#include "lldb/Core/Debugger.h"
|
2010-08-04 09:40:35 +08:00
|
|
|
#include "lldb/Core/StreamString.h"
|
2011-08-09 10:12:22 +08:00
|
|
|
#include "lldb/Expression/ClangUserExpression.h"
|
|
|
|
#include "lldb/Target/Target.h"
|
2010-08-04 09:40:35 +08:00
|
|
|
#include "lldb/Target/Thread.h"
|
|
|
|
#include "lldb/Target/ThreadPlan.h"
|
|
|
|
#include "lldb/Target/Process.h"
|
|
|
|
#include "lldb/Target/UnixSignals.h"
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
StopInfo::StopInfo (Thread &thread, uint64_t value) :
|
2013-04-30 07:30:46 +08:00
|
|
|
m_thread_wp (thread.shared_from_this()),
|
2012-02-21 08:09:25 +08:00
|
|
|
m_stop_id (thread.GetProcess()->GetStopID()),
|
|
|
|
m_resume_id (thread.GetProcess()->GetResumeID()),
|
2013-02-09 09:29:05 +08:00
|
|
|
m_value (value),
|
Figure out the reply to "PlanExplainsStop" once when we stop and then use the cached
value. This fixes problems, for instance, with the StepRange plans, where they know that
they explained the stop because they were at their "run to here" breakpoint, then deleted
that breakpoint, so when they got asked again, doh! I had done this for a couple of plans
in an ad hoc fashion, this just formalizes it.
Also add a "ResumeRequested" in Process so that the code in the completion handlers can
tell the ShouldStop logic they want to resume rather than just directly resuming. That allows
us to handle resuming in a more controlled fashion.
Also, SetPublicState can take a "restarted" flag, so that it doesn't drop the run lock when
the target was immediately restarted.
--This line, and those below , will be ignored--
M test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
M include/lldb/Target/ThreadList.h
M include/lldb/Target/ThreadPlanStepOut.h
M include/lldb/Target/Thread.h
M include/lldb/Target/ThreadPlanBase.h
M include/lldb/Target/ThreadPlanStepThrough.h
M include/lldb/Target/ThreadPlanStepInstruction.h
M include/lldb/Target/ThreadPlanStepInRange.h
M include/lldb/Target/ThreadPlanStepOverBreakpoint.h
M include/lldb/Target/ThreadPlanStepUntil.h
M include/lldb/Target/StopInfo.h
M include/lldb/Target/Process.h
M include/lldb/Target/ThreadPlanRunToAddress.h
M include/lldb/Target/ThreadPlan.h
M include/lldb/Target/ThreadPlanCallFunction.h
M include/lldb/Target/ThreadPlanStepOverRange.h
M source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h
M source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
M source/Target/StopInfo.cpp
M source/Target/Process.cpp
M source/Target/ThreadPlanRunToAddress.cpp
M source/Target/ThreadPlan.cpp
M source/Target/ThreadPlanCallFunction.cpp
M source/Target/ThreadPlanStepOverRange.cpp
M source/Target/ThreadList.cpp
M source/Target/ThreadPlanStepOut.cpp
M source/Target/Thread.cpp
M source/Target/ThreadPlanBase.cpp
M source/Target/ThreadPlanStepThrough.cpp
M source/Target/ThreadPlanStepInstruction.cpp
M source/Target/ThreadPlanStepInRange.cpp
M source/Target/ThreadPlanStepOverBreakpoint.cpp
M source/Target/ThreadPlanStepUntil.cpp
M lldb.xcodeproj/xcshareddata/xcschemes/Run Testsuite.xcscheme
llvm-svn: 181381
2013-05-08 08:35:16 +08:00
|
|
|
m_override_should_notify (eLazyBoolCalculate),
|
|
|
|
m_override_should_stop (eLazyBoolCalculate)
|
2010-08-04 09:40:35 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
StopInfo::IsValid () const
|
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
ThreadSP thread_sp (m_thread_wp.lock());
|
|
|
|
if (thread_sp)
|
|
|
|
return thread_sp->GetProcess()->GetStopID() == m_stop_id;
|
|
|
|
return false;
|
2010-08-04 09:40:35 +08:00
|
|
|
}
|
|
|
|
|
2011-01-20 10:03:18 +08:00
|
|
|
void
|
|
|
|
StopInfo::MakeStopInfoValid ()
|
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
ThreadSP thread_sp (m_thread_wp.lock());
|
|
|
|
if (thread_sp)
|
|
|
|
{
|
|
|
|
m_stop_id = thread_sp->GetProcess()->GetStopID();
|
|
|
|
m_resume_id = thread_sp->GetProcess()->GetResumeID();
|
|
|
|
}
|
2011-01-20 10:03:18 +08:00
|
|
|
}
|
|
|
|
|
2011-11-08 11:00:11 +08:00
|
|
|
bool
|
|
|
|
StopInfo::HasTargetRunSinceMe ()
|
2011-08-09 10:12:22 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
ThreadSP thread_sp (m_thread_wp.lock());
|
|
|
|
|
|
|
|
if (thread_sp)
|
2011-11-08 11:00:11 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
lldb::StateType ret_type = thread_sp->GetProcess()->GetPrivateState();
|
|
|
|
if (ret_type == eStateRunning)
|
2011-11-08 11:00:11 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
return true;
|
2011-11-08 11:00:11 +08:00
|
|
|
}
|
2013-04-30 07:30:46 +08:00
|
|
|
else if (ret_type == eStateStopped)
|
2011-11-08 11:00:11 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
// This is a little tricky. We want to count "run and stopped again before you could
|
|
|
|
// ask this question as a "TRUE" answer to HasTargetRunSinceMe. But we don't want to
|
|
|
|
// include any running of the target done for expressions. So we track both resumes,
|
|
|
|
// and resumes caused by expressions, and check if there are any resumes NOT caused
|
|
|
|
// by expressions.
|
|
|
|
|
|
|
|
uint32_t curr_resume_id = thread_sp->GetProcess()->GetResumeID();
|
|
|
|
uint32_t last_user_expression_id = thread_sp->GetProcess()->GetLastUserExpressionResumeID ();
|
|
|
|
if (curr_resume_id == m_resume_id)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if (curr_resume_id > last_user_expression_id)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2011-11-08 11:00:11 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2011-08-09 10:12:22 +08:00
|
|
|
}
|
|
|
|
|
2010-08-04 09:40:35 +08:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// StopInfoBreakpoint
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2011-08-09 10:12:22 +08:00
|
|
|
namespace lldb_private
|
|
|
|
{
|
2010-08-04 09:40:35 +08:00
|
|
|
class StopInfoBreakpoint : public StopInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
StopInfoBreakpoint (Thread &thread, break_id_t break_id) :
|
|
|
|
StopInfo (thread, break_id),
|
|
|
|
m_description(),
|
|
|
|
m_should_stop (false),
|
2011-02-08 13:20:59 +08:00
|
|
|
m_should_stop_is_valid (false),
|
2011-10-28 09:12:19 +08:00
|
|
|
m_should_perform_action (true),
|
2012-10-06 03:16:31 +08:00
|
|
|
m_address (LLDB_INVALID_ADDRESS),
|
|
|
|
m_break_id(LLDB_INVALID_BREAK_ID),
|
|
|
|
m_was_one_shot (false)
|
2010-08-04 09:40:35 +08:00
|
|
|
{
|
2012-10-06 03:16:31 +08:00
|
|
|
StoreBPInfo();
|
2010-08-04 09:40:35 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2010-10-15 07:45:03 +08:00
|
|
|
StopInfoBreakpoint (Thread &thread, break_id_t break_id, bool should_stop) :
|
|
|
|
StopInfo (thread, break_id),
|
|
|
|
m_description(),
|
|
|
|
m_should_stop (should_stop),
|
2011-02-08 13:20:59 +08:00
|
|
|
m_should_stop_is_valid (true),
|
2011-10-28 09:12:19 +08:00
|
|
|
m_should_perform_action (true),
|
2012-10-06 03:16:31 +08:00
|
|
|
m_address (LLDB_INVALID_ADDRESS),
|
|
|
|
m_break_id(LLDB_INVALID_BREAK_ID),
|
|
|
|
m_was_one_shot (false)
|
|
|
|
{
|
|
|
|
StoreBPInfo();
|
|
|
|
}
|
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
void
|
|
|
|
StoreBPInfo ()
|
2010-10-15 07:45:03 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
ThreadSP thread_sp (m_thread_wp.lock());
|
|
|
|
if (thread_sp)
|
2011-10-28 09:12:19 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
BreakpointSiteSP bp_site_sp (thread_sp->GetProcess()->GetBreakpointSiteList().FindByID (m_value));
|
|
|
|
if (bp_site_sp)
|
2012-10-06 03:16:31 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
if (bp_site_sp->GetNumberOfOwners() == 1)
|
2012-10-06 03:16:31 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
BreakpointLocationSP bp_loc_sp = bp_site_sp->GetOwnerAtIndex(0);
|
|
|
|
if (bp_loc_sp)
|
|
|
|
{
|
|
|
|
m_break_id = bp_loc_sp->GetBreakpoint().GetID();
|
|
|
|
m_was_one_shot = bp_loc_sp->GetBreakpoint().IsOneShot();
|
|
|
|
}
|
2012-10-06 03:16:31 +08:00
|
|
|
}
|
2013-04-30 07:30:46 +08:00
|
|
|
m_address = bp_site_sp->GetLoadAddress();
|
2012-10-06 03:16:31 +08:00
|
|
|
}
|
2011-10-28 09:12:19 +08:00
|
|
|
}
|
2010-10-15 07:45:03 +08:00
|
|
|
}
|
|
|
|
|
2010-08-04 09:40:35 +08:00
|
|
|
virtual ~StopInfoBreakpoint ()
|
|
|
|
{
|
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2010-08-04 09:40:35 +08:00
|
|
|
virtual StopReason
|
|
|
|
GetStopReason () const
|
|
|
|
{
|
|
|
|
return eStopReasonBreakpoint;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool
|
2012-04-21 05:16:56 +08:00
|
|
|
ShouldStopSynchronous (Event *event_ptr)
|
2010-08-04 09:40:35 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
ThreadSP thread_sp (m_thread_wp.lock());
|
|
|
|
if (thread_sp)
|
2010-08-04 09:40:35 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
if (!m_should_stop_is_valid)
|
2010-08-04 09:40:35 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
// Only check once if we should stop at a breakpoint
|
|
|
|
BreakpointSiteSP bp_site_sp (thread_sp->GetProcess()->GetBreakpointSiteList().FindByID (m_value));
|
|
|
|
if (bp_site_sp)
|
|
|
|
{
|
|
|
|
ExecutionContext exe_ctx (thread_sp->GetStackFrameAtIndex(0));
|
|
|
|
StoppointCallbackContext context (event_ptr, exe_ctx, true);
|
|
|
|
m_should_stop = bp_site_sp->ShouldStop (&context);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
|
2010-08-04 09:40:35 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("Process::%s could not find breakpoint site id: %" PRId64 "...", __FUNCTION__, m_value);
|
2010-08-04 09:40:35 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
m_should_stop = true;
|
|
|
|
}
|
|
|
|
m_should_stop_is_valid = true;
|
2010-08-04 09:40:35 +08:00
|
|
|
}
|
2013-04-30 07:30:46 +08:00
|
|
|
return m_should_stop;
|
2010-08-04 09:40:35 +08:00
|
|
|
}
|
2013-04-30 07:30:46 +08:00
|
|
|
return false;
|
2010-08-04 09:40:35 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2012-11-10 10:08:14 +08:00
|
|
|
virtual bool
|
Figure out the reply to "PlanExplainsStop" once when we stop and then use the cached
value. This fixes problems, for instance, with the StepRange plans, where they know that
they explained the stop because they were at their "run to here" breakpoint, then deleted
that breakpoint, so when they got asked again, doh! I had done this for a couple of plans
in an ad hoc fashion, this just formalizes it.
Also add a "ResumeRequested" in Process so that the code in the completion handlers can
tell the ShouldStop logic they want to resume rather than just directly resuming. That allows
us to handle resuming in a more controlled fashion.
Also, SetPublicState can take a "restarted" flag, so that it doesn't drop the run lock when
the target was immediately restarted.
--This line, and those below , will be ignored--
M test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
M include/lldb/Target/ThreadList.h
M include/lldb/Target/ThreadPlanStepOut.h
M include/lldb/Target/Thread.h
M include/lldb/Target/ThreadPlanBase.h
M include/lldb/Target/ThreadPlanStepThrough.h
M include/lldb/Target/ThreadPlanStepInstruction.h
M include/lldb/Target/ThreadPlanStepInRange.h
M include/lldb/Target/ThreadPlanStepOverBreakpoint.h
M include/lldb/Target/ThreadPlanStepUntil.h
M include/lldb/Target/StopInfo.h
M include/lldb/Target/Process.h
M include/lldb/Target/ThreadPlanRunToAddress.h
M include/lldb/Target/ThreadPlan.h
M include/lldb/Target/ThreadPlanCallFunction.h
M include/lldb/Target/ThreadPlanStepOverRange.h
M source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h
M source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
M source/Target/StopInfo.cpp
M source/Target/Process.cpp
M source/Target/ThreadPlanRunToAddress.cpp
M source/Target/ThreadPlan.cpp
M source/Target/ThreadPlanCallFunction.cpp
M source/Target/ThreadPlanStepOverRange.cpp
M source/Target/ThreadList.cpp
M source/Target/ThreadPlanStepOut.cpp
M source/Target/Thread.cpp
M source/Target/ThreadPlanBase.cpp
M source/Target/ThreadPlanStepThrough.cpp
M source/Target/ThreadPlanStepInstruction.cpp
M source/Target/ThreadPlanStepInRange.cpp
M source/Target/ThreadPlanStepOverBreakpoint.cpp
M source/Target/ThreadPlanStepUntil.cpp
M lldb.xcodeproj/xcshareddata/xcschemes/Run Testsuite.xcscheme
llvm-svn: 181381
2013-05-08 08:35:16 +08:00
|
|
|
DoShouldNotify (Event *event_ptr)
|
2012-11-10 10:08:14 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
ThreadSP thread_sp (m_thread_wp.lock());
|
|
|
|
if (thread_sp)
|
2012-11-10 10:08:14 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
BreakpointSiteSP bp_site_sp (thread_sp->GetProcess()->GetBreakpointSiteList().FindByID (m_value));
|
|
|
|
if (bp_site_sp)
|
2012-11-10 10:08:14 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
bool all_internal = true;
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < bp_site_sp->GetNumberOfOwners(); i++)
|
2012-11-10 10:08:14 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
if (!bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint().IsInternal())
|
|
|
|
{
|
|
|
|
all_internal = false;
|
|
|
|
break;
|
|
|
|
}
|
2012-11-10 10:08:14 +08:00
|
|
|
}
|
2013-04-30 07:30:46 +08:00
|
|
|
return all_internal == false;
|
2012-11-10 10:08:14 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual const char *
|
|
|
|
GetDescription ()
|
|
|
|
{
|
|
|
|
if (m_description.empty())
|
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
ThreadSP thread_sp (m_thread_wp.lock());
|
|
|
|
if (thread_sp)
|
2012-11-10 10:08:14 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
BreakpointSiteSP bp_site_sp (thread_sp->GetProcess()->GetBreakpointSiteList().FindByID (m_value));
|
|
|
|
if (bp_site_sp)
|
2013-01-26 10:19:28 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
StreamString strm;
|
|
|
|
// If we have just hit an internal breakpoint, and it has a kind description, print that instead of the
|
|
|
|
// full breakpoint printing:
|
|
|
|
if (bp_site_sp->IsInternal())
|
2013-01-26 10:19:28 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
size_t num_owners = bp_site_sp->GetNumberOfOwners();
|
|
|
|
for (size_t idx = 0; idx < num_owners; idx++)
|
2013-01-26 10:19:28 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
const char *kind = bp_site_sp->GetOwnerAtIndex(idx)->GetBreakpoint().GetBreakpointKind();
|
|
|
|
if (kind != NULL)
|
|
|
|
{
|
|
|
|
m_description.assign (kind);
|
|
|
|
return kind;
|
|
|
|
}
|
2013-01-26 10:19:28 +08:00
|
|
|
}
|
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
strm.Printf("breakpoint ");
|
|
|
|
bp_site_sp->GetDescription(&strm, eDescriptionLevelBrief);
|
|
|
|
m_description.swap (strm.GetString());
|
2013-01-26 10:19:28 +08:00
|
|
|
}
|
2013-04-30 07:30:46 +08:00
|
|
|
else
|
2012-11-10 10:08:14 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
StreamString strm;
|
|
|
|
if (m_break_id != LLDB_INVALID_BREAK_ID)
|
2013-02-14 11:05:42 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
BreakpointSP break_sp = thread_sp->GetProcess()->GetTarget().GetBreakpointByID(m_break_id);
|
|
|
|
if (break_sp)
|
2013-02-14 11:05:42 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
if (break_sp->IsInternal())
|
|
|
|
{
|
|
|
|
const char *kind = break_sp->GetBreakpointKind();
|
|
|
|
if (kind)
|
|
|
|
strm.Printf ("internal %s breakpoint(%d).", kind, m_break_id);
|
|
|
|
else
|
|
|
|
strm.Printf ("internal breakpoint(%d).", m_break_id);
|
|
|
|
}
|
2013-02-14 11:05:42 +08:00
|
|
|
else
|
2013-04-30 07:30:46 +08:00
|
|
|
{
|
|
|
|
strm.Printf ("breakpoint %d.", m_break_id);
|
|
|
|
}
|
|
|
|
}
|
2013-02-14 11:05:42 +08:00
|
|
|
else
|
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
if (m_was_one_shot)
|
|
|
|
strm.Printf ("one-shot breakpoint %d", m_break_id);
|
|
|
|
else
|
|
|
|
strm.Printf ("breakpoint %d which has been deleted.", m_break_id);
|
2013-02-14 11:05:42 +08:00
|
|
|
}
|
|
|
|
}
|
2013-04-30 07:30:46 +08:00
|
|
|
else if (m_address == LLDB_INVALID_ADDRESS)
|
|
|
|
strm.Printf("breakpoint site %" PRIi64 " which has been deleted - unknown address", m_value);
|
|
|
|
else
|
|
|
|
strm.Printf("breakpoint site %" PRIi64 " which has been deleted - was at 0x%" PRIx64, m_value, m_address);
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
m_description.swap (strm.GetString());
|
2012-11-10 10:08:14 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return m_description.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2012-04-21 05:16:56 +08:00
|
|
|
bool
|
|
|
|
ShouldStop (Event *event_ptr)
|
|
|
|
{
|
|
|
|
// 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.
|
|
|
|
assert (m_should_stop_is_valid);
|
|
|
|
return m_should_stop;
|
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2010-08-10 08:59:59 +08:00
|
|
|
virtual void
|
|
|
|
PerformAction (Event *event_ptr)
|
|
|
|
{
|
2011-02-08 13:20:59 +08:00
|
|
|
if (!m_should_perform_action)
|
|
|
|
return;
|
|
|
|
m_should_perform_action = false;
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
ThreadSP thread_sp (m_thread_wp.lock());
|
|
|
|
|
|
|
|
if (thread_sp)
|
2010-08-10 08:59:59 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
if (!thread_sp->IsValid())
|
2010-08-10 08:59:59 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
// This shouldn't ever happen, but just in case, don't do more harm.
|
2013-08-07 07:08:59 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
log->Printf ("PerformAction got called with an invalid thread.");
|
|
|
|
}
|
2011-12-09 12:17:31 +08:00
|
|
|
m_should_stop = true;
|
2013-04-30 07:30:46 +08:00
|
|
|
m_should_stop_is_valid = true;
|
|
|
|
return;
|
2011-12-09 12:17:31 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
BreakpointSiteSP bp_site_sp (thread_sp->GetProcess()->GetBreakpointSiteList().FindByID (m_value));
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
if (bp_site_sp)
|
2011-12-09 12:17:31 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
size_t num_owners = bp_site_sp->GetNumberOfOwners();
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
if (num_owners == 0)
|
2013-01-15 10:47:48 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
m_should_stop = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// We go through each location, and test first its 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
|
|
|
|
// chance to run their callbacks.
|
|
|
|
// Of course if any callback restarts the target by putting "continue" in the callback, then
|
|
|
|
// we're going to restart, without running the rest of the callbacks. And in this case we will
|
|
|
|
// end up not stopping even if another location said we should stop. But that's better than not
|
|
|
|
// running all the callbacks.
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
m_should_stop = false;
|
|
|
|
|
|
|
|
ExecutionContext exe_ctx (thread_sp->GetStackFrameAtIndex(0));
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (process->GetModIDRef().IsLastResumeForUserExpression())
|
2013-01-15 10:47:48 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
// If we are in the middle of evaluating an expression, don't run asynchronous breakpoint commands or
|
|
|
|
// expressions. That could lead to infinite recursion if the command or condition re-calls the function
|
|
|
|
// with this breakpoint.
|
|
|
|
// TODO: We can keep a list of the breakpoints we've seen while running expressions in the nested
|
|
|
|
// PerformAction calls that can arise when the action runs a function that hits another breakpoint,
|
|
|
|
// and only stop running commands when we see the same breakpoint hit a second time.
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
m_should_stop_is_valid = true;
|
|
|
|
if (log)
|
|
|
|
log->Printf ("StopInfoBreakpoint::PerformAction - Hit a breakpoint while running an expression,"
|
|
|
|
" not running commands to avoid recursion.");
|
|
|
|
bool ignoring_breakpoints = process->GetIgnoreBreakpointsInExpressions();
|
|
|
|
if (ignoring_breakpoints)
|
2013-01-15 10:47:48 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
m_should_stop = false;
|
|
|
|
// Internal breakpoints will always stop.
|
|
|
|
for (size_t j = 0; j < num_owners; j++)
|
2013-01-15 10:47:48 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
lldb::BreakpointLocationSP bp_loc_sp = bp_site_sp->GetOwnerAtIndex(j);
|
|
|
|
if (bp_loc_sp->GetBreakpoint().IsInternal())
|
|
|
|
{
|
|
|
|
m_should_stop = true;
|
|
|
|
break;
|
|
|
|
}
|
2013-01-15 10:47:48 +08:00
|
|
|
}
|
|
|
|
}
|
2013-04-30 07:30:46 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
m_should_stop = true;
|
|
|
|
}
|
|
|
|
if (log)
|
|
|
|
log->Printf ("StopInfoBreakpoint::PerformAction - in expression, continuing: %s.",
|
|
|
|
m_should_stop ? "true" : "false");
|
|
|
|
process->GetTarget().GetDebugger().GetAsyncOutputStream()->Printf("Warning: hit breakpoint while "
|
|
|
|
"running function, skipping commands and conditions to prevent recursion.");
|
|
|
|
return;
|
2013-01-15 10:47:48 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
StoppointCallbackContext context (event_ptr, exe_ctx, false);
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
// 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.
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
BreakpointLocationCollection site_locations;
|
|
|
|
for (size_t j = 0; j < num_owners; j++)
|
|
|
|
site_locations.Add(bp_site_sp->GetOwnerAtIndex(j));
|
|
|
|
|
|
|
|
for (size_t j = 0; j < num_owners; j++)
|
2011-08-09 10:12:22 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
lldb::BreakpointLocationSP bp_loc_sp = site_locations.GetByIndex(j);
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
// If another action disabled this breakpoint or its location, then don't run the actions.
|
|
|
|
if (!bp_loc_sp->IsEnabled() || !bp_loc_sp->GetBreakpoint().IsEnabled())
|
|
|
|
continue;
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
// The breakpoint site may have many locations associated with it, not all of them valid for
|
|
|
|
// this thread. Skip the ones that aren't:
|
|
|
|
if (!bp_loc_sp->ValidForThisThread(thread_sp.get()))
|
2014-01-15 11:30:04 +08:00
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
StreamString s;
|
|
|
|
bp_loc_sp->GetDescription(&s, eDescriptionLevelBrief);
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("Breakpoint %s hit on thread 0x%llx but it was not for this thread, continuing.",
|
|
|
|
s.GetData(),
|
|
|
|
static_cast<unsigned long long>(thread_sp->GetID()));
|
2014-01-15 11:30:04 +08:00
|
|
|
}
|
2013-04-30 07:30:46 +08:00
|
|
|
continue;
|
2014-01-15 11:30:04 +08:00
|
|
|
}
|
2013-04-30 07:30:46 +08:00
|
|
|
// First 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.
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
if (bp_loc_sp->GetConditionText() != NULL)
|
2011-08-09 10:12:22 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
Error condition_error;
|
|
|
|
bool condition_says_stop = bp_loc_sp->ConditionSaysStop(exe_ctx, condition_error);
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
if (!condition_error.Success())
|
|
|
|
{
|
|
|
|
Debugger &debugger = exe_ctx.GetTargetRef().GetDebugger();
|
|
|
|
StreamSP error_sp = debugger.GetAsyncErrorStream ();
|
|
|
|
error_sp->Printf ("Stopped due to an error evaluating condition of breakpoint ");
|
|
|
|
bp_loc_sp->GetDescription (error_sp.get(), eDescriptionLevelBrief);
|
|
|
|
error_sp->Printf (": \"%s\"",
|
|
|
|
bp_loc_sp->GetConditionText());
|
|
|
|
error_sp->EOL();
|
|
|
|
const char *err_str = condition_error.AsCString("<Unknown Error>");
|
|
|
|
if (log)
|
|
|
|
log->Printf("Error evaluating condition: \"%s\"\n", err_str);
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
error_sp->PutCString (err_str);
|
|
|
|
error_sp->EOL();
|
|
|
|
error_sp->Flush();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-15 11:30:04 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
StreamString s;
|
|
|
|
bp_loc_sp->GetDescription(&s, eDescriptionLevelBrief);
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("Condition evaluated for breakpoint %s on thread 0x%llx conditon_says_stop: %i.",
|
|
|
|
s.GetData(),
|
|
|
|
static_cast<unsigned long long>(thread_sp->GetID()),
|
|
|
|
condition_says_stop);
|
2014-01-15 11:30:04 +08:00
|
|
|
}
|
2013-04-30 07:30:46 +08:00
|
|
|
if (!condition_says_stop)
|
|
|
|
continue;
|
|
|
|
}
|
2011-08-09 10:12:22 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
bool callback_says_stop;
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
// FIXME: For now the callbacks have to run in async mode - the first time we restart we need
|
|
|
|
// to get out of there. So set it here.
|
|
|
|
// When we figure out how to nest breakpoint hits then this will change.
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
Debugger &debugger = thread_sp->CalculateTarget()->GetDebugger();
|
|
|
|
bool old_async = debugger.GetAsyncExecution();
|
|
|
|
debugger.SetAsyncExecution (true);
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
callback_says_stop = bp_loc_sp->InvokeCallback (&context);
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
debugger.SetAsyncExecution (old_async);
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
if (callback_says_stop)
|
|
|
|
m_should_stop = true;
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
// If we are going to stop for this breakpoint, then remove the breakpoint.
|
|
|
|
if (callback_says_stop && bp_loc_sp && bp_loc_sp->GetBreakpoint().IsOneShot())
|
2013-04-19 15:09:15 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
thread_sp->GetProcess()->GetTarget().RemoveBreakpointByID (bp_loc_sp->GetBreakpoint().GetID());
|
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
// Also make sure that the callback hasn't continued the target.
|
|
|
|
// If it did, when we'll set m_should_start to false and get out of here.
|
|
|
|
if (HasTargetRunSinceMe ())
|
|
|
|
{
|
|
|
|
m_should_stop = false;
|
|
|
|
break;
|
2013-04-19 15:09:15 +08:00
|
|
|
}
|
2011-12-09 12:17:31 +08:00
|
|
|
}
|
2011-08-09 10:12:22 +08:00
|
|
|
}
|
2013-04-30 07:30:46 +08:00
|
|
|
// We've figured out what this stop wants to do, so mark it as valid so we don't compute it again.
|
|
|
|
m_should_stop_is_valid = true;
|
2011-12-09 12:17:31 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_should_stop = true;
|
|
|
|
m_should_stop_is_valid = true;
|
|
|
|
Log * log_process(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
|
2010-08-10 08:59:59 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
if (log_process)
|
|
|
|
log_process->Printf ("Process::%s could not find breakpoint site id: %" PRId64 "...", __FUNCTION__, m_value);
|
|
|
|
}
|
|
|
|
if (log)
|
|
|
|
log->Printf ("Process::%s returning from action with m_should_stop: %d.", __FUNCTION__, m_should_stop);
|
2010-08-10 08:59:59 +08:00
|
|
|
}
|
|
|
|
}
|
2010-08-04 09:40:35 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::string m_description;
|
|
|
|
bool m_should_stop;
|
|
|
|
bool m_should_stop_is_valid;
|
2011-02-08 13:20:59 +08:00
|
|
|
bool m_should_perform_action; // Since we are trying to preserve the "state" of the system even if we run functions
|
|
|
|
// etc. behind the users backs, we need to make sure we only REALLY perform the action once.
|
2011-10-28 09:12:19 +08:00
|
|
|
lldb::addr_t m_address; // We use this to capture the breakpoint site address when we create the StopInfo,
|
|
|
|
// in case somebody deletes it between the time the StopInfo is made and the
|
|
|
|
// description is asked for.
|
2012-10-06 03:16:31 +08:00
|
|
|
lldb::break_id_t m_break_id;
|
|
|
|
bool m_was_one_shot;
|
2010-08-04 09:40:35 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// StopInfoWatchpoint
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
class StopInfoWatchpoint : public StopInfo
|
|
|
|
{
|
|
|
|
public:
|
2012-11-10 10:08:14 +08:00
|
|
|
// Make sure watchpoint is properly disabled and subsequently enabled while performing watchpoint actions.
|
|
|
|
class WatchpointSentry {
|
|
|
|
public:
|
|
|
|
WatchpointSentry(Process *p, Watchpoint *w):
|
|
|
|
process(p),
|
|
|
|
watchpoint(w)
|
|
|
|
{
|
|
|
|
if (process && watchpoint)
|
|
|
|
{
|
2012-12-18 10:03:49 +08:00
|
|
|
const bool notify = false;
|
2012-11-10 10:08:14 +08:00
|
|
|
watchpoint->TurnOnEphemeralMode();
|
2012-12-18 10:03:49 +08:00
|
|
|
process->DisableWatchpoint(watchpoint, notify);
|
2012-11-10 10:08:14 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
~WatchpointSentry()
|
|
|
|
{
|
|
|
|
if (process && watchpoint)
|
|
|
|
{
|
|
|
|
if (!watchpoint->IsDisabledDuringEphemeralMode())
|
2012-12-18 10:03:49 +08:00
|
|
|
{
|
|
|
|
const bool notify = false;
|
|
|
|
process->EnableWatchpoint(watchpoint, notify);
|
|
|
|
}
|
2012-11-10 10:08:14 +08:00
|
|
|
watchpoint->TurnOffEphemeralMode();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
Process *process;
|
|
|
|
Watchpoint *watchpoint;
|
|
|
|
};
|
2010-08-04 09:40:35 +08:00
|
|
|
|
|
|
|
StopInfoWatchpoint (Thread &thread, break_id_t watch_id) :
|
2011-09-22 06:47:15 +08:00
|
|
|
StopInfo(thread, watch_id),
|
|
|
|
m_description(),
|
|
|
|
m_should_stop(false),
|
|
|
|
m_should_stop_is_valid(false)
|
2010-08-04 09:40:35 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~StopInfoWatchpoint ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual StopReason
|
|
|
|
GetStopReason () const
|
|
|
|
{
|
|
|
|
return eStopReasonWatchpoint;
|
|
|
|
}
|
|
|
|
|
2012-11-10 10:08:14 +08:00
|
|
|
virtual const char *
|
|
|
|
GetDescription ()
|
|
|
|
{
|
|
|
|
if (m_description.empty())
|
|
|
|
{
|
|
|
|
StreamString strm;
|
2012-11-30 05:49:15 +08:00
|
|
|
strm.Printf("watchpoint %" PRIi64, m_value);
|
2012-11-10 10:08:14 +08:00
|
|
|
m_description.swap (strm.GetString());
|
|
|
|
}
|
|
|
|
return m_description.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2011-09-22 06:47:15 +08:00
|
|
|
virtual bool
|
2013-02-23 05:23:43 +08:00
|
|
|
ShouldStopSynchronous (Event *event_ptr)
|
2011-09-22 06:47:15 +08:00
|
|
|
{
|
|
|
|
// ShouldStop() method is idempotent and should not affect hit count.
|
2011-10-18 02:58:00 +08:00
|
|
|
// See Process::RunPrivateStateThread()->Process()->HandlePrivateEvent()
|
|
|
|
// -->Process()::ShouldBroadcastEvent()->ThreadList::ShouldStop()->
|
|
|
|
// Thread::ShouldStop()->ThreadPlanBase::ShouldStop()->
|
|
|
|
// StopInfoWatchpoint::ShouldStop() and
|
|
|
|
// Event::DoOnRemoval()->Process::ProcessEventData::DoOnRemoval()->
|
|
|
|
// StopInfoWatchpoint::PerformAction().
|
2011-09-22 06:47:15 +08:00
|
|
|
if (m_should_stop_is_valid)
|
|
|
|
return m_should_stop;
|
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
ThreadSP thread_sp (m_thread_wp.lock());
|
|
|
|
if (thread_sp)
|
2011-09-22 06:47:15 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
WatchpointSP wp_sp (thread_sp->CalculateTarget()->GetWatchpointList().FindByID(GetValue()));
|
|
|
|
if (wp_sp)
|
|
|
|
{
|
|
|
|
// Check if we should stop at a watchpoint.
|
|
|
|
ExecutionContext exe_ctx (thread_sp->GetStackFrameAtIndex(0));
|
|
|
|
StoppointCallbackContext context (event_ptr, exe_ctx, true);
|
|
|
|
m_should_stop = wp_sp->ShouldStop (&context);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
|
2011-09-22 06:47:15 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("Process::%s could not find watchpoint location id: %" PRId64 "...",
|
|
|
|
__FUNCTION__, GetValue());
|
2011-09-22 06:47:15 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
m_should_stop = true;
|
|
|
|
}
|
2011-09-22 06:47:15 +08:00
|
|
|
}
|
|
|
|
m_should_stop_is_valid = true;
|
|
|
|
return m_should_stop;
|
|
|
|
}
|
|
|
|
|
2013-02-23 05:23:43 +08:00
|
|
|
bool
|
|
|
|
ShouldStop (Event *event_ptr)
|
|
|
|
{
|
|
|
|
// 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.
|
|
|
|
assert (m_should_stop_is_valid);
|
|
|
|
return m_should_stop;
|
|
|
|
}
|
|
|
|
|
2011-10-18 02:58:00 +08:00
|
|
|
virtual void
|
|
|
|
PerformAction (Event *event_ptr)
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS);
|
2011-10-18 02:58:00 +08:00
|
|
|
// We're going to calculate if we should stop or not in some way during the course of
|
|
|
|
// this code. Also by default we're going to stop, so set that here.
|
|
|
|
m_should_stop = true;
|
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
ThreadSP thread_sp (m_thread_wp.lock());
|
|
|
|
if (thread_sp)
|
2011-10-18 02:58:00 +08:00
|
|
|
{
|
2012-08-22 06:06:34 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
WatchpointSP wp_sp (thread_sp->CalculateTarget()->GetWatchpointList().FindByID(GetValue()));
|
|
|
|
if (wp_sp)
|
2012-07-14 07:18:48 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
ExecutionContext exe_ctx (thread_sp->GetStackFrameAtIndex(0));
|
|
|
|
Process* process = exe_ctx.GetProcessPtr();
|
|
|
|
|
|
|
|
// This sentry object makes sure the current watchpoint is disabled while performing watchpoint actions,
|
|
|
|
// and it is then enabled after we are finished.
|
|
|
|
WatchpointSentry sentry(process, wp_sp.get());
|
|
|
|
|
2012-07-14 07:18:48 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
// check if this process is running on an architecture where watchpoints trigger
|
|
|
|
// before the associated instruction runs. if so, disable the WP, single-step and then
|
|
|
|
// re-enable the watchpoint
|
|
|
|
if (process)
|
2012-07-14 07:18:48 +08:00
|
|
|
{
|
2013-05-04 08:39:52 +08:00
|
|
|
uint32_t num;
|
|
|
|
bool wp_triggers_after;
|
2013-04-30 07:30:46 +08:00
|
|
|
if (process->GetWatchpointSupportInfo(num, wp_triggers_after).Success())
|
2012-07-14 07:18:48 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
if (!wp_triggers_after)
|
|
|
|
{
|
2013-07-03 05:12:44 +08:00
|
|
|
StopInfoSP stored_stop_info_sp = thread_sp->GetStopInfo();
|
|
|
|
assert (stored_stop_info_sp.get() == this);
|
|
|
|
|
2013-07-19 05:48:26 +08:00
|
|
|
ThreadPlanSP new_plan_sp(thread_sp->QueueThreadPlanForStepSingleInstruction(false, // step-over
|
|
|
|
false, // abort_other_plans
|
|
|
|
true)); // stop_other_threads
|
|
|
|
new_plan_sp->SetIsMasterPlan (true);
|
|
|
|
new_plan_sp->SetOkayToDiscard (false);
|
|
|
|
new_plan_sp->SetPrivate (true);
|
2013-04-30 07:30:46 +08:00
|
|
|
process->GetThreadList().SetSelectedThreadByID (thread_sp->GetID());
|
|
|
|
process->Resume ();
|
|
|
|
process->WaitForProcessToStop (NULL);
|
|
|
|
process->GetThreadList().SetSelectedThreadByID (thread_sp->GetID());
|
2013-07-03 05:12:44 +08:00
|
|
|
thread_sp->SetStopInfo(stored_stop_info_sp);
|
2013-04-30 07:30:46 +08:00
|
|
|
}
|
2012-07-14 07:18:48 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-08-14 05:09:54 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
if (m_should_stop && wp_sp->GetConditionText() != NULL)
|
2011-10-18 02:58:00 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
// We need to make sure the user sees any parse errors in their condition, so we'll hook the
|
|
|
|
// constructor errors up to the debugger's Async I/O.
|
2014-05-05 10:26:40 +08:00
|
|
|
ExpressionResults result_code;
|
2013-11-05 03:35:17 +08:00
|
|
|
EvaluateExpressionOptions expr_options;
|
|
|
|
expr_options.SetUnwindOnError(true);
|
|
|
|
expr_options.SetIgnoreBreakpoints(true);
|
2013-04-30 07:30:46 +08:00
|
|
|
ValueObjectSP result_value_sp;
|
|
|
|
Error error;
|
2013-11-05 03:35:17 +08:00
|
|
|
result_code = ClangUserExpression::Evaluate (exe_ctx,
|
|
|
|
expr_options,
|
|
|
|
wp_sp->GetConditionText(),
|
|
|
|
NULL,
|
|
|
|
result_value_sp,
|
|
|
|
error);
|
2014-05-05 10:47:44 +08:00
|
|
|
if (result_code == eExpressionCompleted)
|
2011-10-18 02:58:00 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
if (result_value_sp)
|
2011-10-18 02:58:00 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
Scalar scalar_value;
|
|
|
|
if (result_value_sp->ResolveValue (scalar_value))
|
2011-10-18 02:58:00 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
if (scalar_value.ULongLong(1) == 0)
|
|
|
|
{
|
|
|
|
// We have been vetoed. This takes precedence over querying
|
|
|
|
// the watchpoint whether it should stop (aka ignore count and
|
|
|
|
// friends). See also StopInfoWatchpoint::ShouldStop() as well
|
|
|
|
// as Process::ProcessEventData::DoOnRemoval().
|
|
|
|
m_should_stop = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m_should_stop = true;
|
|
|
|
if (log)
|
|
|
|
log->Printf("Condition successfully evaluated, result is %s.\n",
|
|
|
|
m_should_stop ? "true" : "false");
|
2011-10-18 02:58:00 +08:00
|
|
|
}
|
|
|
|
else
|
2013-04-30 07:30:46 +08:00
|
|
|
{
|
2011-10-18 02:58:00 +08:00
|
|
|
m_should_stop = true;
|
2013-04-30 07:30:46 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("Failed to get an integer result from the expression.");
|
|
|
|
}
|
2011-10-18 02:58:00 +08:00
|
|
|
}
|
|
|
|
}
|
2013-04-30 07:30:46 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
Debugger &debugger = exe_ctx.GetTargetRef().GetDebugger();
|
|
|
|
StreamSP error_sp = debugger.GetAsyncErrorStream ();
|
|
|
|
error_sp->Printf ("Stopped due to an error evaluating condition of watchpoint ");
|
|
|
|
wp_sp->GetDescription (error_sp.get(), eDescriptionLevelBrief);
|
|
|
|
error_sp->Printf (": \"%s\"",
|
|
|
|
wp_sp->GetConditionText());
|
|
|
|
error_sp->EOL();
|
|
|
|
const char *err_str = error.AsCString("<Unknown Error>");
|
|
|
|
if (log)
|
|
|
|
log->Printf("Error evaluating condition: \"%s\"\n", err_str);
|
|
|
|
|
|
|
|
error_sp->PutCString (err_str);
|
|
|
|
error_sp->EOL();
|
|
|
|
error_sp->Flush();
|
|
|
|
// If the condition fails to be parsed or run, we should stop.
|
|
|
|
m_should_stop = true;
|
|
|
|
}
|
2011-10-18 02:58:00 +08:00
|
|
|
}
|
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
// If the condition says to stop, we run the callback to further decide whether to stop.
|
|
|
|
if (m_should_stop)
|
|
|
|
{
|
|
|
|
StoppointCallbackContext context (event_ptr, exe_ctx, false);
|
|
|
|
bool stop_requested = wp_sp->InvokeCallback (&context);
|
|
|
|
// Also make sure that the callback hasn't continued the target.
|
|
|
|
// If it did, when we'll set m_should_stop to false and get out of here.
|
|
|
|
if (HasTargetRunSinceMe ())
|
|
|
|
m_should_stop = false;
|
|
|
|
|
|
|
|
if (m_should_stop && !stop_requested)
|
|
|
|
{
|
|
|
|
// We have been vetoed by the callback mechanism.
|
|
|
|
m_should_stop = false;
|
|
|
|
}
|
2011-10-18 02:58:00 +08:00
|
|
|
}
|
2013-04-30 07:30:46 +08:00
|
|
|
// Finally, if we are going to stop, print out the new & old values:
|
|
|
|
if (m_should_stop)
|
2012-08-10 07:10:57 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
wp_sp->CaptureWatchedValue(exe_ctx);
|
|
|
|
|
|
|
|
Debugger &debugger = exe_ctx.GetTargetRef().GetDebugger();
|
|
|
|
StreamSP output_sp = debugger.GetAsyncOutputStream ();
|
|
|
|
wp_sp->DumpSnapshots(output_sp.get());
|
|
|
|
output_sp->EOL();
|
|
|
|
output_sp->Flush();
|
2012-08-10 07:10:57 +08:00
|
|
|
}
|
2013-04-30 07:30:46 +08:00
|
|
|
|
2012-08-10 07:10:57 +08:00
|
|
|
}
|
2013-04-30 07:30:46 +08:00
|
|
|
else
|
2012-10-23 15:20:06 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
Log * log_process(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
|
|
|
|
|
|
|
|
if (log_process)
|
|
|
|
log_process->Printf ("Process::%s could not find watchpoint id: %" PRId64 "...", __FUNCTION__, m_value);
|
2012-10-23 15:20:06 +08:00
|
|
|
}
|
2013-04-30 07:30:46 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("Process::%s returning from action with m_should_stop: %d.", __FUNCTION__, m_should_stop);
|
2012-10-23 15:20:06 +08:00
|
|
|
|
2013-04-30 07:30:46 +08:00
|
|
|
m_should_stop_is_valid = true;
|
2011-10-18 02:58:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-04 09:40:35 +08:00
|
|
|
private:
|
|
|
|
std::string m_description;
|
2011-09-22 06:47:15 +08:00
|
|
|
bool m_should_stop;
|
|
|
|
bool m_should_stop_is_valid;
|
2010-08-04 09:40:35 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// StopInfoUnixSignal
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
class StopInfoUnixSignal : public StopInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
StopInfoUnixSignal (Thread &thread, int signo) :
|
2011-06-04 09:26:29 +08:00
|
|
|
StopInfo (thread, signo)
|
2010-08-04 09:40:35 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~StopInfoUnixSignal ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virtual StopReason
|
|
|
|
GetStopReason () const
|
|
|
|
{
|
|
|
|
return eStopReasonSignal;
|
|
|
|
}
|
|
|
|
|
2013-02-09 09:29:05 +08:00
|
|
|
virtual bool
|
|
|
|
ShouldStopSynchronous (Event *event_ptr)
|
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
ThreadSP thread_sp (m_thread_wp.lock());
|
|
|
|
if (thread_sp)
|
|
|
|
return thread_sp->GetProcess()->GetUnixSignals().GetShouldStop (m_value);
|
|
|
|
return false;
|
2013-02-09 09:29:05 +08:00
|
|
|
}
|
|
|
|
|
2010-08-04 09:40:35 +08:00
|
|
|
virtual bool
|
|
|
|
ShouldStop (Event *event_ptr)
|
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
ThreadSP thread_sp (m_thread_wp.lock());
|
|
|
|
if (thread_sp)
|
|
|
|
return thread_sp->GetProcess()->GetUnixSignals().GetShouldStop (m_value);
|
|
|
|
return false;
|
2010-08-04 09:40:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// If should stop returns false, check if we should notify of this event
|
|
|
|
virtual bool
|
Figure out the reply to "PlanExplainsStop" once when we stop and then use the cached
value. This fixes problems, for instance, with the StepRange plans, where they know that
they explained the stop because they were at their "run to here" breakpoint, then deleted
that breakpoint, so when they got asked again, doh! I had done this for a couple of plans
in an ad hoc fashion, this just formalizes it.
Also add a "ResumeRequested" in Process so that the code in the completion handlers can
tell the ShouldStop logic they want to resume rather than just directly resuming. That allows
us to handle resuming in a more controlled fashion.
Also, SetPublicState can take a "restarted" flag, so that it doesn't drop the run lock when
the target was immediately restarted.
--This line, and those below , will be ignored--
M test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
M include/lldb/Target/ThreadList.h
M include/lldb/Target/ThreadPlanStepOut.h
M include/lldb/Target/Thread.h
M include/lldb/Target/ThreadPlanBase.h
M include/lldb/Target/ThreadPlanStepThrough.h
M include/lldb/Target/ThreadPlanStepInstruction.h
M include/lldb/Target/ThreadPlanStepInRange.h
M include/lldb/Target/ThreadPlanStepOverBreakpoint.h
M include/lldb/Target/ThreadPlanStepUntil.h
M include/lldb/Target/StopInfo.h
M include/lldb/Target/Process.h
M include/lldb/Target/ThreadPlanRunToAddress.h
M include/lldb/Target/ThreadPlan.h
M include/lldb/Target/ThreadPlanCallFunction.h
M include/lldb/Target/ThreadPlanStepOverRange.h
M source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h
M source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
M source/Target/StopInfo.cpp
M source/Target/Process.cpp
M source/Target/ThreadPlanRunToAddress.cpp
M source/Target/ThreadPlan.cpp
M source/Target/ThreadPlanCallFunction.cpp
M source/Target/ThreadPlanStepOverRange.cpp
M source/Target/ThreadList.cpp
M source/Target/ThreadPlanStepOut.cpp
M source/Target/Thread.cpp
M source/Target/ThreadPlanBase.cpp
M source/Target/ThreadPlanStepThrough.cpp
M source/Target/ThreadPlanStepInstruction.cpp
M source/Target/ThreadPlanStepInRange.cpp
M source/Target/ThreadPlanStepOverBreakpoint.cpp
M source/Target/ThreadPlanStepUntil.cpp
M lldb.xcodeproj/xcshareddata/xcschemes/Run Testsuite.xcscheme
llvm-svn: 181381
2013-05-08 08:35:16 +08:00
|
|
|
DoShouldNotify (Event *event_ptr)
|
2010-08-04 09:40:35 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
ThreadSP thread_sp (m_thread_wp.lock());
|
|
|
|
if (thread_sp)
|
2013-02-09 09:29:05 +08:00
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
bool should_notify = thread_sp->GetProcess()->GetUnixSignals().GetShouldNotify (m_value);
|
|
|
|
if (should_notify)
|
|
|
|
{
|
|
|
|
StreamString strm;
|
|
|
|
strm.Printf ("thread %d received signal: %s",
|
|
|
|
thread_sp->GetIndexID(),
|
|
|
|
thread_sp->GetProcess()->GetUnixSignals().GetSignalAsCString (m_value));
|
|
|
|
Process::ProcessEventData::AddRestartedReason(event_ptr, strm.GetData());
|
|
|
|
}
|
|
|
|
return should_notify;
|
2013-02-09 09:29:05 +08:00
|
|
|
}
|
2013-04-30 07:30:46 +08:00
|
|
|
return true;
|
2010-08-04 09:40:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
WillResume (lldb::StateType resume_state)
|
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
ThreadSP thread_sp (m_thread_wp.lock());
|
|
|
|
if (thread_sp)
|
|
|
|
{
|
|
|
|
if (thread_sp->GetProcess()->GetUnixSignals().GetShouldSuppress(m_value) == false)
|
|
|
|
thread_sp->SetResumeSignal(m_value);
|
|
|
|
}
|
2010-08-04 09:40:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual const char *
|
|
|
|
GetDescription ()
|
|
|
|
{
|
|
|
|
if (m_description.empty())
|
|
|
|
{
|
2013-04-30 07:30:46 +08:00
|
|
|
ThreadSP thread_sp (m_thread_wp.lock());
|
|
|
|
if (thread_sp)
|
|
|
|
{
|
|
|
|
StreamString strm;
|
|
|
|
const char *signal_name = thread_sp->GetProcess()->GetUnixSignals().GetSignalAsCString (m_value);
|
|
|
|
if (signal_name)
|
|
|
|
strm.Printf("signal %s", signal_name);
|
|
|
|
else
|
|
|
|
strm.Printf("signal %" PRIi64, m_value);
|
|
|
|
m_description.swap (strm.GetString());
|
|
|
|
}
|
2010-08-04 09:40:35 +08:00
|
|
|
}
|
|
|
|
return m_description.c_str();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// StopInfoTrace
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
class StopInfoTrace : public StopInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
StopInfoTrace (Thread &thread) :
|
|
|
|
StopInfo (thread, LLDB_INVALID_UID)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~StopInfoTrace ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual StopReason
|
|
|
|
GetStopReason () const
|
|
|
|
{
|
|
|
|
return eStopReasonTrace;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual const char *
|
|
|
|
GetDescription ()
|
|
|
|
{
|
2011-06-04 09:26:29 +08:00
|
|
|
if (m_description.empty())
|
2010-08-04 09:40:35 +08:00
|
|
|
return "trace";
|
2011-06-04 09:26:29 +08:00
|
|
|
else
|
|
|
|
return m_description.c_str();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// StopInfoException
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
return eStopReasonException;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual const char *
|
|
|
|
GetDescription ()
|
|
|
|
{
|
|
|
|
if (m_description.empty())
|
|
|
|
return "exception";
|
|
|
|
else
|
|
|
|
return m_description.c_str();
|
2010-08-04 09:40:35 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// StopInfoThreadPlan
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
class StopInfoThreadPlan : public StopInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2014-07-08 09:07:32 +08:00
|
|
|
StopInfoThreadPlan (ThreadPlanSP &plan_sp, ValueObjectSP &return_valobj_sp, ClangExpressionVariableSP &expression_variable_sp) :
|
2010-08-04 09:40:35 +08:00
|
|
|
StopInfo (plan_sp->GetThread(), LLDB_INVALID_UID),
|
2011-12-17 09:35:57 +08:00
|
|
|
m_plan_sp (plan_sp),
|
2014-07-08 09:07:32 +08:00
|
|
|
m_return_valobj_sp (return_valobj_sp),
|
|
|
|
m_expression_variable_sp (expression_variable_sp)
|
2010-08-04 09:40:35 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~StopInfoThreadPlan ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual StopReason
|
|
|
|
GetStopReason () const
|
|
|
|
{
|
|
|
|
return eStopReasonPlanComplete;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual const char *
|
|
|
|
GetDescription ()
|
|
|
|
{
|
|
|
|
if (m_description.empty())
|
|
|
|
{
|
|
|
|
StreamString strm;
|
|
|
|
m_plan_sp->GetDescription (&strm, eDescriptionLevelBrief);
|
|
|
|
m_description.swap (strm.GetString());
|
|
|
|
}
|
|
|
|
return m_description.c_str();
|
|
|
|
}
|
2011-12-17 09:35:57 +08:00
|
|
|
|
|
|
|
ValueObjectSP
|
|
|
|
GetReturnValueObject()
|
|
|
|
{
|
|
|
|
return m_return_valobj_sp;
|
|
|
|
}
|
2013-02-09 09:29:05 +08:00
|
|
|
|
2014-07-08 09:07:32 +08:00
|
|
|
ClangExpressionVariableSP
|
|
|
|
GetExpressionVariable()
|
|
|
|
{
|
|
|
|
return m_expression_variable_sp;
|
|
|
|
}
|
|
|
|
|
2013-02-09 09:29:05 +08:00
|
|
|
protected:
|
|
|
|
virtual bool
|
|
|
|
ShouldStop (Event *event_ptr)
|
|
|
|
{
|
|
|
|
if (m_plan_sp)
|
|
|
|
return m_plan_sp->ShouldStop(event_ptr);
|
|
|
|
else
|
|
|
|
return StopInfo::ShouldStop(event_ptr);
|
|
|
|
}
|
2010-08-04 09:40:35 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
ThreadPlanSP m_plan_sp;
|
2011-12-17 09:35:57 +08:00
|
|
|
ValueObjectSP m_return_valobj_sp;
|
2014-07-08 09:07:32 +08:00
|
|
|
ClangExpressionVariableSP m_expression_variable_sp;
|
2010-08-04 09:40:35 +08:00
|
|
|
};
|
2012-12-05 08:16:59 +08:00
|
|
|
|
|
|
|
class StopInfoExec : public StopInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
StopInfoExec (Thread &thread) :
|
|
|
|
StopInfo (thread, LLDB_INVALID_UID),
|
|
|
|
m_performed_action (false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual
|
|
|
|
~StopInfoExec ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual StopReason
|
|
|
|
GetStopReason () const
|
|
|
|
{
|
|
|
|
return eStopReasonExec;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual const char *
|
|
|
|
GetDescription ()
|
|
|
|
{
|
|
|
|
return "exec";
|
|
|
|
}
|
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
PerformAction (Event *event_ptr)
|
|
|
|
{
|
|
|
|
// Only perform the action once
|
|
|
|
if (m_performed_action)
|
|
|
|
return;
|
|
|
|
m_performed_action = true;
|
2013-04-30 07:30:46 +08:00
|
|
|
ThreadSP thread_sp (m_thread_wp.lock());
|
|
|
|
if (thread_sp)
|
|
|
|
thread_sp->GetProcess()->DidExec();
|
2012-12-05 08:16:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool m_performed_action;
|
|
|
|
};
|
|
|
|
|
2011-08-09 10:12:22 +08:00
|
|
|
} // namespace lldb_private
|
2010-08-04 09:40:35 +08:00
|
|
|
|
|
|
|
StopInfoSP
|
|
|
|
StopInfo::CreateStopReasonWithBreakpointSiteID (Thread &thread, break_id_t break_id)
|
|
|
|
{
|
|
|
|
return StopInfoSP (new StopInfoBreakpoint (thread, break_id));
|
|
|
|
}
|
|
|
|
|
2010-10-15 07:45:03 +08:00
|
|
|
StopInfoSP
|
|
|
|
StopInfo::CreateStopReasonWithBreakpointSiteID (Thread &thread, break_id_t break_id, bool should_stop)
|
|
|
|
{
|
|
|
|
return StopInfoSP (new StopInfoBreakpoint (thread, break_id, should_stop));
|
|
|
|
}
|
|
|
|
|
2010-08-04 09:40:35 +08:00
|
|
|
StopInfoSP
|
|
|
|
StopInfo::CreateStopReasonWithWatchpointID (Thread &thread, break_id_t watch_id)
|
|
|
|
{
|
|
|
|
return StopInfoSP (new StopInfoWatchpoint (thread, watch_id));
|
|
|
|
}
|
|
|
|
|
|
|
|
StopInfoSP
|
|
|
|
StopInfo::CreateStopReasonWithSignal (Thread &thread, int signo)
|
|
|
|
{
|
|
|
|
return StopInfoSP (new StopInfoUnixSignal (thread, signo));
|
|
|
|
}
|
|
|
|
|
|
|
|
StopInfoSP
|
|
|
|
StopInfo::CreateStopReasonToTrace (Thread &thread)
|
|
|
|
{
|
|
|
|
return StopInfoSP (new StopInfoTrace (thread));
|
|
|
|
}
|
|
|
|
|
|
|
|
StopInfoSP
|
2014-07-08 09:07:32 +08:00
|
|
|
StopInfo::CreateStopReasonWithPlan (ThreadPlanSP &plan_sp,
|
|
|
|
ValueObjectSP return_valobj_sp,
|
|
|
|
ClangExpressionVariableSP expression_variable_sp)
|
2010-08-04 09:40:35 +08:00
|
|
|
{
|
2014-07-08 09:07:32 +08:00
|
|
|
return StopInfoSP (new StopInfoThreadPlan (plan_sp, return_valobj_sp, expression_variable_sp));
|
2010-08-04 09:40:35 +08:00
|
|
|
}
|
2011-06-04 09:26:29 +08:00
|
|
|
|
|
|
|
StopInfoSP
|
|
|
|
StopInfo::CreateStopReasonWithException (Thread &thread, const char *description)
|
|
|
|
{
|
|
|
|
return StopInfoSP (new StopInfoException (thread, description));
|
|
|
|
}
|
2011-12-17 09:35:57 +08:00
|
|
|
|
2012-12-05 08:16:59 +08:00
|
|
|
StopInfoSP
|
|
|
|
StopInfo::CreateStopReasonWithExec (Thread &thread)
|
|
|
|
{
|
|
|
|
return StopInfoSP (new StopInfoExec (thread));
|
|
|
|
}
|
|
|
|
|
2011-12-17 09:35:57 +08:00
|
|
|
ValueObjectSP
|
|
|
|
StopInfo::GetReturnValueObject(StopInfoSP &stop_info_sp)
|
|
|
|
{
|
|
|
|
if (stop_info_sp && stop_info_sp->GetStopReason() == eStopReasonPlanComplete)
|
|
|
|
{
|
|
|
|
StopInfoThreadPlan *plan_stop_info = static_cast<StopInfoThreadPlan *>(stop_info_sp.get());
|
|
|
|
return plan_stop_info->GetReturnValueObject();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return ValueObjectSP();
|
|
|
|
}
|
2014-07-08 09:07:32 +08:00
|
|
|
|
|
|
|
ClangExpressionVariableSP
|
|
|
|
StopInfo::GetExpressionVariable(StopInfoSP &stop_info_sp)
|
|
|
|
{
|
|
|
|
if (stop_info_sp && stop_info_sp->GetStopReason() == eStopReasonPlanComplete)
|
|
|
|
{
|
|
|
|
StopInfoThreadPlan *plan_stop_info = static_cast<StopInfoThreadPlan *>(stop_info_sp.get());
|
|
|
|
return plan_stop_info->GetExpressionVariable();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return ClangExpressionVariableSP();
|
|
|
|
}
|