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 6 commits 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
9 changes: 3 additions & 6 deletions lldb/source/Plugins/Language/Swift/SwiftLanguage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1722,7 +1722,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 @@ -1748,9 +1748,7 @@ bool SwiftLanguage::GetFunctionDisplayName(
}

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the back and forth, but now that we merged #10789 into 6.2, we can remove this

}

VariableList args;
Expand Down Expand Up @@ -1862,8 +1860,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
34 changes: 34 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,34 @@
# Test Swift function name printing in backtraces.

# XFAIL: !system-darwin
# 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=Swift.Int @ scalar)
# CHECK: `[inlined] foo(a=Swift.Int @ scalar, b=Swift.Int @ scalar)
# CHECK: `[inlined] bar()