Skip to content

Commit 8afab75

Browse files
authored
[lldb][Format] Fall back to old function.name-with-args if language frame format is emtpy (#148235)
There is currently no way to prevent `${function.name-with-args}` from using the `plugin.cplusplus.display.function-name-format` setting. Even if the setting is set to an empty string. As a way to disable formatting by language plugin, this patch makes it so `plugin.cplusplus.display.function-name-format` falls back to the old way of printing `${function.name-with-args}`. Even if we didn't want to add a fallback, making the setting an empty string shouldn't really "succeed".
1 parent 00311cf commit 8afab75

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

lldb/source/Core/FormatEntity.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,9 @@ static bool FormatFunctionNameForLanguage(Stream &s,
12801280
return false;
12811281

12821282
FormatEntity::Entry format = language_plugin->GetFunctionNameFormat();
1283-
if (!format)
1283+
1284+
// Bail on invalid or empty format.
1285+
if (!format || format == FormatEntity::Entry(Entry::Type::Root))
12841286
return false;
12851287

12861288
StreamString name_stream;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# XFAIL: target-windows
2+
3+
# Test that setting plugin.cplusplus.display.function-name-format
4+
# to an empty string disables the "format by language" part of
5+
# ${function.name-with-args}.
6+
7+
# RUN: split-file %s %t
8+
# RUN: %clang_host -g -gdwarf %t/main.cpp -o %t.out
9+
# RUN: %lldb -x -b -s %t/commands.input %t.out -o exit 2>&1 \
10+
# RUN: | FileCheck %s
11+
12+
#--- main.cpp
13+
namespace ns::ns2 {
14+
void custom(int x) {}
15+
void bar() { custom(5); }
16+
}
17+
18+
int main(int argc, char const *argv[]) {
19+
ns::ns2::bar();
20+
return 0;
21+
}
22+
23+
#--- commands.input
24+
settings set plugin.cplusplus.display.function-name-format ""
25+
settings set -f frame-format "custom-frame '${function.name-with-args}'\n"
26+
break set -l 2 -f main.cpp
27+
28+
run
29+
bt
30+
31+
# CHECK: custom-frame 'ns::ns2::custom(x=5)'
32+
# CHECK: custom-frame 'ns::ns2::bar()'

0 commit comments

Comments
 (0)