Skip to content

[lldb][Format] Display only the inlined Swift frame name in backtraces if available #10786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: swift/release/6.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions lldb/source/Plugins/Language/Swift/SwiftLanguage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1724,7 +1724,7 @@ bool SwiftLanguage::GetFunctionDisplayName(
if (sc.function->GetLanguage() != eLanguageTypeSwift)
return false;
std::string display_name = SwiftLanguageRuntime::DemangleSymbolAsString(
sc.function->GetMangled().GetMangledName().GetStringRef(),
sc.GetPossiblyInlinedFunctionName().GetMangledName(),
SwiftLanguageRuntime::eSimplified, &sc, exe_ctx);
if (display_name.empty())
return false;
Expand All @@ -1749,12 +1749,6 @@ bool SwiftLanguage::GetFunctionDisplayName(
sc.function->GetBlock(true).GetBlockVariableList(true);
}

if (inline_info) {
s << display_name;
s.PutCString(" [inlined] ");
display_name = inline_info->GetName().GetString();
}

VariableList args;
if (variable_list_sp)
variable_list_sp->AppendVariablesWithScope(eValueTypeVariableArgument,
Expand Down Expand Up @@ -1864,8 +1858,7 @@ SwiftLanguage::GetDemangledFunctionNameWithoutArguments(Mangled mangled) const {
ConstString mangled_name = mangled.GetMangledName();
ConstString demangled_name = mangled.GetDemangledName();
if (demangled_name && mangled_name) {
if (SwiftLanguageRuntime::IsSwiftMangledName(
demangled_name.GetStringRef())) {
if (SwiftLanguageRuntime::IsSwiftMangledName(mangled_name.GetStringRef())) {
lldb_private::ConstString basename;
bool is_method = false;
if (SwiftLanguageRuntime::MethodName::ExtractFunctionBasenameFromMangled(
Expand Down
33 changes: 33 additions & 0 deletions lldb/test/Shell/Swift/inlined-function-name-backtrace.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Test Swift function name printing in backtraces.

# RUN: split-file %s %t
# RUN: %target-swiftc -g -O %t/main.swift -o %t.out
# RUN: %lldb -x -b -s %t/commands.input %t.out -o exit 2>&1 \
# RUN: | FileCheck %s

#--- main.swift
@inline(never)
func baz(_ a: Int) -> Int {
return a * 2
}

@inline(__always)
func foo(_ a: Int, _ b: Int) -> Int {
return a * b * baz(a)
}

func bar() {
let baz = foo(4, 5)
}

bar()

#--- commands.input
b baz

run
bt

# CHECK: `baz(a={{.*}}) at main.swift:3:14 [opt]
# CHECK: `foo(a={{.*}}, b={{.*}}) at main.swift:8:17 [opt] [inlined]
# CHECK: `bar() at main.swift:12:15 [opt] [inlined]