Skip to content

Commit 31c294e

Browse files
Merge pull request #8726 from apple/dl/lldb-Display-breakpoint-locations-using-display-name
[lldb] Display breakpoint locations using display name
2 parents 2af7c27 + 00ef34a commit 31c294e

File tree

12 files changed

+32
-15
lines changed

12 files changed

+32
-15
lines changed

lldb/include/lldb/Symbol/Function.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ class Function : public UserID, public SymbolContextScope {
537537

538538
ConstString GetNameNoArguments(const SymbolContext *sc = nullptr) const;
539539

540-
ConstString GetDisplayName() const;
540+
ConstString GetDisplayName(const SymbolContext *sc = nullptr) const;
541541

542542
const Mangled &GetMangled() const { return m_mangled; }
543543

lldb/include/lldb/Symbol/Symbol.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class Symbol : public SymbolContextScope {
130130

131131
ConstString GetNameNoArguments() const;
132132

133-
ConstString GetDisplayName() const;
133+
ConstString GetDisplayName(const SymbolContext *sc = nullptr) const;
134134

135135
uint32_t GetID() const { return m_uid; }
136136

lldb/include/lldb/Symbol/SymbolContext.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ class SymbolContext {
151151
const Address &so_addr, bool show_fullpaths,
152152
bool show_module, bool show_inlined_frames,
153153
bool show_function_arguments,
154-
bool show_function_name) const;
154+
bool show_function_name,
155+
bool show_function_display_name = false) const;
155156

156157
/// Get the address range contained within a symbol context.
157158
///

lldb/include/lldb/Target/Language.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,10 @@ class Language : public PluginInterface {
270270
return mangled.GetMangledName();
271271
}
272272

273+
virtual ConstString GetDisplayDemangledName(Mangled mangled) const {
274+
return mangled.GetDemangledName();
275+
}
276+
273277
virtual void GetExceptionResolverDescription(bool catch_on, bool throw_on,
274278
Stream &s);
275279

lldb/source/Breakpoint/BreakpointLocation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ void BreakpointLocation::GetDescription(Stream *s,
515515
else
516516
s->PutCString("where = ");
517517
sc.DumpStopContext(s, m_owner.GetTarget().GetProcessSP().get(), m_address,
518-
false, true, false, true, true);
518+
false, true, false, true, true, true);
519519
} else {
520520
if (sc.module_sp) {
521521
s->EOL();

lldb/source/Core/Address.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
643643
pointer_sc.symbol != nullptr) {
644644
s->PutCString(": ");
645645
pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, false,
646-
false, true, true);
646+
false, true, true, false);
647647
}
648648
}
649649
}
@@ -682,7 +682,8 @@ bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
682682
// address.
683683
sc.DumpStopContext(s, exe_scope, *this, show_fullpaths,
684684
show_module, show_inlined_frames,
685-
show_function_arguments, show_function_name);
685+
show_function_arguments, show_function_name,
686+
false);
686687
} else {
687688
// We found a symbol but it was in a different section so it
688689
// isn't the symbol we should be showing, just show the section

lldb/source/Core/Mangled.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ ConstString Mangled::GetDisplayDemangledName(
337337
m_mangled.GetStringRef(), SwiftLanguageRuntime::eSimplified, sc));
338338
#endif // LLDB_ENABLE_SWIFT
339339
// END SWIFT
340+
if (Language *lang = Language::FindPlugin(GuessLanguage()))
341+
return lang->GetDisplayDemangledName(*this);
340342
return GetDemangledName();
341343
}
342344

lldb/source/Symbol/Function.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,10 +498,10 @@ bool Function::IsTopLevelFunction() {
498498
return result;
499499
}
500500

501-
ConstString Function::GetDisplayName() const {
501+
ConstString Function::GetDisplayName(const SymbolContext *sc) const {
502502
if (!m_mangled)
503503
return GetName();
504-
return m_mangled.GetDisplayDemangledName();
504+
return m_mangled.GetDisplayDemangledName(sc);
505505
}
506506

507507
CompilerDeclContext Function::GetDeclContext() {

lldb/source/Symbol/Symbol.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ bool Symbol::ValueIsAddress() const {
168168
return (bool)m_addr_range.GetBaseAddress().GetSection();
169169
}
170170

171-
ConstString Symbol::GetDisplayName() const {
172-
return GetMangled().GetDisplayDemangledName();
171+
ConstString Symbol::GetDisplayName(const SymbolContext *sc) const {
172+
return GetMangled().GetDisplayDemangledName(sc);
173173
}
174174

175175
ConstString Symbol::GetReExportedSymbolName() const {

lldb/source/Symbol/SymbolContext.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ bool SymbolContext::DumpStopContext(Stream *s, ExecutionContextScope *exe_scope,
7171
const Address &addr, bool show_fullpaths,
7272
bool show_module, bool show_inlined_frames,
7373
bool show_function_arguments,
74-
bool show_function_name) const {
74+
bool show_function_name,
75+
bool show_function_display_name) const {
7576
bool dumped_something = false;
7677
if (show_module && module_sp) {
7778
if (show_fullpaths)
@@ -92,6 +93,8 @@ bool SymbolContext::DumpStopContext(Stream *s, ExecutionContextScope *exe_scope,
9293
ConstString name;
9394
if (!show_function_arguments)
9495
name = function->GetNameNoArguments(this);
96+
if (!name && show_function_display_name)
97+
name = function->GetDisplayName(this);
9598
if (!name)
9699
name = function->GetName(this);
97100
if (name)
@@ -145,7 +148,8 @@ bool SymbolContext::DumpStopContext(Stream *s, ExecutionContextScope *exe_scope,
145148
const bool show_function_name = true;
146149
return inline_parent_sc.DumpStopContext(
147150
s, exe_scope, inline_parent_addr, show_fullpaths, show_module,
148-
show_inlined_frames, show_function_arguments, show_function_name);
151+
show_inlined_frames, show_function_arguments, show_function_name,
152+
show_function_display_name);
149153
}
150154
} else {
151155
if (line_entry.IsValid()) {
@@ -163,7 +167,12 @@ bool SymbolContext::DumpStopContext(Stream *s, ExecutionContextScope *exe_scope,
163167
dumped_something = true;
164168
if (symbol->GetType() == eSymbolTypeTrampoline)
165169
s->PutCString("symbol stub for: ");
166-
symbol->GetName().Dump(s);
170+
ConstString name;
171+
if (show_function_display_name)
172+
name = symbol->GetDisplayName(this);
173+
if (!name)
174+
name = symbol->GetName();
175+
name.Dump(s);
167176
}
168177

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

lldb/test/API/lang/swift/expression/generic_function_name/TestSwiftGenericFunctionName.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def test(self):
2525
stream = lldb.SBStream()
2626
bkpt.GetLocationAtIndex(0).GetDescription(stream, 1)
2727
desc = stream.GetData()
28-
self.assertIn("C.f<T>(T, U) -> ()", desc)
28+
self.assertIn("C.f<T>(_:_:)", desc)
2929

3030
# Demangling only:
3131
fs = target.FindFunctions("f")

lldb/test/Shell/SwiftREPL/BreakpointSimple.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ func foo() -> Int {
77
}
88

99
:b foo
10-
// CHECK: Breakpoint 1: {{.*}}foo() -> Swift.Int {{.*}} repl.swift:6:3, address = 0x
10+
// CHECK: Breakpoint 1: {{.*}}foo() {{.*}} repl.swift:6:3, address = 0x
1111

1212
// CHECK: Execution stopped at breakpoint
1313
foo()

0 commit comments

Comments
 (0)