diff options
author | Jim Ingham <jingham@apple.com> | 2010-08-12 02:14:28 +0000 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2010-08-12 02:14:28 +0000 |
commit | 87c1191e0e392f70965b8ce3b89e57d5165aadc7 (patch) | |
tree | d0e48015479611e52c2839a65f35e282b8812e42 /lldb/source/Target/Thread.cpp | |
parent | 1401e040eb7f2910f574ddea8dea4e1b1b42a95f (diff) | |
download | bcm5719-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/Target/Thread.cpp')
-rw-r--r-- | lldb/source/Target/Thread.cpp | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp index 1769cb97b55..efbcad7fa4d 100644 --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -32,6 +32,7 @@ #include "lldb/Target/ThreadPlanRunToAddress.h" #include "lldb/Target/ThreadPlanStepUntil.h" #include "lldb/Target/ThreadSpec.h" +#include "lldb/Target/Unwind.h" using namespace lldb; using namespace lldb_private; @@ -51,7 +52,9 @@ Thread::Thread (Process &process, lldb::tid_t tid) : m_frames (), m_current_frame_idx (0), m_resume_signal (LLDB_INVALID_SIGNAL_NUMBER), - m_resume_state (eStateRunning) + m_resume_state (eStateRunning), + m_unwinder_ap () + { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT); if (log) @@ -790,6 +793,56 @@ Thread::Calculate (ExecutionContext &exe_ctx) exe_ctx.frame = NULL; } +uint32_t +Thread::GetStackFrameCount() +{ + Unwind *unwinder = GetUnwinder (); + if (unwinder) + return unwinder->GetFrameCount(); + return 0; +} + +lldb::StackFrameSP +Thread::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; +} + lldb::StackFrameSP Thread::GetCurrentFrame () { |