Skip to content

Commit 5fbc818

Browse files
Merge pull request #10786 from swiftlang/charles-zablit/lldb/remove-inlined-format
[lldb][Format] Display only the inlined Swift frame name in backtraces if available
2 parents 36d712e + 5ffc6cf commit 5fbc818

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
@@ -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: 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)