From e4284b719ccbe8c2028dfd3eb82c64e50355de54 Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Thu, 23 Sep 2010 17:40:12 +0000 Subject: [PATCH] Add GetSP to the StackFrame. llvm-svn: 114674 --- lldb/include/lldb/Target/StackFrame.h | 3 +++ lldb/include/lldb/Target/StackFrameList.h | 3 +++ lldb/include/lldb/Target/Thread.h | 3 +++ lldb/source/Target/StackFrame.cpp | 6 ++++++ lldb/source/Target/StackFrameList.cpp | 20 ++++++++++++++++++++ lldb/source/Target/Thread.cpp | 5 +++++ 6 files changed, 40 insertions(+) diff --git a/lldb/include/lldb/Target/StackFrame.h b/lldb/include/lldb/Target/StackFrame.h index 66a2c1d5de2c..797a117ce7a9 100644 --- a/lldb/include/lldb/Target/StackFrame.h +++ b/lldb/include/lldb/Target/StackFrame.h @@ -143,6 +143,9 @@ public: virtual void Calculate (ExecutionContext &exe_ctx); + + lldb::StackFrameSP + GetSP (); protected: friend class StackFrameList; diff --git a/lldb/include/lldb/Target/StackFrameList.h b/lldb/include/lldb/Target/StackFrameList.h index 888a959665e6..f0ab6047078f 100644 --- a/lldb/include/lldb/Target/StackFrameList.h +++ b/lldb/include/lldb/Target/StackFrameList.h @@ -58,6 +58,9 @@ public: void Dump (Stream *s); + + lldb::StackFrameSP + GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr); protected: diff --git a/lldb/include/lldb/Target/Thread.h b/lldb/include/lldb/Target/Thread.h index 627a899cdf00..3aad792236aa 100644 --- a/lldb/include/lldb/Target/Thread.h +++ b/lldb/include/lldb/Target/Thread.h @@ -611,6 +611,9 @@ public: virtual void Calculate (ExecutionContext &exe_ctx); + + lldb::StackFrameSP + GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr); protected: diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp index bd9df621e6ed..c7f2c0401620 100644 --- a/lldb/source/Target/StackFrame.cpp +++ b/lldb/source/Target/StackFrame.cpp @@ -679,4 +679,10 @@ StackFrame::HasCachedData () const if (!m_disassembly.GetString().empty()) return true; return false; +} + +lldb::StackFrameSP +StackFrame::GetSP () +{ + return m_thread.GetStackFrameSPForStackFramePtr (this); } \ No newline at end of file diff --git a/lldb/source/Target/StackFrameList.cpp b/lldb/source/Target/StackFrameList.cpp index 2e76d339a5e5..c6ac2de0f0df 100644 --- a/lldb/source/Target/StackFrameList.cpp +++ b/lldb/source/Target/StackFrameList.cpp @@ -513,3 +513,23 @@ StackFrameList::Merge (std::auto_ptr& curr_ap, lldb::StackFrameL } + +lldb::StackFrameSP +StackFrameList::GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr) +{ + const_iterator pos; + const_iterator begin = m_frames.begin(); + const_iterator end = m_frames.end(); + lldb::StackFrameSP ret_sp; + + for (pos = begin; pos != end; ++pos) + { + if (pos->get() == stack_frame_ptr) + { + ret_sp = (*pos); + break; + } + } + return ret_sp; +} + diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp index cd4f8247c3d0..11273b180e10 100644 --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -1129,3 +1129,8 @@ Thread::ThreadSettingsController::instance_settings_table[] = { NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL } }; +lldb::StackFrameSP +Thread::GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr) +{ + return GetStackFrameList().GetStackFrameSPForStackFramePtr (stack_frame_ptr); +}