Restructure the relationship between UnwindLLDB and the
RegisterContextLLDBs it contains.
Previously RegisterContextLLDB objects had a pointer to their "next"
frame down the stack. e.g. stack starts at frame 0; frame 3 has a
pointer to frame 2. This is used to retreive callee saved register
values. When debugging an inferior that has blown out its own stack,
however, this could result in lldb blowing out its own stack while
recursing down to retrieve register values.
RegisterContextLLDB no longer has a pointer to its next frame; it
has a reference to the UnwindLLDB which contains it. When it needs
to retrieve a reg value, it asks the UnwindLLDB for that reg value
and UnwindLLDB iterates through the frames until it finds a location.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@143423 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Plugins/Process/Utility/UnwindLLDB.cpp b/source/Plugins/Process/Utility/UnwindLLDB.cpp
index d61b6d0..954ad8b 100644
--- a/source/Plugins/Process/Utility/UnwindLLDB.cpp
+++ b/source/Plugins/Process/Utility/UnwindLLDB.cpp
@@ -69,10 +69,10 @@
{
// First, set up the 0th (initial) frame
CursorSP first_cursor_sp(new Cursor ());
- RegisterContextLLDB::SharedPtr reg_ctx_sp (new RegisterContextLLDB (m_thread,
- RegisterContextLLDB::SharedPtr(),
+ RegisterContextLLDBSharedPtr reg_ctx_sp (new RegisterContextLLDB (m_thread,
+ RegisterContextLLDBSharedPtr(),
first_cursor_sp->sctx,
- 0));
+ 0, *this));
if (reg_ctx_sp.get() == NULL)
return false;
@@ -104,10 +104,10 @@
return false;
uint32_t cur_idx = m_frames.size ();
- RegisterContextLLDB::SharedPtr reg_ctx_sp(new RegisterContextLLDB (m_thread,
+ RegisterContextLLDBSharedPtr reg_ctx_sp(new RegisterContextLLDB (m_thread,
m_frames[cur_idx - 1]->reg_ctx,
cursor_sp->sctx,
- cur_idx));
+ cur_idx, *this));
if (reg_ctx_sp.get() == NULL)
return false;
@@ -225,3 +225,28 @@
reg_ctx_sp = m_frames[idx]->reg_ctx;
return reg_ctx_sp;
}
+
+UnwindLLDB::RegisterContextLLDBSharedPtr
+UnwindLLDB::GetRegisterContextForFrameNum (uint32_t frame_num)
+{
+ RegisterContextLLDBSharedPtr reg_ctx_sp;
+ if (frame_num >= m_frames.size())
+ return reg_ctx_sp;
+ reg_ctx_sp = m_frames[frame_num]->reg_ctx;
+ return reg_ctx_sp;
+}
+
+bool
+UnwindLLDB::SearchForSavedLocationForRegister (uint32_t lldb_regnum, lldb_private::UnwindLLDB::RegisterLocation ®loc, uint32_t starting_frame_num)
+{
+ int64_t frame_num = starting_frame_num;
+ if (frame_num >= m_frames.size())
+ return false;
+ while (frame_num >= 0)
+ {
+ if (m_frames[frame_num]->reg_ctx->SavedLocationForRegister (lldb_regnum, regloc, false))
+ return true;
+ frame_num--;
+ }
+ return false;
+}