Skip to content

Commit da70992

Browse files
authored
Revert "[lldb][Format] Make function name frame-format variables work without debug-info" (#137757)
Reverts llvm/llvm-project#137408 This change broke `lldb/test/Shell/Unwind/split-machine-functions.test`. The test binary has a symbol named `_Z3foov.cold` and the test expects the backtrace to print the name of the cold part of the function like this: ``` # SPLIT: frame #1: {{.*}}`foo() (.cold) + ``` but now it gets ``` frame #1: 0x000055555555514f split-machine-functions.test.tmp`foo() + 12 ```
1 parent 0ddb579 commit da70992

8 files changed

+10
-73
lines changed

lldb/source/Core/FormatEntity.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -1809,12 +1809,11 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
18091809
case Entry::Type::FunctionReturnRight:
18101810
case Entry::Type::FunctionReturnLeft:
18111811
case Entry::Type::FunctionQualifiers: {
1812-
Language *language_plugin = nullptr;
1813-
if (sc->function)
1814-
language_plugin = Language::FindPlugin(sc->function->GetLanguage());
1815-
else if (sc->symbol)
1816-
language_plugin = Language::FindPlugin(sc->symbol->GetLanguage());
1812+
if (!sc->function)
1813+
return false;
18171814

1815+
Language *language_plugin =
1816+
Language::FindPlugin(sc->function->GetLanguage());
18181817
if (!language_plugin)
18191818
return false;
18201819

lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp

+2-36
Original file line numberDiff line numberDiff line change
@@ -381,34 +381,6 @@ GetDemangledScope(const SymbolContext &sc) {
381381
return demangled_name.slice(info->ScopeRange.first, info->ScopeRange.second);
382382
}
383383

384-
static bool PrintDemangledArgumentList(Stream &s, const SymbolContext &sc) {
385-
assert(sc.symbol);
386-
387-
Mangled mangled = sc.GetPossiblyInlinedFunctionName();
388-
if (!mangled)
389-
return false;
390-
391-
auto demangled_name = mangled.GetDemangledName().GetStringRef();
392-
if (demangled_name.empty())
393-
return false;
394-
395-
const std::optional<DemangledNameInfo> &info = mangled.GetDemangledInfo();
396-
if (!info)
397-
return false;
398-
399-
// Function without a basename is nonsense.
400-
if (!info->hasBasename())
401-
return false;
402-
403-
if (info->ArgumentsRange.second < info->ArgumentsRange.first)
404-
return false;
405-
406-
s << demangled_name.slice(info->ArgumentsRange.first,
407-
info->ArgumentsRange.second);
408-
409-
return true;
410-
}
411-
412384
bool CPlusPlusLanguage::CxxMethodName::TrySimplifiedParse() {
413385
// This method tries to parse simple method definitions which are presumably
414386
// most comman in user programs. Definitions that can be parsed by this
@@ -1918,6 +1890,8 @@ bool CPlusPlusLanguage::GetFunctionDisplayName(
19181890
bool CPlusPlusLanguage::HandleFrameFormatVariable(
19191891
const SymbolContext &sc, const ExecutionContext *exe_ctx,
19201892
FormatEntity::Entry::Type type, Stream &s) {
1893+
assert(sc.function);
1894+
19211895
switch (type) {
19221896
case FormatEntity::Entry::Type::FunctionScope: {
19231897
std::optional<llvm::StringRef> scope = GetDemangledScope(sc);
@@ -1951,14 +1925,6 @@ bool CPlusPlusLanguage::HandleFrameFormatVariable(
19511925
}
19521926

19531927
case FormatEntity::Entry::Type::FunctionFormattedArguments: {
1954-
// This ensures we print the arguments even when no debug-info is available.
1955-
//
1956-
// FIXME: we should have a Entry::Type::FunctionArguments and
1957-
// use it in the plugin.cplusplus.display.function-name-format
1958-
// once we have a "fallback operator" in the frame-format language.
1959-
if (!sc.function && sc.symbol)
1960-
return PrintDemangledArgumentList(s, sc);
1961-
19621928
VariableList args;
19631929
if (auto variable_list_sp = GetFunctionVariableList(sc))
19641930
variable_list_sp->AppendVariablesWithScope(eValueTypeVariableArgument,

lldb/test/Shell/Settings/TestFrameFormatFunctionBasename.test

-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
# RUN: %lldb -x -b -s %t/commands.input %t.out -o exit 2>&1 \
88
# RUN: | FileCheck %s
99
#
10-
# RUN: %clang_host -O0 %t/main.cpp -o %t-nodebug.out
11-
# RUN: %lldb -x -b -s %t/commands.input %t-nodebug.out -o exit 2>&1 \
12-
# RUN: | FileCheck %s
13-
1410
#--- main.cpp
1511
namespace ns {
1612
template<typename T>

lldb/test/Shell/Settings/TestFrameFormatFunctionFormattedArguments.test

-9
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
# RUN: %clang_host -g -gdwarf %t/main.cpp -o %t.out
77
# RUN: %lldb -x -b -s %t/commands.input %t.out -o exit 2>&1 \
88
# RUN: | FileCheck %s
9-
#
10-
# RUN: %clang_host -O0 %t/main.cpp -o %t-nodebug.out
11-
# RUN: %lldb -x -b -s %t/commands.input %t-nodebug.out -o exit 2>&1 \
12-
# RUN: | FileCheck %s --check-prefix=CHECK-NODEBUG
139

1410
#--- main.cpp
1511
struct Foo {
@@ -46,8 +42,3 @@ bt
4642
# CHECK: custom-frame '({{.*}}=5, x=10)'
4743
# CHECK: custom-frame '(str="hello", fptr=({{.*}}.out`{{.*}}foo(int,{{.*}}int) at main.cpp:{{[0-9]+}}))'
4844
# CHECK: custom-frame '(argc=1, argv={{.*}})'
49-
50-
# CHECK-NODEBUG: custom-frame '()'
51-
# CHECK-NODEBUG: custom-frame '()'
52-
# CHECK-NODEBUG: custom-frame '(int, int)'
53-
# CHECK-NODEBUG: custom-frame '(char const*, void (*)(int, int))'

lldb/test/Shell/Settings/TestFrameFormatFunctionQualifiers.test

-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
# RUN: %clang_host -g -gdwarf %t/main.cpp -o %t.out
77
# RUN: %lldb -x -b -s %t/commands.input %t.out -o exit 2>&1 \
88
# RUN: | FileCheck %s
9-
#
10-
# RUN: %clang_host -O0 %t/main.cpp -o %t-nodebug.out
11-
# RUN: %lldb -x -b -s %t/commands.input %t-nodebug.out -o exit 2>&1 \
12-
# RUN: | FileCheck %s
139

1410
#--- main.cpp
1511
struct Foo {

lldb/test/Shell/Settings/TestFrameFormatFunctionReturn.test

-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
# RUN: %clang_host -g -gdwarf %t/main.cpp -o %t.out
88
# RUN: %lldb -x -b -s %t/commands.input %t.out -o exit 2>&1 \
99
# RUN: | FileCheck %s
10-
#
11-
# RUN: %clang_host -O0 %t/main.cpp -o %t-nodebug.out
12-
# RUN: %lldb -x -b -s %t/commands.input %t-nodebug.out -o exit 2>&1 \
13-
# RUN: | FileCheck %s
1410

1511
#--- main.cpp
1612
namespace ns::ns2 {

lldb/test/Shell/Settings/TestFrameFormatFunctionScope.test

+2-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44

55
# RUN: split-file %s %t
66
# RUN: %clang_host -g -gdwarf %t/main.cpp -o %t.out
7-
# RUN: %lldb -x -b -s %t/commands.input %t.out -o exit 2>&1 \
8-
# RUN: | FileCheck %s
9-
#
10-
# RUN: %clang_host -O0 %t/main.cpp -o %t-nodebug.out
11-
# RUN: %lldb -x -b -s %t/commands.input %t-nodebug.out -o exit 2>&1 \
7+
# RUN: %lldb -o "settings set interpreter.stop-command-source-on-error false" \
8+
# RUN: -x -b -s %t/commands.input %t.out -o exit 2>&1 \
129
# RUN: | FileCheck %s
1310

1411
#--- main.cpp

lldb/test/Shell/Settings/TestFrameFormatFunctionTemplateArguments.test

+2-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@
33
# Test the ${function.template-arguments} frame-format variable.
44

55
# RUN: split-file %s %t
6-
# RUN: %clang_host -g -gdwarf %t/main.cpp -o %t.out
7-
# RUN: %lldb -x -b -s %t/commands.input %t.out -o exit 2>&1 \
8-
# RUN: | FileCheck %s
9-
#
10-
# RUN: %clang_host -O0 %t/main.cpp -o %t-nodebug.out
11-
# RUN: %lldb -x -b -s %t/commands.input %t-nodebug.out -o exit 2>&1 \
6+
# RUN: %clang_host -g -gdwarf %t/main.cpp -o %t.cxx.out
7+
# RUN: %lldb -x -b -s %t/commands.input %t.cxx.out -o exit 2>&1 \
128
# RUN: | FileCheck %s
139

1410
#--- main.cpp

0 commit comments

Comments
 (0)