#include "lldb/lldb-python.h"
#include "lldb/Target/StopInfo.h"
#include <string>
#include "lldb/Core/Log.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Breakpoint/Watchpoint.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Expression/ClangUserExpression.h"
#include "lldb/Target/Target.h"
#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) :
m_thread_wp (thread.shared_from_this()),
m_stop_id (thread.GetProcess()->GetStopID()),
m_resume_id (thread.GetProcess()->GetResumeID()),
m_value (value),
m_override_should_notify (eLazyBoolCalculate),
m_override_should_stop (eLazyBoolCalculate)
{
}
bool
StopInfo::IsValid () const
{
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
return thread_sp->GetProcess()->GetStopID() == m_stop_id;
return false;
}
void
StopInfo::MakeStopInfoValid ()
{
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
{
m_stop_id = thread_sp->GetProcess()->GetStopID();
m_resume_id = thread_sp->GetProcess()->GetResumeID();
}
}
bool
StopInfo::HasTargetRunSinceMe ()
{
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
{
lldb::StateType ret_type = thread_sp->GetProcess()->GetPrivateState();
if (ret_type == eStateRunning)
{
return true;
}
else if (ret_type == eStateStopped)
{
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;
}
}
}
return false;
}
namespace lldb_private
{
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),
m_address (LLDB_INVALID_ADDRESS),
m_break_id(LLDB_INVALID_BREAK_ID),
m_was_one_shot (false)
{
StoreBPInfo();
}
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),
m_address (LLDB_INVALID_ADDRESS),
m_break_id(LLDB_INVALID_BREAK_ID),
m_was_one_shot (false)
{
StoreBPInfo();
}
void
StoreBPInfo ()
{
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
{
BreakpointSiteSP bp_site_sp (thread_sp->GetProcess()->GetBreakpointSiteList().FindByID (m_value));
if (bp_site_sp)
{
if (bp_site_sp->GetNumberOfOwners() == 1)
{
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();
}
}
m_address = bp_site_sp->GetLoadAddress();
}
}
}
virtual ~StopInfoBreakpoint ()
{
}
virtual StopReason
GetStopReason () const
{
return eStopReasonBreakpoint;
}
virtual bool
ShouldStopSynchronous (Event *event_ptr)
{
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
{
if (!m_should_stop_is_valid)
{
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));
if (log)
log->Printf ("Process::%s could not find breakpoint site id: %" PRId64 "...", __FUNCTION__, m_value);
m_should_stop = true;
}
m_should_stop_is_valid = true;
}
return m_should_stop;
}
return false;
}
virtual bool
DoShouldNotify (Event *event_ptr)
{
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
{
BreakpointSiteSP bp_site_sp (thread_sp->GetProcess()->GetBreakpointSiteList().FindByID (m_value));
if (bp_site_sp)
{
bool all_internal = true;
for (uint32_t i = 0; i < bp_site_sp->GetNumberOfOwners(); i++)
{
if (!bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint().IsInternal())
{
all_internal = false;
break;
}
}
return all_internal == false;
}
}
return true;
}
virtual const char *
GetDescription ()
{
if (m_description.empty())
{
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
{
BreakpointSiteSP bp_site_sp (thread_sp->GetProcess()->GetBreakpointSiteList().FindByID (m_value));
if (bp_site_sp)
{
StreamString strm;
if (bp_site_sp->IsInternal())
{
size_t num_owners = bp_site_sp->GetNumberOfOwners();
for (size_t idx = 0; idx < num_owners; idx++)
{
const char *kind = bp_site_sp->GetOwnerAtIndex(idx)->GetBreakpoint().GetBreakpointKind();
if (kind != NULL)
{
m_description.assign (kind);
return kind;
}
}
}
strm.Printf("breakpoint ");
bp_site_sp->GetDescription(&strm, eDescriptionLevelBrief);
m_description.swap (strm.GetString());
}
else
{
StreamString strm;
if (m_break_id != LLDB_INVALID_BREAK_ID)
{
BreakpointSP break_sp = thread_sp->GetProcess()->GetTarget().GetBreakpointByID(m_break_id);
if (break_sp)
{
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);
}
else
{
strm.Printf ("breakpoint %d.", m_break_id);
}
}
else
{
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);
}
}
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);
m_description.swap (strm.GetString());
}
}
}
return m_description.c_str();
}
protected:
bool
ShouldStop (Event *event_ptr)
{
assert (m_should_stop_is_valid);
return m_should_stop;
}
virtual void
PerformAction (Event *event_ptr)
{
if (!m_should_perform_action)
return;
m_should_perform_action = false;
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
{
Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
if (!thread_sp->IsValid())
{
if (log)
{
log->Printf ("PerformAction got called with an invalid thread.");
}
m_should_stop = true;
m_should_stop_is_valid = true;
return;
}
BreakpointSiteSP bp_site_sp (thread_sp->GetProcess()->GetBreakpointSiteList().FindByID (m_value));
if (bp_site_sp)
{
size_t num_owners = bp_site_sp->GetNumberOfOwners();
if (num_owners == 0)
{
m_should_stop = true;
}
else
{
m_should_stop = false;
ExecutionContext exe_ctx (thread_sp->GetStackFrameAtIndex(0));
Process *process = exe_ctx.GetProcessPtr();
if (process->GetModIDRef().IsLastResumeForUserExpression())
{
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)
{
m_should_stop = false;
for (size_t j = 0; j < num_owners; j++)
{
lldb::BreakpointLocationSP bp_loc_sp = bp_site_sp->GetOwnerAtIndex(j);
if (bp_loc_sp->GetBreakpoint().IsInternal())
{
m_should_stop = true;
break;
}
}
}
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;
}
StoppointCallbackContext context (event_ptr, exe_ctx, false);
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++)
{
lldb::BreakpointLocationSP bp_loc_sp = site_locations.GetByIndex(j);
if (!bp_loc_sp->IsEnabled() || !bp_loc_sp->GetBreakpoint().IsEnabled())
continue;
if (!bp_loc_sp->ValidForThisThread(thread_sp.get()))
continue;
if (bp_loc_sp->GetConditionText() != NULL)
{
Error condition_error;
bool condition_says_stop = bp_loc_sp->ConditionSaysStop(exe_ctx, condition_error);
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);
error_sp->PutCString (err_str);
error_sp->EOL();
error_sp->Flush();
condition_says_stop = true;
}
else
{
if (!condition_says_stop)
continue;
}
}
bool callback_says_stop;
Debugger &debugger = thread_sp->CalculateTarget()->GetDebugger();
bool old_async = debugger.GetAsyncExecution();
debugger.SetAsyncExecution (true);
callback_says_stop = bp_loc_sp->InvokeCallback (&context);
debugger.SetAsyncExecution (old_async);
if (callback_says_stop)
m_should_stop = true;
if (callback_says_stop && bp_loc_sp && bp_loc_sp->GetBreakpoint().IsOneShot())
{
thread_sp->GetProcess()->GetTarget().RemoveBreakpointByID (bp_loc_sp->GetBreakpoint().GetID());
}
if (HasTargetRunSinceMe ())
{
m_should_stop = false;
break;
}
}
}
m_should_stop_is_valid = true;
}
else
{
m_should_stop = true;
m_should_stop_is_valid = true;
Log * log_process(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
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);
}
}
private:
std::string m_description;
bool m_should_stop;
bool m_should_stop_is_valid;
bool m_should_perform_action; lldb::addr_t m_address; lldb::break_id_t m_break_id;
bool m_was_one_shot;
};
class StopInfoWatchpoint : public StopInfo
{
public:
class WatchpointSentry {
public:
WatchpointSentry(Process *p, Watchpoint *w):
process(p),
watchpoint(w)
{
if (process && watchpoint)
{
const bool notify = false;
watchpoint->TurnOnEphemeralMode();
process->DisableWatchpoint(watchpoint, notify);
}
}
~WatchpointSentry()
{
if (process && watchpoint)
{
if (!watchpoint->IsDisabledDuringEphemeralMode())
{
const bool notify = false;
process->EnableWatchpoint(watchpoint, notify);
}
watchpoint->TurnOffEphemeralMode();
}
}
private:
Process *process;
Watchpoint *watchpoint;
};
StopInfoWatchpoint (Thread &thread, break_id_t watch_id) :
StopInfo(thread, watch_id),
m_description(),
m_should_stop(false),
m_should_stop_is_valid(false)
{
}
virtual ~StopInfoWatchpoint ()
{
}
virtual StopReason
GetStopReason () const
{
return eStopReasonWatchpoint;
}
virtual const char *
GetDescription ()
{
if (m_description.empty())
{
StreamString strm;
strm.Printf("watchpoint %" PRIi64, m_value);
m_description.swap (strm.GetString());
}
return m_description.c_str();
}
protected:
virtual bool
ShouldStopSynchronous (Event *event_ptr)
{
if (m_should_stop_is_valid)
return m_should_stop;
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
{
WatchpointSP wp_sp (thread_sp->CalculateTarget()->GetWatchpointList().FindByID(GetValue()));
if (wp_sp)
{
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));
if (log)
log->Printf ("Process::%s could not find watchpoint location id: %" PRId64 "...",
__FUNCTION__, GetValue());
m_should_stop = true;
}
}
m_should_stop_is_valid = true;
return m_should_stop;
}
bool
ShouldStop (Event *event_ptr)
{
assert (m_should_stop_is_valid);
return m_should_stop;
}
virtual void
PerformAction (Event *event_ptr)
{
Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS);
m_should_stop = true;
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
{
WatchpointSP wp_sp (thread_sp->CalculateTarget()->GetWatchpointList().FindByID(GetValue()));
if (wp_sp)
{
ExecutionContext exe_ctx (thread_sp->GetStackFrameAtIndex(0));
Process* process = exe_ctx.GetProcessPtr();
WatchpointSentry sentry(process, wp_sp.get());
{
if (process)
{
uint32_t num;
bool wp_triggers_after;
if (process->GetWatchpointSupportInfo(num, wp_triggers_after).Success())
{
if (!wp_triggers_after)
{
StopInfoSP stored_stop_info_sp = thread_sp->GetStopInfo();
assert (stored_stop_info_sp.get() == this);
ThreadPlanSP new_plan_sp(thread_sp->QueueThreadPlanForStepSingleInstruction(false, false, true)); new_plan_sp->SetIsMasterPlan (true);
new_plan_sp->SetOkayToDiscard (false);
new_plan_sp->SetPrivate (true);
process->GetThreadList().SetSelectedThreadByID (thread_sp->GetID());
process->Resume ();
process->WaitForProcessToStop (NULL);
process->GetThreadList().SetSelectedThreadByID (thread_sp->GetID());
thread_sp->SetStopInfo(stored_stop_info_sp);
}
}
}
}
if (m_should_stop && wp_sp->GetConditionText() != NULL)
{
ExecutionResults result_code;
ValueObjectSP result_value_sp;
const bool unwind_on_error = true;
const bool ignore_breakpoints = true;
Error error;
result_code = ClangUserExpression::EvaluateWithError (exe_ctx,
eExecutionPolicyOnlyWhenNeeded,
lldb::eLanguageTypeUnknown,
ClangUserExpression::eResultTypeAny,
unwind_on_error,
ignore_breakpoints,
wp_sp->GetConditionText(),
NULL,
result_value_sp,
error,
true,
ClangUserExpression::kDefaultTimeout);
if (result_code == eExecutionCompleted)
{
if (result_value_sp)
{
Scalar scalar_value;
if (result_value_sp->ResolveValue (scalar_value))
{
if (scalar_value.ULongLong(1) == 0)
{
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");
}
else
{
m_should_stop = true;
if (log)
log->Printf("Failed to get an integer result from the expression.");
}
}
}
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();
m_should_stop = true;
}
}
if (m_should_stop)
{
StoppointCallbackContext context (event_ptr, exe_ctx, false);
bool stop_requested = wp_sp->InvokeCallback (&context);
if (HasTargetRunSinceMe ())
m_should_stop = false;
if (m_should_stop && !stop_requested)
{
m_should_stop = false;
}
}
if (m_should_stop)
{
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();
}
}
else
{
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);
}
if (log)
log->Printf ("Process::%s returning from action with m_should_stop: %d.", __FUNCTION__, m_should_stop);
m_should_stop_is_valid = true;
}
}
private:
std::string m_description;
bool m_should_stop;
bool m_should_stop_is_valid;
};
class StopInfoUnixSignal : public StopInfo
{
public:
StopInfoUnixSignal (Thread &thread, int signo) :
StopInfo (thread, signo)
{
}
virtual ~StopInfoUnixSignal ()
{
}
virtual StopReason
GetStopReason () const
{
return eStopReasonSignal;
}
virtual bool
ShouldStopSynchronous (Event *event_ptr)
{
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
return thread_sp->GetProcess()->GetUnixSignals().GetShouldStop (m_value);
return false;
}
virtual bool
ShouldStop (Event *event_ptr)
{
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
return thread_sp->GetProcess()->GetUnixSignals().GetShouldStop (m_value);
return false;
}
virtual bool
DoShouldNotify (Event *event_ptr)
{
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
{
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;
}
return true;
}
virtual void
WillResume (lldb::StateType resume_state)
{
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
{
if (thread_sp->GetProcess()->GetUnixSignals().GetShouldSuppress(m_value) == false)
thread_sp->SetResumeSignal(m_value);
}
}
virtual const char *
GetDescription ()
{
if (m_description.empty())
{
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());
}
}
return m_description.c_str();
}
};
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 ()
{
if (m_description.empty())
return "trace";
else
return m_description.c_str();
}
};
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();
}
};
class StopInfoThreadPlan : public StopInfo
{
public:
StopInfoThreadPlan (ThreadPlanSP &plan_sp, ValueObjectSP &return_valobj_sp) :
StopInfo (plan_sp->GetThread(), LLDB_INVALID_UID),
m_plan_sp (plan_sp),
m_return_valobj_sp (return_valobj_sp)
{
}
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();
}
ValueObjectSP
GetReturnValueObject()
{
return m_return_valobj_sp;
}
protected:
virtual bool
ShouldStop (Event *event_ptr)
{
if (m_plan_sp)
return m_plan_sp->ShouldStop(event_ptr);
else
return StopInfo::ShouldStop(event_ptr);
}
private:
ThreadPlanSP m_plan_sp;
ValueObjectSP m_return_valobj_sp;
};
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)
{
if (m_performed_action)
return;
m_performed_action = true;
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
thread_sp->GetProcess()->DidExec();
}
bool m_performed_action;
};
}
StopInfoSP
StopInfo::CreateStopReasonWithBreakpointSiteID (Thread &thread, break_id_t break_id)
{
return StopInfoSP (new StopInfoBreakpoint (thread, break_id));
}
StopInfoSP
StopInfo::CreateStopReasonWithBreakpointSiteID (Thread &thread, break_id_t break_id, bool should_stop)
{
return StopInfoSP (new StopInfoBreakpoint (thread, break_id, should_stop));
}
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
StopInfo::CreateStopReasonWithPlan (ThreadPlanSP &plan_sp, ValueObjectSP return_valobj_sp)
{
return StopInfoSP (new StopInfoThreadPlan (plan_sp, return_valobj_sp));
}
StopInfoSP
StopInfo::CreateStopReasonWithException (Thread &thread, const char *description)
{
return StopInfoSP (new StopInfoException (thread, description));
}
StopInfoSP
StopInfo::CreateStopReasonWithExec (Thread &thread)
{
return StopInfoSP (new StopInfoExec (thread));
}
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();
}