Skip to content

Commit 768adbb

Browse files
[lldb][Format] Display only the inlined Swift frame name in backtraces if available
1 parent e64ef52 commit 768adbb

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,7 +1761,7 @@ std::string SwiftLanguage::GetFunctionName(const SymbolContext &sc,
17611761
if (sc.function->GetLanguage() != eLanguageTypeSwift)
17621762
return {};
17631763
std::string name = SwiftLanguageRuntime::DemangleSymbolAsString(
1764-
sc.function->GetMangled().GetMangledName().GetStringRef(),
1764+
sc.GetPossiblyInlinedFunctionName().GetMangledName(),
17651765
SwiftLanguageRuntime::eSimplified, &sc, exe_ctx);
17661766
if (name.empty())
17671767
return {};
@@ -1879,8 +1879,7 @@ SwiftLanguage::GetDemangledFunctionNameWithoutArguments(Mangled mangled) const {
18791879
ConstString mangled_name = mangled.GetMangledName();
18801880
ConstString demangled_name = mangled.GetDemangledName();
18811881
if (demangled_name && mangled_name) {
1882-
if (SwiftLanguageRuntime::IsSwiftMangledName(
1883-
demangled_name.GetStringRef())) {
1882+
if (SwiftLanguageRuntime::IsSwiftMangledName(mangled_name.GetStringRef())) {
18841883
lldb_private::ConstString basename;
18851884
bool is_method = false;
18861885
if (SwiftLanguageRuntime::MethodName::ExtractFunctionBasenameFromMangled(
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Test Swift function name printing in backtraces.
2+
3+
# RUN: split-file %s %t
4+
# RUN: %target-swiftc -g -O %t/main.swift -o %t.out
5+
# RUN: %lldb -x -b -s %t/commands.input %t.out -o exit 2>&1 \
6+
# RUN: | FileCheck %s
7+
8+
#--- main.swift
9+
@inline(never)
10+
func baz(_ a: Int) -> Int {
11+
return a * 2
12+
}
13+
14+
@inline(__always)
15+
func foo(_ a: Int, _ b: Int) -> Int {
16+
return a * b * baz(a)
17+
}
18+
19+
func bar() {
20+
let baz = foo(4, 5)
21+
}
22+
23+
bar()
24+
25+
#--- commands.input
26+
b baz
27+
28+
run
29+
bt
30+
31+
# CHECK: `baz(a={{.*}}) at main.swift:3:14 [opt]
32+
# CHECK: `foo(a={{.*}}, b={{.*}}) at main.swift:8:17 [opt] [inlined]
33+
# CHECK: `bar() at main.swift:12:15 [opt] [inlined]

0 commit comments

Comments
 (0)