summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2010-08-12 02:14:28 +0000
committerJim Ingham <jingham@apple.com>2010-08-12 02:14:28 +0000
commit87c1191e0e392f70965b8ce3b89e57d5165aadc7 (patch)
treed0e48015479611e52c2839a65f35e282b8812e42 /lldb/source/Plugins/Process
parent1401e040eb7f2910f574ddea8dea4e1b1b42a95f (diff)
downloadbcm5719-llvm-87c1191e0e392f70965b8ce3b89e57d5165aadc7.tar.gz
bcm5719-llvm-87c1191e0e392f70965b8ce3b89e57d5165aadc7.zip
Now that we are using the Unwinder (or Jason's new unwinder when that comes about) all the plugin-specific details of getting stack frames
should be hidden behind that, and the "GetStackFrameAtIndex" and "GetStackFrameCount" algorithms become generic. So I moved them to Thread.cpp. llvm-svn: 110899
Diffstat (limited to 'lldb/source/Plugins/Process')
-rw-r--r--lldb/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp64
-rw-r--r--lldb/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.h9
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp58
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h9
4 files changed, 26 insertions, 114 deletions
diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp b/lldb/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp
index 974421074a9..a9920bb09a9 100644
--- a/lldb/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp
@@ -22,6 +22,10 @@
#include "lldb/Target/RegisterContext.h"
#include "lldb/Breakpoint/WatchpointLocation.h"
#include "lldb/Core/StreamString.h"
+#include "lldb/Target/Unwind.h"
+#include "LibUnwindRegisterContext.h"
+#include "UnwindLibUnwind.h"
+#include "UnwindMacOSXFrameBackchain.h"
using namespace lldb;
using namespace lldb_private;
@@ -203,54 +207,28 @@ ThreadMacOSX::RefreshStateAfterStop()
m_basic_info_string.clear();
}
-uint32_t
-ThreadMacOSX::GetStackFrameCount()
-{
- if (m_fp_pc_pairs.empty())
- GetStackFrameData(m_fp_pc_pairs);
- return m_fp_pc_pairs.size();
-}
-
-// Make sure that GetStackFrameAtIndex() does NOT call GetStackFrameCount() when
-// getting the stack frame at index zero! This way GetStackFrameCount() (via
-// GetStackFRameData()) can call this function to get the first frame in order
-// to provide the first frame to a lower call for efficiency sake (avoid
-// redundant lookups in the frame symbol context).
-lldb::StackFrameSP
-ThreadMacOSX::GetStackFrameAtIndex (uint32_t idx)
+Unwind *
+ThreadMacOSX::GetUnwinder ()
{
- StackFrameSP frame_sp(m_frames.GetFrameAtIndex(idx));
-
- if (frame_sp)
- return frame_sp;
-
- // Don't try and fetch a frame while process is running
- // Calling IsRunning isn't right here, because IsRunning reads the Public
- // state but we need to be able to read the stack frames in the ShouldStop
- // methods, which happen before the Public state has been updated.
-// if (m_process.IsRunning())
-// return frame_sp;
-
- // Special case the first frame (idx == 0) so that we don't need to
- // know how many stack frames there are to get it. If we need any other
- // frames, then we do need to know if "idx" is a valid index.
- if (idx == 0)
- {
- // If this is the first frame, we want to share the thread register
- // context with the stack frame at index zero.
- GetRegisterContext();
- assert (m_reg_context_sp.get());
- frame_sp.reset (new StackFrame (idx, *this, m_reg_context_sp, m_reg_context_sp->GetFP(), m_reg_context_sp->GetPC()));
- }
- else if (idx < GetStackFrameCount())
+ if (m_unwinder_ap.get() == NULL)
{
- assert (idx < m_fp_pc_pairs.size());
- frame_sp.reset (new StackFrame (idx, *this, m_fp_pc_pairs[idx].first, m_fp_pc_pairs[idx].second));
+ const ArchSpec target_arch (GetProcess().GetTarget().GetArchitecture ());
+#if 0 // Not sure this is the right thing to do for native, but this will all go away with Jason's new
+ // unwinder anyway...
+ if (target_arch == ArchSpec("x86_64") || target_arch == ArchSpec("i386"))
+ {
+ m_unwinder_ap.reset (new UnwindLibUnwind (*this, GetGDBProcess().GetLibUnwindAddressSpace()));
+ }
+ else
+#endif
+ {
+ m_unwinder_ap.reset (new UnwindMacOSXFrameBackchain (*this));
+ }
}
- m_frames.SetFrameAtIndex(idx, frame_sp);
- return frame_sp;
+ return m_unwinder_ap.get();
}
+
void
ThreadMacOSX::ClearStackFrames ()
{
diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.h b/lldb/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.h
index 2e57ca93112..a610b76d980 100644
--- a/lldb/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.h
+++ b/lldb/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.h
@@ -51,12 +51,6 @@ public:
virtual bool
RestoreSaveFrameZero (const RegisterCheckpoint &checkpoint);
- virtual uint32_t
- GetStackFrameCount();
-
- virtual lldb::StackFrameSP
- GetStackFrameAtIndex (uint32_t idx);
-
virtual void
ClearStackFrames ();
@@ -139,6 +133,9 @@ protected:
static bool
GetBasicInfo (lldb::tid_t threadID, struct thread_basic_info *basic_info);
+ virtual lldb_private::Unwind *
+ GetUnwinder ();
+
//------------------------------------------------------------------
// Member variables.
//------------------------------------------------------------------
diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
index 6f7cf7bc4fd..66cf0b06027 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
@@ -38,8 +38,7 @@ ThreadGDBRemote::ThreadGDBRemote (ProcessGDBRemote &process, lldb::tid_t tid) :
Thread(process, tid),
m_thread_name (),
m_dispatch_queue_name (),
- m_thread_dispatch_qaddr (LLDB_INVALID_ADDRESS),
- m_unwinder_ap ()
+ m_thread_dispatch_qaddr (LLDB_INVALID_ADDRESS)
{
// ProcessGDBRemoteLog::LogIf(GDBR_LOG_THREAD | GDBR_LOG_VERBOSE, "ThreadGDBRemote::ThreadGDBRemote ( pid = %i, tid = 0x%4.4x, )", m_process.GetID(), GetID());
ProcessGDBRemoteLog::LogIf(GDBR_LOG_THREAD, "%p: ThreadGDBRemote::ThreadGDBRemote (pid = %i, tid = 0x%4.4x)", this, m_process.GetID(), GetID());
@@ -136,61 +135,6 @@ ThreadGDBRemote::GetUnwinder ()
return m_unwinder_ap.get();
}
-uint32_t
-ThreadGDBRemote::GetStackFrameCount()
-{
- Unwind *unwinder = GetUnwinder ();
- if (unwinder)
- return unwinder->GetFrameCount();
- return 0;
-}
-
-// Make sure that GetStackFrameAtIndex() does NOT call GetStackFrameCount() when
-// getting the stack frame at index zero! This way GetStackFrameCount() (via
-// GetStackFRameData()) can call this function to get the first frame in order
-// to provide the first frame to a lower call for efficiency sake (avoid
-// redundant lookups in the frame symbol context).
-lldb::StackFrameSP
-ThreadGDBRemote::GetStackFrameAtIndex (uint32_t idx)
-{
-
- StackFrameSP frame_sp (m_frames.GetFrameAtIndex(idx));
-
- if (frame_sp.get())
- return frame_sp;
-
- // Don't try and fetch a frame while process is running
-// FIXME: This check isn't right because IsRunning checks the Public state, but this
-// is work you need to do - for instance in ShouldStop & friends - before the public
-// state has been changed.
-// if (m_process.IsRunning())
-// return frame_sp;
-
- // Special case the first frame (idx == 0) so that we don't need to
- // know how many stack frames there are to get it. If we need any other
- // frames, then we do need to know if "idx" is a valid index.
- if (idx == 0)
- {
- // If this is the first frame, we want to share the thread register
- // context with the stack frame at index zero.
- GetRegisterContext();
- assert (m_reg_context_sp.get());
- frame_sp.reset (new StackFrame (idx, *this, m_reg_context_sp, m_reg_context_sp->GetSP(), m_reg_context_sp->GetPC()));
- }
- else if (idx < GetStackFrameCount())
- {
- Unwind *unwinder = GetUnwinder ();
- if (unwinder)
- {
- addr_t pc, cfa;
- if (unwinder->GetFrameInfoAtIndex(idx, cfa, pc))
- frame_sp.reset (new StackFrame (idx, *this, cfa, pc));
- }
- }
- m_frames.SetFrameAtIndex(idx, frame_sp);
- return frame_sp;
-}
-
void
ThreadGDBRemote::ClearStackFrames ()
{
diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h
index 01c37d8b5df..a6deead8f15 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h
+++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h
@@ -54,12 +54,6 @@ public:
virtual bool
RestoreSaveFrameZero (const RegisterCheckpoint &checkpoint);
- virtual uint32_t
- GetStackFrameCount();
-
- virtual lldb::StackFrameSP
- GetStackFrameAtIndex (uint32_t idx);
-
virtual void
ClearStackFrames ();
@@ -121,12 +115,11 @@ protected:
std::string m_thread_name;
std::string m_dispatch_queue_name;
lldb::addr_t m_thread_dispatch_qaddr;
- std::auto_ptr<lldb_private::Unwind> m_unwinder_ap;
//------------------------------------------------------------------
// Member variables.
//------------------------------------------------------------------
- lldb_private::Unwind *
+ virtual lldb_private::Unwind *
GetUnwinder ();
void
OpenPOWER on IntegriCloud