diff --git a/lldb/source/Plugins/Language/Swift/SwiftLanguage.cpp b/lldb/source/Plugins/Language/Swift/SwiftLanguage.cpp index 620b4033d4f97..05065a1f6e9b0 100644 --- a/lldb/source/Plugins/Language/Swift/SwiftLanguage.cpp +++ b/lldb/source/Plugins/Language/Swift/SwiftLanguage.cpp @@ -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; @@ -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, @@ -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( diff --git a/lldb/test/Shell/Swift/inlined-function-name-backtrace.test b/lldb/test/Shell/Swift/inlined-function-name-backtrace.test new file mode 100644 index 0000000000000..8b264d27935b4 --- /dev/null +++ b/lldb/test/Shell/Swift/inlined-function-name-backtrace.test @@ -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]