Cleaned up the the code that figures out the inlined stack frames given a
symbol context that represents an inlined function. This function has been
renamed internally to:
bool
SymbolContext::GetParentOfInlinedScope (const Address &curr_frame_pc,
SymbolContext &next_frame_sc,
Address &next_frame_pc) const;
And externally to:
SBSymbolContext
SBSymbolContext::GetParentOfInlinedScope (const SBAddress &curr_frame_pc,
SBAddress &parent_frame_addr) const;
The correct blocks are now correctly calculated.
Switched the stack backtracing engine (in StackFrameList) and the address
context printing over to using the internal SymbolContext::GetParentOfInlinedScope(...)
so all inlined callstacks will match exactly.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@140910 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Target/StackFrameList.cpp b/source/Target/StackFrameList.cpp
index 3f74781..3d83423 100644
--- a/source/Target/StackFrameList.cpp
+++ b/source/Target/StackFrameList.cpp
@@ -112,64 +112,28 @@
m_frames.push_back (unwind_frame_sp);
}
- Block *unwind_block = unwind_frame_sp->GetSymbolContext (eSymbolContextBlock).block;
-
+ SymbolContext unwind_sc = unwind_frame_sp->GetSymbolContext (eSymbolContextBlock | eSymbolContextFunction);
+ Block *unwind_block = unwind_sc.block;
if (unwind_block)
{
- Block *inlined_block = unwind_block->GetContainingInlinedBlock();
- if (inlined_block)
+ Address curr_frame_address = unwind_frame_sp->GetFrameCodeAddress();
+ SymbolContext next_frame_sc;
+ Address next_frame_address;
+
+ while (unwind_sc.GetParentOfInlinedScope(curr_frame_address, next_frame_sc, next_frame_address))
{
- for (; inlined_block != NULL; inlined_block = inlined_block->GetInlinedParent ())
- {
- SymbolContext inline_sc;
- Block *parent_block = inlined_block->GetInlinedParent();
-
- const bool is_inlined_frame = parent_block != NULL;
-
- if (parent_block == NULL)
- parent_block = inlined_block->GetParent();
-
- parent_block->CalculateSymbolContext (&inline_sc);
-
- Address previous_frame_lookup_addr (m_frames.back()->GetFrameCodeAddress());
- if (unwind_frame_sp->GetFrameIndex() > 0 && m_frames.back().get() == unwind_frame_sp.get())
- previous_frame_lookup_addr.Slide (-1);
-
- AddressRange range;
- inlined_block->GetRangeContainingAddress (previous_frame_lookup_addr, range);
-
- const InlineFunctionInfo* inline_info = inlined_block->GetInlinedFunctionInfo();
- assert (inline_info);
- inline_sc.line_entry.range.GetBaseAddress() = m_frames.back()->GetFrameCodeAddress();
- inline_sc.line_entry.file = inline_info->GetCallSite().GetFile();
- inline_sc.line_entry.line = inline_info->GetCallSite().GetLine();
- inline_sc.line_entry.column = inline_info->GetCallSite().GetColumn();
-
StackFrameSP frame_sp(new StackFrame (m_frames.size(),
idx,
m_thread,
unwind_frame_sp->GetRegisterContextSP (),
cfa,
- range.GetBaseAddress(),
- &inline_sc)); // The symbol context for this inline frame
-
- if (is_inlined_frame)
- {
- // Use the block with the inlined function info
- // as the symbol context since we want this frame
- // to have only the variables for the inlined function
- frame_sp->SetSymbolContextScope (parent_block);
- }
- else
- {
- // This block is not inlined with means it has no
- // inlined parents either, so we want to use the top
- // most function block.
- frame_sp->SetSymbolContextScope (&unwind_frame_sp->GetSymbolContext (eSymbolContextFunction).function->GetBlock(false));
- }
-
+ next_frame_address,
+ &next_frame_sc));
+
m_frames.push_back (frame_sp);
- }
+ unwind_sc = next_frame_sc;
+ curr_frame_address = next_frame_address;
+
}
}
}