forked from OSchip/llvm-project
Created a std::string in the base StopInfo class for the description and
cleaned up all base classes that had their own copy. Added a SetDescription accessor to the StopInfo class. llvm-svn: 132615
This commit is contained in:
parent
64ae92e5c5
commit
a658fd26c3
|
@ -12,6 +12,8 @@
|
|||
|
||||
// C Includes
|
||||
// C++ Includes
|
||||
#include <string>
|
||||
|
||||
// Other libraries and framework includes
|
||||
// Project includes
|
||||
#include "lldb/lldb-public.h"
|
||||
|
@ -92,8 +94,19 @@ public:
|
|||
}
|
||||
|
||||
virtual const char *
|
||||
GetDescription () = 0;
|
||||
GetDescription ()
|
||||
{
|
||||
return m_description.c_str();
|
||||
}
|
||||
|
||||
virtual void
|
||||
SetDescription (const char *desc_cstr)
|
||||
{
|
||||
if (desc_cstr && desc_cstr[0])
|
||||
m_description.assign (desc_cstr);
|
||||
else
|
||||
m_description.clear();
|
||||
}
|
||||
|
||||
static lldb::StopInfoSP
|
||||
CreateStopReasonWithBreakpointSiteID (Thread &thread, lldb::break_id_t break_id);
|
||||
|
@ -114,6 +127,9 @@ public:
|
|||
static lldb::StopInfoSP
|
||||
CreateStopReasonWithPlan (lldb::ThreadPlanSP &plan);
|
||||
|
||||
static lldb::StopInfoSP
|
||||
CreateStopReasonWithException (Thread &thread, const char *description);
|
||||
|
||||
protected:
|
||||
//------------------------------------------------------------------
|
||||
// Classes that inherit from StackID can see and modify these
|
||||
|
@ -121,6 +137,7 @@ protected:
|
|||
Thread & m_thread; // The thread corresponding to the stop reason.
|
||||
uint32_t m_stop_id; // The process stop ID for which this stop info is valid
|
||||
uint64_t m_value; // A generic value that can be used for things pertaining to this stop info
|
||||
std::string m_description; // A textual description describing this stop.
|
||||
private:
|
||||
friend class Thread;
|
||||
|
||||
|
|
|
@ -454,6 +454,10 @@ EmulateInstruction::Context::Dump (Stream &strm,
|
|||
strm.PutCString ("adjust sp");
|
||||
break;
|
||||
|
||||
case eContextSetFramePointer:
|
||||
strm.PutCString ("set frame pointer");
|
||||
break;
|
||||
|
||||
case eContextAdjustBaseRegister:
|
||||
strm.PutCString ("adjusting (writing value back to) a base register");
|
||||
break;
|
||||
|
|
|
@ -391,9 +391,6 @@ ABIMacOSX_arm::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan)
|
|||
pc_reg_num == LLDB_INVALID_REGNUM)
|
||||
return false;
|
||||
|
||||
unwind_plan.Clear();
|
||||
unwind_plan.SetRegisterKind (eRegisterKindDWARF);
|
||||
|
||||
UnwindPlan::Row row;
|
||||
|
||||
// Our previous Call Frame Address is the stack pointer
|
||||
|
@ -439,7 +436,7 @@ ABIMacOSX_arm::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan)
|
|||
return false;
|
||||
|
||||
UnwindPlan::Row row;
|
||||
const int32_t ptr_size = 8;
|
||||
const int32_t ptr_size = 4;
|
||||
|
||||
unwind_plan.SetRegisterKind (eRegisterKindGeneric);
|
||||
row.SetCFARegister (fp_reg_num);
|
||||
|
|
|
@ -1120,6 +1120,8 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet)
|
|||
std::string name;
|
||||
std::string value;
|
||||
std::string thread_name;
|
||||
std::string reason;
|
||||
std::string description;
|
||||
uint32_t exc_type = 0;
|
||||
std::vector<addr_t> exc_data;
|
||||
uint32_t tid = LLDB_INVALID_THREAD_ID;
|
||||
|
@ -1174,6 +1176,18 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet)
|
|||
{
|
||||
thread_dispatch_qaddr = Args::StringToUInt64 (value.c_str(), 0, 16);
|
||||
}
|
||||
else if (name.compare("reason") == 0)
|
||||
{
|
||||
reason.swap(value);
|
||||
}
|
||||
else if (name.compare("description") == 0)
|
||||
{
|
||||
StringExtractor desc_extractor;
|
||||
// Swap "value" over into "name_extractor"
|
||||
desc_extractor.GetStringRef().swap(value);
|
||||
// Now convert the HEX bytes into a string value
|
||||
desc_extractor.GetHexByteString (thread_name);
|
||||
}
|
||||
else if (name.size() == 2 && ::isxdigit(name[0]) && ::isxdigit(name[1]))
|
||||
{
|
||||
// We have a register number that contains an expedited
|
||||
|
@ -1218,8 +1232,83 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet)
|
|||
exc_data_size >= 1 ? exc_data[0] : 0,
|
||||
exc_data_size >= 2 ? exc_data[1] : 0));
|
||||
}
|
||||
else if (signo)
|
||||
else
|
||||
{
|
||||
bool handled = false;
|
||||
if (!reason.empty())
|
||||
{
|
||||
if (reason.compare("trace") == 0)
|
||||
{
|
||||
gdb_thread->SetStopInfo (StopInfo::CreateStopReasonToTrace (*thread_sp));
|
||||
handled = true;
|
||||
}
|
||||
else if (reason.compare("breakpoint") == 0)
|
||||
{
|
||||
addr_t pc = gdb_thread->GetRegisterContext()->GetPC();
|
||||
lldb::BreakpointSiteSP bp_site_sp = gdb_thread->GetProcess().GetBreakpointSiteList().FindByAddress(pc);
|
||||
if (bp_site_sp)
|
||||
{
|
||||
// If the breakpoint is for this thread, then we'll report the hit, but if it is for another thread,
|
||||
// we can just report no reason. We don't need to worry about stepping over the breakpoint here, that
|
||||
// will be taken care of when the thread resumes and notices that there's a breakpoint under the pc.
|
||||
if (bp_site_sp->ValidForThisThread (gdb_thread))
|
||||
{
|
||||
gdb_thread->SetStopInfo (StopInfo::CreateStopReasonWithBreakpointSiteID (*thread_sp, bp_site_sp->GetID()));
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!handled)
|
||||
{
|
||||
gdb_thread->SetStopInfo (StopInfo::CreateStopReasonToTrace (*thread_sp));
|
||||
}
|
||||
}
|
||||
else if (reason.compare("trap") == 0)
|
||||
{
|
||||
// Let the trap just use the standard signal stop reason below...
|
||||
}
|
||||
else if (reason.compare("watchpoint") == 0)
|
||||
{
|
||||
break_id_t watch_id = LLDB_INVALID_WATCH_ID;
|
||||
// TODO: locate the watchpoint somehow...
|
||||
gdb_thread->SetStopInfo (StopInfo::CreateStopReasonWithWatchpointID (*thread_sp, watch_id));
|
||||
handled = true;
|
||||
}
|
||||
else if (reason.compare("exception") == 0)
|
||||
{
|
||||
gdb_thread->SetStopInfo (StopInfo::CreateStopReasonWithException(*thread_sp, description.c_str()));
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (signo)
|
||||
{
|
||||
if (signo == SIGTRAP)
|
||||
{
|
||||
// Currently we are going to assume SIGTRAP means we are either
|
||||
// hitting a breakpoint or hardware single stepping.
|
||||
addr_t pc = gdb_thread->GetRegisterContext()->GetPC();
|
||||
lldb::BreakpointSiteSP bp_site_sp = gdb_thread->GetProcess().GetBreakpointSiteList().FindByAddress(pc);
|
||||
if (bp_site_sp)
|
||||
{
|
||||
// If the breakpoint is for this thread, then we'll report the hit, but if it is for another thread,
|
||||
// we can just report no reason. We don't need to worry about stepping over the breakpoint here, that
|
||||
// will be taken care of when the thread resumes and notices that there's a breakpoint under the pc.
|
||||
if (bp_site_sp->ValidForThisThread (gdb_thread))
|
||||
{
|
||||
gdb_thread->SetStopInfo (StopInfo::CreateStopReasonWithBreakpointSiteID (*thread_sp, bp_site_sp->GetID()));
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
if (!handled)
|
||||
{
|
||||
// TODO: check for breakpoint or trap opcode in case there is a hard
|
||||
// coded software trap
|
||||
gdb_thread->SetStopInfo (StopInfo::CreateStopReasonToTrace (*thread_sp));
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
if (!handled)
|
||||
gdb_thread->SetStopInfo (StopInfo::CreateStopReasonWithSignal (*thread_sp, signo));
|
||||
}
|
||||
else
|
||||
|
@ -1227,6 +1316,20 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet)
|
|||
StopInfoSP invalid_stop_info_sp;
|
||||
gdb_thread->SetStopInfo (invalid_stop_info_sp);
|
||||
}
|
||||
|
||||
if (!description.empty())
|
||||
{
|
||||
lldb::StopInfoSP stop_info_sp (gdb_thread->GetStopInfo ());
|
||||
if (stop_info_sp)
|
||||
{
|
||||
stop_info_sp->SetDescription (description.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
gdb_thread->SetStopInfo (StopInfo::CreateStopReasonWithException (*thread_sp, description.c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return eStateStopped;
|
||||
}
|
||||
|
|
|
@ -253,8 +253,7 @@ class StopInfoUnixSignal : public StopInfo
|
|||
public:
|
||||
|
||||
StopInfoUnixSignal (Thread &thread, int signo) :
|
||||
StopInfo (thread, signo),
|
||||
m_description()
|
||||
StopInfo (thread, signo)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -306,9 +305,6 @@ public:
|
|||
}
|
||||
return m_description.c_str();
|
||||
}
|
||||
|
||||
private:
|
||||
std::string m_description;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -337,7 +333,47 @@ public:
|
|||
virtual const char *
|
||||
GetDescription ()
|
||||
{
|
||||
if (m_description.empty())
|
||||
return "trace";
|
||||
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();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -380,7 +416,6 @@ public:
|
|||
|
||||
private:
|
||||
ThreadPlanSP m_plan_sp;
|
||||
std::string m_description;
|
||||
};
|
||||
|
||||
StopInfoSP
|
||||
|
@ -418,3 +453,9 @@ StopInfo::CreateStopReasonWithPlan (ThreadPlanSP &plan_sp)
|
|||
{
|
||||
return StopInfoSP (new StopInfoThreadPlan (plan_sp));
|
||||
}
|
||||
|
||||
StopInfoSP
|
||||
StopInfo::CreateStopReasonWithException (Thread &thread, const char *description)
|
||||
{
|
||||
return StopInfoSP (new StopInfoException (thread, description));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue