Skip to content

Commit

Permalink
[lldb] Display breakpoint locations using display name (llvm#90297)
Browse files Browse the repository at this point in the history
Adds a `show_function_display_name` parameter to
`SymbolContext::DumpStopContext`. This
parameter defaults to false, but `BreakpointLocation::GetDescription`
sets it to true.

This is NFC in mainline lldb, and will be used to modify how Swift
breakpoint locations are printed.
  • Loading branch information
kastiglione committed May 8, 2024
1 parent e37bd6c commit 7ec8a33
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions lldb/include/lldb/Symbol/SymbolContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ class SymbolContext {
Stream *s, ExecutionContextScope *exe_scope, const Address &so_addr,
bool show_fullpaths, bool show_module, bool show_inlined_frames,
bool show_function_arguments, bool show_function_name,
bool show_function_display_name = false,
std::optional<Stream::HighlightSettings> settings = std::nullopt) const;

/// Get the address range contained within a symbol context.
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Breakpoint/BreakpointLocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ void BreakpointLocation::GetDescription(Stream *s,
else
s->PutCString("where = ");
sc.DumpStopContext(s, m_owner.GetTarget().GetProcessSP().get(), m_address,
false, true, false, true, true);
false, true, false, true, true, true);
} else {
if (sc.module_sp) {
s->EOL();
Expand Down
5 changes: 3 additions & 2 deletions lldb/source/Core/Address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,8 @@ bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
pointer_sc.symbol != nullptr) {
s->PutCString(": ");
pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, false,
false, true, true, settings);
false, true, true, false,
settings);
}
}
}
Expand Down Expand Up @@ -685,7 +686,7 @@ bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
sc.DumpStopContext(s, exe_scope, *this, show_fullpaths,
show_module, show_inlined_frames,
show_function_arguments, show_function_name,
settings);
false, settings);
} else {
// We found a symbol but it was in a different section so it
// isn't the symbol we should be showing, just show the section
Expand Down
13 changes: 11 additions & 2 deletions lldb/source/Symbol/SymbolContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ bool SymbolContext::DumpStopContext(
Stream *s, ExecutionContextScope *exe_scope, const Address &addr,
bool show_fullpaths, bool show_module, bool show_inlined_frames,
bool show_function_arguments, bool show_function_name,
bool show_function_display_name,
std::optional<Stream::HighlightSettings> settings) const {
bool dumped_something = false;
if (show_module && module_sp) {
Expand All @@ -93,6 +94,8 @@ bool SymbolContext::DumpStopContext(
ConstString name;
if (!show_function_arguments)
name = function->GetNameNoArguments();
if (!name && show_function_display_name)
name = function->GetDisplayName();
if (!name)
name = function->GetName();
if (name)
Expand Down Expand Up @@ -146,7 +149,8 @@ bool SymbolContext::DumpStopContext(
const bool show_function_name = true;
return inline_parent_sc.DumpStopContext(
s, exe_scope, inline_parent_addr, show_fullpaths, show_module,
show_inlined_frames, show_function_arguments, show_function_name);
show_inlined_frames, show_function_arguments, show_function_name,
show_function_display_name);
}
} else {
if (line_entry.IsValid()) {
Expand All @@ -164,7 +168,12 @@ bool SymbolContext::DumpStopContext(
dumped_something = true;
if (symbol->GetType() == eSymbolTypeTrampoline)
s->PutCString("symbol stub for: ");
s->PutCStringColorHighlighted(symbol->GetName().GetStringRef(), settings);
ConstString name;
if (show_function_display_name)
name = symbol->GetDisplayName();
if (!name)
name = symbol->GetName();
s->PutCStringColorHighlighted(name.GetStringRef(), settings);
}

if (addr.IsValid() && symbol->ValueIsAddress()) {
Expand Down

0 comments on commit 7ec8a33

Please sign in to comment.