llvm-project/lldb/test/Shell/Settings/TestFrameFormatFunctionFormattedArguments.test
Michael Buch cebf86eb1d
[lldb][Format] Make function name frame-format variables work without debug-info (#137408)
This patch makes the frame-format variables introduced in
https://github.com/llvm/llvm-project/pull/131836 also work when no
debug-info is available. Previously, we assumed `sc.function` was
available, but without debug-info we might only have `sc.symbol`. We
don't really need the `sc.function` apart from when formatting
arguments.

For the function arguments case I added a fallback that will just print
the arguments we get from the demangler (which is what LLDB does for
stacktraces with no debug-info anyway). Ideally we'd have a separate
`FormatEntity::Entry::Type::FunctionArguments` that will just print the
arguments from the demangler and have something like the following in
the `plugin.cplusplus.display.function-name-format`:
```
{ ${function.formatted-arguments} || ${function.arguments} }
```
I.e., when we can't format the arguments, print the ones from the
demangler. But we currently don't have the `||` operator in the
frame-format language yet.
2025-04-28 10:46:00 +01:00

54 lines
1.3 KiB
Plaintext

# XFAIL: target-windows
# Test the ${function.formatted-arguments} frame-format variable.
# RUN: split-file %s %t
# RUN: %clang_host -g -gdwarf %t/main.cpp -o %t.out
# RUN: %lldb -x -b -s %t/commands.input %t.out -o exit 2>&1 \
# RUN: | FileCheck %s
#
# RUN: %clang_host -O0 %t/main.cpp -o %t-nodebug.out
# RUN: %lldb -x -b -s %t/commands.input %t-nodebug.out -o exit 2>&1 \
# RUN: | FileCheck %s --check-prefix=CHECK-NODEBUG
#--- main.cpp
struct Foo {
void func() {}
};
void bar() {
Foo{}.func();
}
void foo(int, int x) {
bar();
}
void myFunc(char const * str,
void (*fptr)(int, int)) {
fptr(5, 10);
}
int main(int argc, char const *argv[]) {
myFunc("hello", &foo);
return 0;
}
#--- commands.input
settings set -f frame-format "custom-frame '${function.formatted-arguments}'\n"
break set -n func
run
bt
# CHECK: custom-frame '(this={{.*}})'
# CHECK: custom-frame '()'
# CHECK: custom-frame '({{.*}}=5, x=10)'
# CHECK: custom-frame '(str="hello", fptr=({{.*}}.out`{{.*}}foo(int,{{.*}}int) at main.cpp:{{[0-9]+}}))'
# CHECK: custom-frame '(argc=1, argv={{.*}})'
# CHECK-NODEBUG: custom-frame '()'
# CHECK-NODEBUG: custom-frame '()'
# CHECK-NODEBUG: custom-frame '(int, int)'
# CHECK-NODEBUG: custom-frame '(char const*, void (*)(int, int))'