Added a new bool parameter to many of the DumpStopContext() methods that
might dump file paths that allows the dumping of full paths or just the
basenames. Switched the stack frame dumping code to use just the basenames for
the files instead of the full path.
Modified the StackID class to no rely on needing the start PC for the current
function/symbol since we can use the SymbolContextScope to uniquely identify
that, unless there is no symbol context scope. In that case we can rely upon
the current PC value. This saves the StackID from having to calculate the
start PC when the StackFrame::GetStackID() accessor is called.
Also improved the StackID less than operator to correctly handle inlined stack
frames in the same stack.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@112867 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/API/SBThread.cpp b/source/API/SBThread.cpp
index 49a2150..705f08c 100644
--- a/source/API/SBThread.cpp
+++ b/source/API/SBThread.cpp
@@ -288,7 +288,7 @@
frame_idx,
GetThreadID(),
(long long)pc);
- sc->DumpStopContext (&str, &m_opaque_sp->GetProcess(), *frame.GetPCAddress(), true, false);
+ sc->DumpStopContext (&str, &m_opaque_sp->GetProcess(), *frame.GetPCAddress(), false, true, false);
fprintf (out, "\n");
success = true;
}
diff --git a/source/Breakpoint/BreakpointLocation.cpp b/source/Breakpoint/BreakpointLocation.cpp
index f2e338c..7297f1e 100644
--- a/source/Breakpoint/BreakpointLocation.cpp
+++ b/source/Breakpoint/BreakpointLocation.cpp
@@ -285,7 +285,7 @@
if (level == lldb::eDescriptionLevelFull)
{
s->PutCString("where = ");
- sc.DumpStopContext (s, m_owner.GetTarget().GetProcessSP().get(), m_address, true, false);
+ sc.DumpStopContext (s, m_owner.GetTarget().GetProcessSP().get(), m_address, true, true, false);
}
else
{
@@ -313,7 +313,7 @@
{
s->EOL();
s->Indent("location = ");
- sc.line_entry.DumpStopContext (s);
+ sc.line_entry.DumpStopContext (s, true);
}
}
diff --git a/source/Commands/CommandObjectFrame.cpp b/source/Commands/CommandObjectFrame.cpp
index 30287e2..ed36bf7 100644
--- a/source/Commands/CommandObjectFrame.cpp
+++ b/source/Commands/CommandObjectFrame.cpp
@@ -71,7 +71,7 @@
ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext());
if (exe_ctx.frame)
{
- exe_ctx.frame->Dump (&result.GetOutputStream(), true);
+ exe_ctx.frame->Dump (&result.GetOutputStream(), true, false);
result.GetOutputStream().EOL();
result.SetStatus (eReturnStatusSuccessFinishResult);
}
diff --git a/source/Commands/CommandObjectImage.cpp b/source/Commands/CommandObjectImage.cpp
index d28cbf9..1b3c226 100644
--- a/source/Commands/CommandObjectImage.cpp
+++ b/source/Commands/CommandObjectImage.cpp
@@ -341,7 +341,7 @@
strm.PutCString(" in ");
}
}
- sc.DumpStopContext(&strm, interpreter.GetDebugger().GetExecutionContext().process, sc.line_entry.range.GetBaseAddress(), true, false);
+ sc.DumpStopContext(&strm, interpreter.GetDebugger().GetExecutionContext().process, sc.line_entry.range.GetBaseAddress(), true, true, false);
}
}
strm.IndentLess ();
diff --git a/source/Commands/CommandObjectThread.cpp b/source/Commands/CommandObjectThread.cpp
index 8d1737b..f4cc35d 100644
--- a/source/Commands/CommandObjectThread.cpp
+++ b/source/Commands/CommandObjectThread.cpp
@@ -224,7 +224,7 @@
if (show_frame_info)
{
strm.Indent();
- frame->Dump (&strm, true);
+ frame->Dump (&strm, true, false);
strm.EOL();
}
diff --git a/source/Core/Address.cpp b/source/Core/Address.cpp
index 070e11d..68b4b48 100644
--- a/source/Core/Address.cpp
+++ b/source/Core/Address.cpp
@@ -503,7 +503,7 @@
#endif
Address cstr_addr(*this);
cstr_addr.SetOffset(cstr_addr.GetOffset() + pointer_size);
- func_sc.DumpStopContext(s, exe_scope, so_addr, true, false);
+ func_sc.DumpStopContext(s, exe_scope, so_addr, true, true, false);
if (ReadAddress (exe_scope, cstr_addr, pointer_size, so_addr))
{
#if VERBOSE_OUTPUT
@@ -586,7 +586,7 @@
if (pointer_sc.function || pointer_sc.symbol)
{
s->PutCString(": ");
- pointer_sc.DumpStopContext(s, exe_scope, so_addr, false, false);
+ pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, false, false);
}
}
}
@@ -625,7 +625,7 @@
{
// We have a function or a symbol from the same
// sections as this address.
- sc.DumpStopContext(s, exe_scope, *this, show_module, false);
+ sc.DumpStopContext(s, exe_scope, *this, true, show_module, false);
}
else
{
diff --git a/source/Core/Disassembler.cpp b/source/Core/Disassembler.cpp
index 22f6c06..73a3519 100644
--- a/source/Core/Disassembler.cpp
+++ b/source/Core/Disassembler.cpp
@@ -238,7 +238,7 @@
if (offset != 0)
strm.EOL();
- sc.DumpStopContext(&strm, process, addr, true, false);
+ sc.DumpStopContext(&strm, process, addr, true, true, false);
if (sc.comp_unit && sc.line_entry.IsValid())
{
diff --git a/source/Symbol/Block.cpp b/source/Symbol/Block.cpp
index c0b9ac6..67b4490 100644
--- a/source/Symbol/Block.cpp
+++ b/source/Symbol/Block.cpp
@@ -145,7 +145,7 @@
}
void
-Block::DumpStopContext (Stream *s, const SymbolContext *sc)
+Block::DumpStopContext (Stream *s, const SymbolContext *sc, bool show_fullpaths)
{
Block* parent_block = GetParent();
@@ -170,7 +170,7 @@
if (call_site.IsValid())
{
s->PutCString(" at ");
- call_site.DumpStopContext (s);
+ call_site.DumpStopContext (s, show_fullpaths);
}
}
}
@@ -182,11 +182,11 @@
if (sc->line_entry.IsValid())
{
s->PutCString(" at ");
- sc->line_entry.DumpStopContext (s);
+ sc->line_entry.DumpStopContext (s, show_fullpaths);
}
}
if (parent_block)
- parent_block->Block::DumpStopContext (s, NULL);
+ parent_block->Block::DumpStopContext (s, NULL, show_fullpaths);
}
@@ -207,6 +207,24 @@
}
bool
+Block::Contains (const Block *block) const
+{
+ // Block objects can't contain themselves...
+ if (this == block)
+ return false;
+
+ const Block *block_parent;
+ for (block_parent = block->GetParent();
+ block_parent != NULL;
+ block_parent = block_parent->GetParent())
+ {
+ if (block_parent == block)
+ return true;
+ }
+ return false;
+}
+
+bool
Block::Contains (const VMRange& range) const
{
return VMRange::ContainsRange(m_ranges, range);
diff --git a/source/Symbol/Declaration.cpp b/source/Symbol/Declaration.cpp
index d53d900..2f312d4 100644
--- a/source/Symbol/Declaration.cpp
+++ b/source/Symbol/Declaration.cpp
@@ -81,11 +81,11 @@
}
void
-Declaration::DumpStopContext (Stream *s) const
+Declaration::DumpStopContext (Stream *s, bool show_fullpaths) const
{
if (m_file)
{
- if (s->GetVerbose())
+ if (show_fullpaths || s->GetVerbose())
*s << m_file;
else
m_file.GetFilename().Dump(s);
diff --git a/source/Symbol/LineEntry.cpp b/source/Symbol/LineEntry.cpp
index 83c50f2..5d9b27e 100644
--- a/source/Symbol/LineEntry.cpp
+++ b/source/Symbol/LineEntry.cpp
@@ -74,12 +74,16 @@
}
bool
-LineEntry::DumpStopContext(Stream *s) const
+LineEntry::DumpStopContext(Stream *s, bool show_fullpaths) const
{
bool result = false;
if (file)
{
- file.Dump (s);
+ if (show_fullpaths)
+ file.Dump (s);
+ else
+ file.GetFilename().Dump (s);
+
if (line)
s->PutChar(':');
result = true;
diff --git a/source/Symbol/SymbolContext.cpp b/source/Symbol/SymbolContext.cpp
index ce65b91..f54d856 100644
--- a/source/Symbol/SymbolContext.cpp
+++ b/source/Symbol/SymbolContext.cpp
@@ -114,13 +114,18 @@
Stream *s,
ExecutionContextScope *exe_scope,
const Address &addr,
+ bool show_fullpaths,
bool show_module,
bool show_inlined_frames
) const
{
if (show_module && module_sp)
{
- *s << module_sp->GetFileSpec().GetFilename() << '`';
+ if (show_fullpaths)
+ *s << module_sp->GetFileSpec();
+ else
+ *s << module_sp->GetFileSpec().GetFilename();
+ s->PutChar('`');
}
if (function != NULL)
@@ -128,7 +133,6 @@
if (function->GetMangled().GetName())
function->GetMangled().GetName().Dump(s);
-
if (show_inlined_frames && block)
{
const InlineFunctionInfo *inline_info = block->InlinedFunctionInfo();
@@ -147,7 +151,7 @@
if (line_entry.IsValid())
{
s->PutCString(" at ");
- line_entry.DumpStopContext(s);
+ line_entry.DumpStopContext(s, show_fullpaths);
}
return;
}
@@ -159,7 +163,7 @@
if (block != NULL)
{
s->IndentMore();
- block->DumpStopContext(s, this);
+ block->DumpStopContext(s, this, show_fullpaths);
s->IndentLess();
}
else
@@ -167,7 +171,7 @@
if (line_entry.IsValid())
{
s->PutCString(" at ");
- if (line_entry.DumpStopContext(s))
+ if (line_entry.DumpStopContext(s, show_fullpaths))
return;
}
}
diff --git a/source/Target/StackFrame.cpp b/source/Target/StackFrame.cpp
index f812285..b310f25 100644
--- a/source/Target/StackFrame.cpp
+++ b/source/Target/StackFrame.cpp
@@ -32,8 +32,7 @@
// so we know if we have tried to look up information in our internal symbol
// context (m_sc) already.
#define RESOLVED_FRAME_CODE_ADDR (uint32_t(eSymbolContextEverything + 1))
-#define RESOLVED_FRAME_ID_START_ADDR (RESOLVED_FRAME_CODE_ADDR << 1)
-#define RESOLVED_FRAME_ID_SYMBOL_SCOPE (RESOLVED_FRAME_ID_START_ADDR << 1)
+#define RESOLVED_FRAME_ID_SYMBOL_SCOPE (RESOLVED_FRAME_CODE_ADDR << 1)
#define GOT_FRAME_BASE (RESOLVED_FRAME_ID_SYMBOL_SCOPE << 1)
#define RESOLVED_VARIABLES (GOT_FRAME_BASE << 1)
@@ -50,7 +49,7 @@
m_unwind_frame_index (unwind_frame_index),
m_thread (thread),
m_reg_context_sp (),
- m_id (LLDB_INVALID_ADDRESS, cfa, NULL),
+ m_id (pc, cfa, NULL),
m_frame_code_addr (NULL, pc),
m_sc (),
m_flags (),
@@ -80,7 +79,7 @@
m_unwind_frame_index (unwind_frame_index),
m_thread (thread),
m_reg_context_sp (reg_context_sp),
- m_id (LLDB_INVALID_ADDRESS, cfa, NULL),
+ m_id (pc, cfa, NULL),
m_frame_code_addr (NULL, pc),
m_sc (),
m_flags (),
@@ -116,7 +115,7 @@
m_unwind_frame_index (unwind_frame_index),
m_thread (thread),
m_reg_context_sp (reg_context_sp),
- m_id (LLDB_INVALID_ADDRESS, cfa, NULL),
+ m_id (pc_addr.GetLoadAddress (&thread.GetProcess()), cfa, NULL),
m_frame_code_addr (pc_addr),
m_sc (),
m_flags (),
@@ -159,42 +158,12 @@
StackID&
StackFrame::GetStackID()
{
- // Make sure we have resolved our stack ID's start PC before we give
- // it out to any external clients. This allows us to not have to lookup
- // this information if it is never asked for.
- if (m_flags.IsClear(RESOLVED_FRAME_ID_START_ADDR))
- {
- m_flags.Set (RESOLVED_FRAME_ID_START_ADDR);
+ // Make sure we have resolved the StackID object's symbol context scope if
+ // we already haven't looked it up.
- if (m_id.GetStartAddress() == LLDB_INVALID_ADDRESS)
- {
- // Resolve our PC to section offset if we haven't alreday done so
- // and if we don't have a module. The resolved address section will
- // contain the module to which it belongs.
- if (!m_sc.module_sp && m_flags.IsClear(RESOLVED_FRAME_CODE_ADDR))
- GetFrameCodeAddress();
-
- if (GetSymbolContext (eSymbolContextFunction).function)
- {
- m_id.SetStartAddress (m_sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (&m_thread.GetProcess()));
- }
- else if (GetSymbolContext (eSymbolContextSymbol).symbol)
- {
- AddressRange *symbol_range_ptr = m_sc.symbol->GetAddressRangePtr();
- if (symbol_range_ptr)
- m_id.SetStartAddress(symbol_range_ptr->GetBaseAddress().GetLoadAddress (&m_thread.GetProcess()));
- }
-
- // We didn't find a function or symbol, just use the frame code address
- // which will be the same as the PC in the frame.
- if (m_id.GetStartAddress() == LLDB_INVALID_ADDRESS)
- m_id.SetStartAddress (m_frame_code_addr.GetLoadAddress (&m_thread.GetProcess()));
- }
- }
-
if (m_flags.IsClear (RESOLVED_FRAME_ID_SYMBOL_SCOPE))
{
- if (m_id.GetSymbolContextScope ())
+ if (m_id.GetSymbolContextScope () == NULL)
{
m_flags.Set (RESOLVED_FRAME_ID_SYMBOL_SCOPE);
}
@@ -627,20 +596,18 @@
}
void
-StackFrame::Dump (Stream *strm, bool show_frame_index)
+StackFrame::Dump (Stream *strm, bool show_frame_index, bool show_fullpaths)
{
if (strm == NULL)
return;
if (show_frame_index)
strm->Printf("frame #%u: ", m_frame_index);
- strm->Printf("0x%0*llx", m_thread.GetProcess().GetAddressByteSize() * 2, GetFrameCodeAddress().GetLoadAddress(&m_thread.GetProcess()));
+ strm->Printf("0x%0*llx ", m_thread.GetProcess().GetAddressByteSize() * 2, GetFrameCodeAddress().GetLoadAddress(&m_thread.GetProcess()));
GetSymbolContext(eSymbolContextEverything);
- strm->PutCString(", where = ");
- // TODO: need to get the
const bool show_module = true;
const bool show_inline = true;
- m_sc.DumpStopContext(strm, &m_thread.GetProcess(), GetFrameCodeAddress(), show_module, show_inline);
+ m_sc.DumpStopContext(strm, &m_thread.GetProcess(), GetFrameCodeAddress(), show_fullpaths, show_module, show_inline);
}
void
diff --git a/source/Target/StackFrameList.cpp b/source/Target/StackFrameList.cpp
index 75351ff..0b8b8bf 100644
--- a/source/Target/StackFrameList.cpp
+++ b/source/Target/StackFrameList.cpp
@@ -256,7 +256,7 @@
if (frame)
{
frame->GetStackID().Dump (s);
- frame->Dump(s, true);
+ frame->Dump(s, true, false);
}
else
s->Printf("frame #%u", std::distance (begin, pos));
diff --git a/source/Target/StackID.cpp b/source/Target/StackID.cpp
index 215e85e..a1e45b1 100644
--- a/source/Target/StackID.cpp
+++ b/source/Target/StackID.cpp
@@ -24,7 +24,7 @@
void
StackID::Dump (Stream *s)
{
- s->Printf("StackID (start_pc = 0x%16.16llx, cfa = 0x%16.16llx, symbol_scope = %p", (uint64_t)m_start_pc, (uint64_t)m_cfa, m_symbol_scope);
+ s->Printf("StackID (pc = 0x%16.16llx, cfa = 0x%16.16llx, symbol_scope = %p", (uint64_t)m_pc, (uint64_t)m_cfa, m_symbol_scope);
if (m_symbol_scope)
{
SymbolContext sc;
@@ -41,21 +41,64 @@
bool
lldb_private::operator== (const StackID& lhs, const StackID& rhs)
{
- return lhs.GetCallFrameAddress() == rhs.GetCallFrameAddress() &&
- lhs.GetSymbolContextScope() == rhs.GetSymbolContextScope() &&
- lhs.GetStartAddress() == rhs.GetStartAddress();
+ if (lhs.GetCallFrameAddress() != rhs.GetCallFrameAddress())
+ return false;
+
+ SymbolContextScope *lhs_scope = lhs.GetSymbolContextScope();
+ SymbolContextScope *rhs_scope = rhs.GetSymbolContextScope();
+
+ // Only compare the PC values if both symbol context scopes are NULL
+ if (lhs_scope == NULL && rhs_scope == NULL)
+ return lhs.GetPC() == rhs.GetPC();
+
+ return lhs_scope == rhs_scope;
}
bool
lldb_private::operator!= (const StackID& lhs, const StackID& rhs)
{
- return lhs.GetCallFrameAddress() != rhs.GetCallFrameAddress() ||
- lhs.GetSymbolContextScope() != rhs.GetSymbolContextScope() ||
- lhs.GetStartAddress() != rhs.GetStartAddress();
+ if (lhs.GetCallFrameAddress() != rhs.GetCallFrameAddress())
+ return true;
+
+ SymbolContextScope *lhs_scope = lhs.GetSymbolContextScope();
+ SymbolContextScope *rhs_scope = rhs.GetSymbolContextScope();
+
+ if (lhs_scope == NULL && rhs_scope == NULL)
+ return lhs.GetPC() != rhs.GetPC();
+
+ return lhs_scope != rhs_scope;
}
bool
lldb_private::operator< (const StackID& lhs, const StackID& rhs)
{
- return lhs.GetCallFrameAddress() < rhs.GetCallFrameAddress();
+ const lldb::addr_t lhs_cfa = lhs.GetCallFrameAddress();
+ const lldb::addr_t rhs_cfa = rhs.GetCallFrameAddress();
+
+ if (lhs_cfa != rhs_cfa)
+ return lhs_cfa < rhs_cfa;
+
+ SymbolContextScope *lhs_scope = lhs.GetSymbolContextScope();
+ SymbolContextScope *rhs_scope = rhs.GetSymbolContextScope();
+
+ if (lhs_scope != NULL && rhs_scope != NULL)
+ {
+ // Same exact scope, lhs is not less than (younger than rhs)
+ if (lhs_scope == rhs_scope)
+ return false;
+
+ SymbolContext lhs_sc;
+ SymbolContext rhs_sc;
+ lhs_scope->CalculateSymbolContext (&lhs_sc);
+ rhs_scope->CalculateSymbolContext (&rhs_sc);
+
+ // Items with the same function can only be compared
+ if (lhs_sc.function == rhs_sc.function &&
+ lhs_sc.function != NULL && lhs_sc.block != NULL &&
+ rhs_sc.function != NULL && rhs_sc.block != NULL)
+ {
+ return rhs_sc.block->Contains (lhs_sc.block);
+ }
+ }
+ return false;
}
diff --git a/source/Target/Thread.cpp b/source/Target/Thread.cpp
index 5a1e1dd..1c8265a 100644
--- a/source/Target/Thread.cpp
+++ b/source/Target/Thread.cpp
@@ -820,7 +820,7 @@
lldb::StackFrameSP
Thread::GetStackFrameAtIndex (uint32_t idx)
{
- return StackFrameSP (GetStackFrameList().GetFrameAtIndex(idx));
+ return GetStackFrameList().GetFrameAtIndex(idx);
}
lldb::StackFrameSP
@@ -859,7 +859,7 @@
if (frame_sp)
{
strm.PutCString(", ");
- frame_sp->Dump (&strm, false);
+ frame_sp->Dump (&strm, false, false);
}
}