summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/gdb-remote
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2010-08-04 01:40:35 +0000
committerGreg Clayton <gclayton@apple.com>2010-08-04 01:40:35 +0000
commitf4b47e15799f16cef4baef4c3ee2519878b0f37a (patch)
tree44271b117f0b87f44f903c5eb471448dd17f5e93 /lldb/source/Plugins/Process/gdb-remote
parent5cae10339208cdf484d67df5d65995a5338f097d (diff)
downloadbcm5719-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/Plugins/Process/gdb-remote')
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp19
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp24
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h22
3 files changed, 24 insertions, 41 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 2bb7a1033a4..759f20dafb4 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -46,6 +46,8 @@
#include "ProcessGDBRemoteLog.h"
#include "ThreadGDBRemote.h"
#include "MacOSXLibunwindCallbacks.h"
+#include "StopInfoMachException.h"
+
#define DEBUGSERVER_BASENAME "debugserver"
@@ -1021,21 +1023,24 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet)
gdb_thread->SetThreadDispatchQAddr (thread_dispatch_qaddr);
gdb_thread->SetName (thread_name.empty() ? thread_name.c_str() : NULL);
- Thread::StopInfo& stop_info = gdb_thread->GetStopInfoRef();
- gdb_thread->SetStopInfoStopID (GetStopID());
if (exc_type != 0)
{
- stop_info.SetStopReasonWithMachException (exc_type,
- exc_data.size(),
- &exc_data[0]);
+ const size_t exc_data_count = exc_data.size();
+
+ gdb_thread->SetStopInfo (StopInfoMachException::CreateStopReasonWithMachException (*thread_sp,
+ exc_type,
+ exc_data_count,
+ exc_data_count >= 1 ? exc_data[0] : 0,
+ exc_data_count >= 2 ? exc_data[1] : 0));
}
else if (signo)
{
- stop_info.SetStopReasonWithSignal (signo);
+ gdb_thread->SetStopInfo (StopInfo::CreateStopReasonWithSignal (*thread_sp, signo));
}
else
{
- stop_info.SetStopReasonToNone ();
+ StopInfoSP invalid_stop_info_sp;
+ gdb_thread->SetStopInfo (invalid_stop_info_sp);
}
}
return eStateStopped;
diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
index 4eae1e6d41b..6f7cf7bc4fd 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
@@ -15,6 +15,7 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Unwind.h"
#include "lldb/Breakpoint/WatchpointLocation.h"
@@ -35,8 +36,6 @@ using namespace lldb_private;
ThreadGDBRemote::ThreadGDBRemote (ProcessGDBRemote &process, lldb::tid_t tid) :
Thread(process, tid),
- m_stop_info_stop_id (0),
- m_stop_info (this),
m_thread_name (),
m_dispatch_queue_name (),
m_thread_dispatch_qaddr (LLDB_INVALID_ADDRESS),
@@ -83,7 +82,7 @@ ThreadGDBRemote::WillResume (StateType resume_state)
// TODO: cache for next time in case we can match things up??
ClearStackFrames();
int signo = GetResumeSignal();
- m_stop_info.Clear();
+
switch (resume_state)
{
case eStateSuspended:
@@ -269,11 +268,13 @@ ThreadGDBRemote::RestoreSaveFrameZero (const RegisterCheckpoint &checkpoint)
return false;
}
-bool
-ThreadGDBRemote::GetRawStopReason (StopInfo *stop_info)
+lldb::StopInfoSP
+ThreadGDBRemote::GetPrivateStopReason ()
{
- if (m_stop_info_stop_id != m_process.GetStopID())
+ if (m_actual_stop_info_sp.get() == NULL || m_actual_stop_info_sp->IsValid() == false)
{
+ m_actual_stop_info_sp.reset();
+
char packet[256];
::snprintf(packet, sizeof(packet), "qThreadStopInfo%x", GetID());
StringExtractorGDBRemote stop_packet;
@@ -281,18 +282,9 @@ ThreadGDBRemote::GetRawStopReason (StopInfo *stop_info)
{
std::string copy(stop_packet.GetStringRef());
GetGDBProcess().SetThreadStopInfo (stop_packet);
- // The process should have set the stop info stop ID and also
- // filled this thread in with valid stop info
- if (m_stop_info_stop_id != m_process.GetStopID())
- {
- //ProcessGDBRemoteLog::LogIf(GDBR_LOG_THREAD, "warning: qThreadStopInfo problem: '%s' => '%s'", packet, stop_packet.GetStringRef().c_str());
- printf("warning: qThreadStopInfo problem: '%s' => '%s'\n\torig '%s'\n", packet, stop_packet.GetStringRef().c_str(), copy.c_str()); /// REMOVE THIS
- return false;
- }
}
}
- *stop_info = m_stop_info;
- return true;
+ return m_actual_stop_info_sp;
}
diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h
index d40c2e1f6ab..01c37d8b5df 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h
+++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h
@@ -87,22 +87,10 @@ public:
const char *
GetBasicInfoAsString ();
- lldb_private::Thread::StopInfo &
- GetStopInfoRef ()
- {
- return m_stop_info;
- }
-
- uint32_t
- GetStopInfoStopID()
- {
- return m_stop_info_stop_id;
- }
-
void
- SetStopInfoStopID (uint32_t stop_id)
+ SetStopInfo (const lldb::StopInfoSP &stop_info)
{
- m_stop_info_stop_id = stop_id;
+ m_actual_stop_info_sp = stop_info;
}
void
@@ -130,8 +118,6 @@ protected:
//------------------------------------------------------------------
// Member variables.
//------------------------------------------------------------------
- uint32_t m_stop_info_stop_id;
- lldb_private::Thread::StopInfo m_stop_info;
std::string m_thread_name;
std::string m_dispatch_queue_name;
lldb::addr_t m_thread_dispatch_qaddr;
@@ -146,8 +132,8 @@ protected:
void
SetStopInfoFromPacket (StringExtractor &stop_packet, uint32_t stop_id);
- virtual bool
- GetRawStopReason (StopInfo *stop_info);
+ virtual lldb::StopInfoSP
+ GetPrivateStopReason ();
};
OpenPOWER on IntegriCloud