Skip to content

Commit 1a77c11

Browse files
committed
[lldb] Print children-count warning for dwim-print and expr (llvm#149088)
When dumping variables, LLDB will print a one-time warning about truncating children (when the children count exceeds the default `target.max-children-count`). But we only do this for `frame variable`. So if we use `dwim-print` or `expression`, the output gets truncated but we don't print a warning. But because we store the fact that we truncated some output on the `CommandInterpreter`, we fire the warning next time we use `frame variable`. E.g.,: ``` (lldb) p arr (int[1000]) { [0] = -5 [1] = 0 [2] = 0 <-- snipped --> [253] = 0 [254] = 0 [255] = 0 ... } (lldb) v someLocal (int) someLocal = 10 *** Some of the displayed variables have more members than the debugger will show by default. To show all of them, you can either use the --show-all-children option to frame variable or raise the limit by changing the target.max-children-count setting. ``` This patch prints the warning for `dwim-print` and `expression`. I only added a test for the `target.max-children-count` for now because it seems the `target.max-children-depth` warning is broken (I can't get it to fire). (cherry picked from commit 8c28f49)
1 parent 858fa71 commit 1a77c11

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

lldb/source/Commands/CommandObjectDWIMPrint.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
152152
return;
153153
}
154154
}
155+
m_interpreter.PrintWarningsIfNecessary(result.GetOutputStream(),
156+
m_cmd_name);
155157
result.SetStatus(eReturnStatusSuccessFinishResult);
156158
};
157159

lldb/source/Commands/CommandObjectExpression.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,9 @@ bool CommandObjectExpression::EvaluateExpression(llvm::StringRef expr,
494494
return false;
495495
}
496496

497+
m_interpreter.PrintWarningsIfNecessary(result.GetOutputStream(),
498+
m_cmd_name);
499+
497500
if (suppress_result)
498501
if (auto result_var_sp =
499502
target.GetPersistentVariable(result_valobj_sp->GetName())) {
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Test that we warn the user about truncated output
2+
# when target.max-children-count wasn't explicitly set.
3+
4+
# RUN: split-file %s %t
5+
# RUN: %clang_host -g -gdwarf %t/main.cpp -o %t.out
6+
# RUN: %lldb -x -b -s %t/dwim-commands.input %t.out -o exit 2>&1 \
7+
# RUN: | FileCheck %s --check-prefix=DWIM
8+
#
9+
# RUN: %lldb -x -b -s %t/expr-commands.input %t.out -o exit 2>&1 \
10+
# RUN: | FileCheck %s --check-prefix=EXPR
11+
#
12+
# RUN: %lldb -x -b -s %t/frame-var-commands.input %t.out -o exit 2>&1 \
13+
# RUN: | FileCheck %s --check-prefix=VAR
14+
#
15+
# RUN: %lldb -x -b -s %t/with-setting-commands.input %t.out -o exit 2>&1 \
16+
# RUN: | FileCheck %s --check-prefix=SETTING
17+
18+
#--- main.cpp
19+
20+
int main() {
21+
int arr[512] = { 3 };
22+
__builtin_debugtrap();
23+
}
24+
25+
#--- dwim-commands.input
26+
27+
run
28+
dwim-print arr
29+
frame variable arr
30+
31+
DWIM: (lldb) dwim-print arr
32+
DWIM: *** Some of the displayed variables have more members
33+
DWIM-SAME: use the --show-all-children option to dwim-print
34+
DWIM: (lldb) frame variable arr
35+
DWIM-NOT: *** Some of the displayed variables have more members
36+
37+
#--- expr-commands.input
38+
39+
run
40+
expression arr
41+
frame variable arr
42+
43+
EXPR: (lldb) expression arr
44+
EXPR: *** Some of the displayed variables have more members
45+
EXPR-SAME: use the --show-all-children option to expression
46+
EXPR: (lldb) frame variable arr
47+
EXPR-NOT: *** Some of the displayed variables have more members
48+
49+
#--- frame-var-commands.input
50+
51+
run
52+
frame variable arr
53+
54+
VAR: (lldb) frame variable arr
55+
VAR: *** Some of the displayed variables have more members
56+
VAR-SAME: use the --show-all-children option to frame variable
57+
VAR: (lldb) frame variable arr
58+
VAR-NOT: *** Some of the displayed variables have more members
59+
60+
#--- with-setting-commands.input
61+
62+
run
63+
settings set target.max-children-count 1
64+
frame variable arr
65+
66+
SETTING: (lldb) frame variable arr
67+
SETTING-NOT: *** Some of the displayed variables have more members

0 commit comments

Comments
 (0)