summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/MacOSX-User
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/MacOSX-User
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/MacOSX-User')
-rw-r--r--lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.cpp23
-rw-r--r--lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.h2
-rw-r--r--lldb/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp69
-rw-r--r--lldb/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.h4
4 files changed, 18 insertions, 80 deletions
diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.cpp b/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.cpp
index d32ed5cd4cf..cfea47518ca 100644
--- a/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.cpp
@@ -13,6 +13,7 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Host/Host.h"
+#include "StopInfoMachException.h"
#include "MachException.h"
#include "ProcessMacOSXLog.h"
@@ -198,22 +199,16 @@ MachException::Message::PutToLog(Log *log) const
}
}
-bool
-MachException::Data::GetStopInfo(Thread::StopInfo *stop_info) const
+lldb::StopInfoSP
+MachException::Data::GetStopInfo (lldb_private::Thread &thread) const
{
- // Zero out the structure.
- stop_info->Clear();
-
- // Make sure we have a valid exception before we return anything valid
- if (exc_type == 0)
- return true;
- // We always stop with a mach exceptions
+
const size_t exc_data_count = exc_data.size();
- stop_info->SetStopReasonWithMachException (exc_type,
- exc_data_count,
- exc_data_count ? &exc_data[0] : NULL);
-
- return true;
+ return StopInfoMachException::CreateStopReasonWithMachException (thread,
+ exc_type,
+ exc_data_count,
+ exc_data_count >= 1 ? exc_data[0] : 0,
+ exc_data_count >= 2 ? exc_data[1] : 0);
}
diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.h b/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.h
index 886cbabc20c..761f433405b 100644
--- a/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.h
+++ b/lldb/source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.h
@@ -98,7 +98,7 @@ public:
}
void PutToLog(lldb_private::Log *log) const;
void DumpStopReason() const;
- bool GetStopInfo(lldb_private::Thread::StopInfo *stop_info) const;
+ lldb::StopInfoSP GetStopInfo (lldb_private::Thread &thread) const;
};
struct Message
diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp b/lldb/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp
index 826407662ad..974421074a9 100644
--- a/lldb/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp
@@ -13,6 +13,7 @@
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Target/Process.h"
+#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Target.h"
#include "ProcessMacOSX.h"
@@ -63,70 +64,12 @@ ThreadMacOSX::~ThreadMacOSX ()
#endif
-bool
-ThreadMacOSX::GetRawStopReason (Thread::StopInfo *stop_info )
+StopInfoSP
+ThreadMacOSX::GetPrivateStopReason ()
{
- stop_info->SetThread(this);
-
- bool success = GetStopException().GetStopInfo(stop_info);
-
-
-#if defined (MACH_SOFTWARE_BREAKPOINT_DATA_0) || defined (MACH_TRAP_DATA_0)
- if (stop_info->GetStopReason() == eStopReasonException)
- {
- if (stop_info->GetExceptionType() == EXC_BREAKPOINT && stop_info->GetExceptionDataCount() == 2)
- {
- const lldb::addr_t data_0 = stop_info->GetExceptionDataAtIndex(0);
-#if defined (MACH_SOFTWARE_BREAKPOINT_DATA_0)
- if (data_0 == MACH_SOFTWARE_BREAKPOINT_DATA_0)
- {
- lldb::addr_t pc = GetRegisterContext()->GetPC();
- lldb::BreakpointSiteSP bp_site_sp = m_process.GetBreakpointSiteList().FindByAddress(pc);
- if (bp_site_sp)
- {
- if (bp_site_sp->ValidForThisThread (this))
- {
- stop_info->Clear ();
- stop_info->SetStopReasonWithBreakpointSiteID (GetID());
- }
- else
- {
- stop_info->Clear ();
- stop_info->SetStopReasonToNone();
- }
- return success;
- }
- }
-#endif
-#if defined (MACH_TRAP_DATA_0)
- if (data_0 == MACH_TRAP_DATA_0)
- {
- stop_info->Clear ();
- stop_info->SetStopReasonToTrace ();
- return success;
- }
-#endif
- }
- }
-#endif
-
- if (stop_info->GetStopReason() == eStopReasonException)
- {
- if (stop_info->GetExceptionType() == EXC_SOFTWARE &&
- stop_info->GetExceptionDataCount() == 2 &&
- stop_info->GetExceptionDataAtIndex(0) == EXC_SOFT_SIGNAL)
- {
- int signo = stop_info->GetExceptionDataAtIndex(1);
- stop_info->Clear ();
- stop_info->SetStopReasonWithSignal (signo);
- }
- }
- else
- {
- stop_info->SetStopReasonToNone();
- }
-
- return success;
+ if (m_actual_stop_info_sp.get() == NULL || m_actual_stop_info_sp->IsValid() == false)
+ m_actual_stop_info_sp = GetStopException().GetStopInfo(*this);
+ return m_actual_stop_info_sp;
}
const char *
diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.h b/lldb/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.h
index 0039f3639f1..2e57ca93112 100644
--- a/lldb/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.h
+++ b/lldb/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.h
@@ -126,8 +126,8 @@ public:
size_t
GetStackFrameData (std::vector<std::pair<lldb::addr_t, lldb::addr_t> >& fp_pc_pairs);
- virtual bool
- GetRawStopReason (lldb_private::Thread::StopInfo *stop_info);
+ virtual lldb::StopInfoSP
+ GetPrivateStopReason ();
protected:
bool
OpenPOWER on IntegriCloud