Skip to content

Commit 26f70f3

Browse files
[lldb][Format] Display only the inlined Swift frame name in backtraces if available
1 parent 026fcad commit 26f70f3

File tree

2 files changed

+36
-9
lines changed

2 files changed

+36
-9
lines changed

lldb/source/Plugins/Language/Swift/SwiftLanguage.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,7 +1724,7 @@ bool SwiftLanguage::GetFunctionDisplayName(
17241724
if (sc.function->GetLanguage() != eLanguageTypeSwift)
17251725
return false;
17261726
std::string display_name = SwiftLanguageRuntime::DemangleSymbolAsString(
1727-
sc.function->GetMangled().GetMangledName().GetStringRef(),
1727+
sc.GetPossiblyInlinedFunctionName().GetMangledName(),
17281728
SwiftLanguageRuntime::eSimplified, &sc, exe_ctx);
17291729
if (display_name.empty())
17301730
return false;
@@ -1749,12 +1749,6 @@ bool SwiftLanguage::GetFunctionDisplayName(
17491749
sc.function->GetBlock(true).GetBlockVariableList(true);
17501750
}
17511751

1752-
if (inline_info) {
1753-
s << display_name;
1754-
s.PutCString(" [inlined] ");
1755-
display_name = inline_info->GetName().GetString();
1756-
}
1757-
17581752
VariableList args;
17591753
if (variable_list_sp)
17601754
variable_list_sp->AppendVariablesWithScope(eValueTypeVariableArgument,
@@ -1864,8 +1858,7 @@ SwiftLanguage::GetDemangledFunctionNameWithoutArguments(Mangled mangled) const {
18641858
ConstString mangled_name = mangled.GetMangledName();
18651859
ConstString demangled_name = mangled.GetDemangledName();
18661860
if (demangled_name && mangled_name) {
1867-
if (SwiftLanguageRuntime::IsSwiftMangledName(
1868-
demangled_name.GetStringRef())) {
1861+
if (SwiftLanguageRuntime::IsSwiftMangledName(mangled_name.GetStringRef())) {
18691862
lldb_private::ConstString basename;
18701863
bool is_method = false;
18711864
if (SwiftLanguageRuntime::MethodName::ExtractFunctionBasenameFromMangled(
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Test Swift function name printing in backtraces.
2+
3+
# XFAIL: !system-darwin
4+
# RUN: split-file %s %t
5+
# RUN: %target-swiftc -g -O %t/main.swift -o %t.out
6+
# RUN: %lldb -x -b -s %t/commands.input %t.out -o exit 2>&1 \
7+
# RUN: | FileCheck %s
8+
9+
#--- main.swift
10+
@inline(never)
11+
func baz(_ a: Int) -> Int {
12+
return a * 2
13+
}
14+
15+
@inline(__always)
16+
func foo(_ a: Int, _ b: Int) -> Int {
17+
return a * b * baz(a)
18+
}
19+
20+
func bar() {
21+
let baz = foo(4, 5)
22+
}
23+
24+
bar()
25+
26+
#--- commands.input
27+
b baz
28+
29+
run
30+
bt
31+
32+
# CHECK: `baz(a=Swift.Int @ scalar) at main.swift:3:14 [opt]
33+
# CHECK: `foo(a=Swift.Int @ scalar, b=Swift.Int @ scalar) at main.swift:8:17 [opt] [inlined]
34+
# CHECK: `bar() at main.swift:12:15 [opt] [inlined]

0 commit comments

Comments
 (0)