Skip to content

Commit f2605f6

Browse files
Merge pull request #10847 from charles-zablit/charles-zablit/lldb/remove-inlined-format-to-next
🍒 [lldb][Format] Display only the inlined Swift frame name in backtraces if available
2 parents faf969d + 408baa7 commit f2605f6

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,7 +1767,7 @@ std::string SwiftLanguage::GetFunctionName(const SymbolContext &sc,
17671767
if (sc.function->GetLanguage() != eLanguageTypeSwift)
17681768
return {};
17691769
std::string name = SwiftLanguageRuntime::DemangleSymbolAsString(
1770-
sc.function->GetMangled().GetMangledName().GetStringRef(),
1770+
sc.GetPossiblyInlinedFunctionName().GetMangledName(),
17711771
SwiftLanguageRuntime::eSimplified, &sc, exe_ctx);
17721772
if (name.empty())
17731773
return {};
@@ -1885,8 +1885,7 @@ SwiftLanguage::GetDemangledFunctionNameWithoutArguments(Mangled mangled) const {
18851885
ConstString mangled_name = mangled.GetMangledName();
18861886
ConstString demangled_name = mangled.GetDemangledName();
18871887
if (demangled_name && mangled_name) {
1888-
if (SwiftLanguageRuntime::IsSwiftMangledName(
1889-
demangled_name.GetStringRef())) {
1888+
if (SwiftLanguageRuntime::IsSwiftMangledName(mangled_name.GetStringRef())) {
18901889
lldb_private::ConstString basename;
18911890
bool is_method = false;
18921891
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-windows
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={{.*}}) at main.swift:3:14 [opt]
33+
# CHECK: `foo(a={{.*}}, b={{.*}}) at main.swift:8:17 [opt] [inlined]
34+
# CHECK: `bar() at main.swift:12:15 [opt] [inlined]

0 commit comments

Comments
 (0)