[PATCH v2 2/2] gdb: add shadowed_loc field in '-stack-list-locals/variables' mi commands
abdul.b.ijaz
abijaz@ecsmtp.iul.intel.com
Wed Dec 29 11:14:46 GMT 2021
For C/C++/Fortran languages GDB prints same name variable multiple times in
case of variable shadowing and it is confusing for user to identify which
variable belongs to the current scope. So add 'shadowed_loc' field in
'-stack-list-locals' and '-stack-list-variables' mi commands for value of
super-block shadowed variable.
Suppose we have
1:int x = 42;
2: {
3: int x = 99;
4: x = 99; /* break here */
5: }
The "-stack-list-locals" and "-stack-list-variables" mi commands at the
"break here" line gives the following output:
(gdb)
-stack-list-locals 0
^done,locals=[name="x",name="x"]
(gdb)
-stack-list-locals 1
^done,locals=[{name="x",value="99"},{name="x",value="42"}]
(gdb)
-stack-list-locals 2
^done,locals=[{name="x",type="int",value="99"},{name="x",type="int",value="42"}]
(gdb)
-stack-list-variables 0
^done,variables=[{name="x"},{name="x"}]
(gdb)
-stack-list-variables 1
^done,variables=[{name="x",value="99"},{name="x",value="42"}]
(gdb)
-stack-list-variables 2
^done,variables=[{name="x",type="int",value="99"},{name="x",type="int",value="42"}]
So far this scenario is only known case for C/C++/Fortran language so
to tackle in this case, when iterating over the stack frame variables keep
the track of inner block variables and when same variable is found in the
outer-block then add shadowed_loc in mi command output with only exception to
'stack-list-locals 0' case where it is not added. Iteration of stack
frame variables always starts with inner block so gdb now print shadowed
field with value true for super-block duplicate variables like this:
(gdb)
-stack-list-locals 0
^done,locals=[name="x",name="x"]
(gdb)
-stack-list-locals 1
^done,locals=[{name="x",value="99"},{name="x",shadowed_loc="1",value="42"}]
(gdb)
-stack-list-locals 2
^done,locals=[{name="x",type="int",value="99"},{name="x",shadowed_loc="1",type="int",value="42"}]
(gdb)
-stack-list-variables 0
^done,variables=[{name="x"},{name="x",shadowed_loc="1"}]
(gdb)
-stack-list-variables 1
^done,variables=[{name="x",value="99"},{name="x",shadowed_loc="1",value="42"}]
(gdb)
-stack-list-variables 2
^done,variables=[{name="x",type="int",value="99"},{name="x",shadowed_loc="1",type="int",value="42"}]
In case of rust language it is possible to declare variable with same name
many times so in this case just print only first instance of variable.
gdb/ChangeLog:
2021-12-29 Abdul Basit Ijaz <abdul.b.ijaz@intel.com>
* mi/mi-cmd-stack.c (list_arg_or_local): Print shadowed_loc field
with line info after the value of super-block variable in
case of variable shadowing.
(list_args_or_locals): Declare unordered_set type object and
pass it to function 'list_arg_or_local'.
gdb/doc/ChangeLog:
2021-12-29 Abdul Basit Ijaz <abdul.b.ijaz@intel.com>
* gdb.textinfo: Update with shadowed variable line info.
gdb/testsuite/ChangeLog:
2021-12-29 Abdul Basit Ijaz <abdul.b.ijaz@intel.com>
* gdb.mi/mi2-amd64-entry-value.exp: Update regex expressions for
testing '-stack-list-variables' mi command output to handle
shadowed_loc field.
* gdb.mi/mi2-amd64-entry-value.c: Add new comments to
refer lines.
* gdb.trace/entry-values.exp: Change test cases to
support the shadowed variable print feature.
* gdb.mi/mi-var-shadowing.c: New file.
* gdb.mi/mi-var-shadowing.exp: New file.
2021-12-29 Abdul Basit Ijaz <abdul.b.ijaz@intel.com>
---
gdb/doc/gdb.texinfo | 12 ++
gdb/mi/mi-cmd-stack.c | 38 ++++-
gdb/testsuite/gdb.mi/mi-var-shadowing.c | 48 ++++++
gdb/testsuite/gdb.mi/mi-var-shadowing.exp | 138 ++++++++++++++++++
gdb/testsuite/gdb.mi/mi2-amd64-entry-value.c | 6 +-
.../gdb.mi/mi2-amd64-entry-value.exp | 23 +--
gdb/testsuite/gdb.trace/entry-values.exp | 2 +-
7 files changed, 250 insertions(+), 17 deletions(-)
create mode 100644 gdb/testsuite/gdb.mi/mi-var-shadowing.c
create mode 100644 gdb/testsuite/gdb.mi/mi-var-shadowing.exp
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 83994c3486..894ab0d737 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -32943,6 +32943,18 @@ If the @code{--skip-unavailable} option is specified, local variables
and arguments that are not available are not listed. Partially
available arguments and local variables are still displayed, however.
+@smallexample
+1: int x = 3;
+2: @{
+3: int x = 4; // breakpt
+4: @}
+(gdb) -stack-list-variables 2
+^done,variables=[@{name="x",type="int",value="4"@},@{name="x",shadowed_loc="1",type="int",value="3"@}]
+@end smallexample
+
+If a variable is shadowed, the @code{shadowed_loc} attribute is added and
+the line of declaration is displayed.
+
@subsubheading Example
@smallexample
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index 9bc9010239..f7211fbfa4 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -36,6 +36,7 @@
#include "mi-parse.h"
#include "gdbsupport/gdb_optional.h"
#include "safe-ctype.h"
+#include <unordered_set>
enum what_to_list { locals, arguments, all };
@@ -484,7 +485,8 @@ mi_cmd_stack_list_variables (const char *command, char **argv, int argc)
static void
list_arg_or_local (const struct frame_arg *arg, enum what_to_list what,
- enum print_values values, int skip_unavailable)
+ enum print_values values, int skip_unavailable,
+ std::unordered_set<std::string> &collected_vars)
{
struct ui_out *uiout = current_uiout;
@@ -514,6 +516,15 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what,
tuple_emitter.emplace (uiout, nullptr);
string_file stb;
+ bool already_collected
+ = collected_vars.find (arg->sym->print_name ()) != collected_vars.end ();
+
+ /* In case of rust language it is possible to declare variable with
+ same name multiple times and only latest declaration of variable
+ is accessible. So print only the first instance and there is no
+ need of printing duplicates. */
+ if (current_language->la_language == language_rust && already_collected)
+ return;
stb.puts (arg->sym->print_name ());
if (arg->entry_kind == print_entry_values_only)
@@ -523,6 +534,24 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what,
if (what == all && SYMBOL_IS_ARGUMENT (arg->sym))
uiout->field_signed ("arg", 1);
+ /* Only for C/C++/Fortran languages, in case of variables shadowing
+ print shadowed_loc field after the superblock variable. Iteration of
+ block starts from inner block so collected_vars variable keeps
+ track of the variables in the innerblock. */
+ if ((current_language->la_language == language_c
+ || current_language->la_language == language_cplus
+ || current_language->la_language == language_fortran)
+ && !(values == PRINT_NO_VALUES && what == locals)
+ && already_collected)
+ {
+ if (arg->sym->line > 0)
+ uiout->field_unsigned ("shadowed_loc", arg->sym->line);
+ else
+ uiout->field_string ("shadowed_loc", "NA");
+ }
+ else
+ collected_vars.insert (arg->sym->print_name ());
+
if (values == PRINT_SIMPLE_VALUES)
{
check_typedef (arg->sym->type);
@@ -572,6 +601,7 @@ list_args_or_locals (const frame_print_options &fp_opts,
struct type *type;
const char *name_of_result;
struct ui_out *uiout = current_uiout;
+ std::unordered_set<std::string> collected_vars;
block = get_frame_block (fi, 0);
@@ -663,9 +693,11 @@ list_args_or_locals (const frame_print_options &fp_opts,
}
if (arg.entry_kind != print_entry_values_only)
- list_arg_or_local (&arg, what, values, skip_unavailable);
+ list_arg_or_local (&arg, what, values,
+ skip_unavailable, collected_vars);
if (entryarg.entry_kind != print_entry_values_no)
- list_arg_or_local (&entryarg, what, values, skip_unavailable);
+ list_arg_or_local (&entryarg, what, values,
+ skip_unavailable, collected_vars);
}
}
diff --git a/gdb/testsuite/gdb.mi/mi-var-shadowing.c b/gdb/testsuite/gdb.mi/mi-var-shadowing.c
new file mode 100644
index 0000000000..e5e5a8faf5
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/mi-var-shadowing.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 2021 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <stdlib.h>
+
+void
+shadowing ()
+{
+ int a;
+ unsigned int val1 = 1; /* val1-d1 */
+ unsigned int val2 = 2; /* val2-d1 */
+ a = 101; /* bp for locals 1 */
+ {
+ unsigned int val2 = 3; /* val2-d2 */
+ unsigned int val3 = 4; /* val3-d1 */
+ a = 102; /* bp for locals 2 */
+ {
+ unsigned int val1 = 5; /* val1-d2 */
+ a = 103; /* bp for locals 3 */
+ {
+ unsigned int val1 = 6;
+ unsigned int val2 = 7;
+ unsigned int val3 = 8;
+ a = 104; /* bp for locals 4 */
+ }
+ }
+ }
+ a = 105; /* bp for locals 5 */
+}
+
+int
+main (void)
+{
+ shadowing ();
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.mi/mi-var-shadowing.exp b/gdb/testsuite/gdb.mi/mi-var-shadowing.exp
new file mode 100644
index 0000000000..25d16db683
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/mi-var-shadowing.exp
@@ -0,0 +1,138 @@
+# Copyright 2021 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+load_lib mi-support.exp
+set MIFLAGS "-i=mi"
+
+gdb_exit
+if [mi_gdb_start] {
+ continue
+}
+
+standard_testfile
+
+set opts {debug}
+if [build_executable ${testfile}.exp ${testfile} ${srcfile} $opts] {
+ return -1
+}
+
+mi_clean_restart $binfile
+
+if {[mi_runto_main] < 0} {
+ return -1
+}
+
+set bp_line1 [gdb_get_line_number "bp for locals 1" ${srcfile}]
+set bp_line2 [gdb_get_line_number "bp for locals 2" ${srcfile}]
+set bp_line3 [gdb_get_line_number "bp for locals 3" ${srcfile}]
+set bp_line4 [gdb_get_line_number "bp for locals 4" ${srcfile}]
+set bp_line5 [gdb_get_line_number "bp for locals 5" ${srcfile}]
+
+set val1_d1 [gdb_get_line_number "val1-d1" ${srcfile}]
+set val1_d2 [gdb_get_line_number "val1-d2" ${srcfile}]
+set val2_d1 [gdb_get_line_number "val2-d1" ${srcfile}]
+set val2_d2 [gdb_get_line_number "val2-d2" ${srcfile}]
+set val3_d1 [gdb_get_line_number "val3-d1" ${srcfile}]
+
+set stack_test1_regx "\\^done,(locals|variables)=\\\[\{name=\"a\",type=\"int\",value=\"$decimal\"\},\{name=\"val1\",type=\"unsigned int\",value=\"1\"\},{name=\"val2\",type=\"unsigned int\",value=\"2\"\}\\\]"
+set stack_test2_regx "\\^done,(locals|variables)=\\\[\{name=\"val2\",type=\"unsigned int\",value=\"3\"\},\{name=\"val3\",type=\"unsigned int\",value=\"4\"\},\{name=\"a\",type=\"int\",value=\"101\"\},\{name=\"val1\",type=\"unsigned int\",value=\"1\"\},\{name=\"val2\",shadowed_loc=\"$val2_d1\",type=\"unsigned int\",value=\"2\"\}\\\]"
+set stack_test3_regx "\\^done,(locals|variables)=\\\[\{name=\"val1\",type=\"unsigned int\",value=\"5\"},{name=\"val2\",type=\"unsigned int\",value=\"3\"\},\{name=\"val3\",type=\"unsigned int\",value=\"4\"\},\{name=\"a\",type=\"int\",value=\"102\"\},\{name=\"val1\",shadowed_loc=\"$val1_d1\",type=\"unsigned int\",value=\"1\"\},\{name=\"val2\",shadowed_loc=\"$val2_d1\",type=\"unsigned int\",value=\"2\"\}\\\]"
+set stack_test4_regx "\\^done,(locals|variables)=\\\[\{name=\"val1\",type=\"unsigned int\",value=\"6\"\},\{name=\"val2\",type=\"unsigned int\",value=\"7\"\},\{name=\"val3\",type=\"unsigned int\",value=\"8\"\},\{name=\"val1\",shadowed_loc=\"$val1_d2\",type=\"unsigned int\",value=\"5\"\},\{name=\"val2\",shadowed_loc=\"$val2_d2\",type=\"unsigned int\",value=\"3\"\},\{name=\"val3\",shadowed_loc=\"$val3_d1\",type=\"unsigned int\",value=\"4\"\},\{name=\"a\",type=\"int\",value=\"103\"\},\{name=\"val1\",shadowed_loc=\"$val1_d1\",type=\"unsigned int\",value=\"1\"\},\{name=\"val2\",shadowed_loc=\"$val2_d1\",type=\"unsigned int\",value=\"2\"\}\\\]"
+set stack_test5_regx "\\^done,(locals|variables)=\\\[\{name=\"a\",type=\"int\",value=\"104\"\},\{name=\"val1\",type=\"unsigned int\",value=\"1\"\},\{name=\"val2\",type=\"unsigned int\",value=\"2\"\}\\\]"
+
+mi_gdb_test \
+ "-break-insert --source ${srcfile} --line ${bp_line1}" \
+ "\\^done.*source ${srcfile} \\-line ${bp_line1}.*" \
+ "bp at outermost level"
+mi_execute_to "exec-continue" "breakpoint-hit" ".*" ".*" ".*" "${bp_line1}" \
+ { "" "disp=\"keep\"" } "continue to outermost level"
+mi_gdb_test "-stack-list-locals 0" \
+ "\\^done,locals=\\\[name=\"a\",name=\"val1\",name=\"val2\"\\\]" \
+ "-stack-list-locals 0 at outermost level"
+mi_gdb_test "-stack-list-variables 0" \
+ "\\^done,variables=\\\[{name=\"a\"},{name=\"val1\"},{name=\"val2\"}\\\]" \
+ "-stack-list-variables 0 at outermost level"
+mi_gdb_test "-stack-list-locals 2" "${stack_test1_regx}" \
+ "-stack-list-locals 2 at outermost level"
+mi_gdb_test "-stack-list-variables 2" "${stack_test1_regx}" \
+ "-stack-list-variables 2 at outermost level"
+
+mi_gdb_test \
+ "-break-insert --source ${srcfile} --line ${bp_line2}" \
+ "\\^done.*source ${srcfile} \\-line ${bp_line2}.*" \
+ "bp at first level"
+mi_execute_to "exec-continue" "breakpoint-hit" ".*" ".*" ".*" "${bp_line2}" \
+ { "" "disp=\"keep\"" } "continue to first level"
+mi_gdb_test "-stack-list-locals 0" \
+ "\\^done,locals=\\\[name=\"val2\",name=\"val3\",name=\"a\",name=\"val1\",name=\"val2\"\\\]" \
+ "-stack-list-locals 0 at first level"
+mi_gdb_test "-stack-list-variables 0" \
+ "\\^done,variables=\\\[{name=\"val2\"},{name=\"val3\"},{name=\"a\"},{name=\"val1\"},{name=\"val2\",shadowed_loc=\"$val2_d1\"}\\\]" \
+ "-stack-list-variables 0 at first level"
+mi_gdb_test "-stack-list-locals 2" "${stack_test2_regx}" \
+ "-stack-list-locals 2 at first level"
+mi_gdb_test "-stack-list-variables 2" "${stack_test2_regx}" \
+ "-stack-list-variables 2 at first level"
+
+mi_gdb_test \
+ "-break-insert --source ${srcfile} --line ${bp_line3}" \
+ "\\^done.*source ${srcfile} \\-line ${bp_line3}.*" \
+ "bp at second level"
+mi_execute_to "exec-continue" "breakpoint-hit" ".*" ".*" ".*" "${bp_line3}" \
+ { "" "disp=\"keep\"" } "continue to second level"
+mi_gdb_test "-stack-list-locals 0" \
+ "\\^done,locals=\\\[name=\"val1\",name=\"val2\",name=\"val3\",name=\"a\",name=\"val1\",name=\"val2\"\\\]" \
+ "-stack-list-locals 0 at second level"
+mi_gdb_test "-stack-list-variables 0" \
+ "\\^done,variables=\\\[{name=\"val1\"},{name=\"val2\"},{name=\"val3\"},{name=\"a\"},{name=\"val1\",shadowed_loc=\"$val1_d1\"},{name=\"val2\",shadowed_loc=\"$val2_d1\"}\\\]" \
+ "-stack-list-variables 0 at second level"
+mi_gdb_test "-stack-list-locals 2" "${stack_test3_regx}" \
+ "-stack-list-locals 2 at second level"
+mi_gdb_test "-stack-list-variables 2" "${stack_test3_regx}" \
+ "-stack-list-variables 2 at second level"
+
+mi_gdb_test \
+ "-break-insert --source ${srcfile} --line ${bp_line4}" \
+ "\\^done.*source ${srcfile} \\-line ${bp_line4}.*" \
+ "bp at third level"
+mi_execute_to "exec-continue" "breakpoint-hit" ".*" ".*" ".*" "${bp_line4}" \
+ { "" "disp=\"keep\"" } "continue to third level"
+mi_gdb_test "-stack-list-locals 0" \
+ "\\^done,locals=\\\[name=\"val1\",name=\"val2\",name=\"val3\",name=\"val1\",name=\"val2\",name=\"val3\",name=\"a\",name=\"val1\",name=\"val2\"\\\]" \
+ "-stack-list-locals 0 at third level"
+mi_gdb_test "-stack-list-variables 0" \
+ "\\^done,variables=\\\[{name=\"val1\"},{name=\"val2\"},{name=\"val3\"},{name=\"val1\",shadowed_loc=\"$val1_d2\"},{name=\"val2\",shadowed_loc=\"$val2_d2\"},{name=\"val3\",shadowed_loc=\"$val3_d1\"},{name=\"a\"},{name=\"val1\",shadowed_loc=\"$val1_d1\"},{name=\"val2\",shadowed_loc=\"$val2_d1\"}\\\]" \
+ "-stack-list-variables 0 at third level"
+mi_gdb_test "-stack-list-locals 2" "${stack_test4_regx}" \
+ "-stack-list-locals 2 at third level"
+mi_gdb_test "-stack-list-variables 2" "${stack_test4_regx}" \
+ "-stack-list-variables 2 at third level"
+
+mi_gdb_test \
+ "-break-insert --source ${srcfile} --line ${bp_line5}" \
+ "\\^done.*source ${srcfile} \\-line ${bp_line5}.*" \
+ "bp at outermost level last"
+mi_execute_to "exec-continue" "breakpoint-hit" ".*" ".*" ".*" "${bp_line5}" \
+ { "" "disp=\"keep\"" } "continue to outermost level last"
+mi_gdb_test "-stack-list-locals 0" \
+ "\\^done,locals=\\\[name=\"a\",name=\"val1\",name=\"val2\"\\\]" \
+ "-stack-list-locals 0 at outermost level last"
+mi_gdb_test "-stack-list-variables 0" \
+ "\\^done,variables=\\\[{name=\"a\"},{name=\"val1\"},{name=\"val2\"}\\\]" \
+ "-stack-list-variables at outermost level last"
+mi_gdb_test "-stack-list-locals 2" "${stack_test5_regx}" \
+ "-stack-list-locals 2 at outermost level last"
+mi_gdb_test "-stack-list-variables 2" "${stack_test5_regx}" \
+ "-stack-list-variables 2 at outermost level last"
diff --git a/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.c b/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.c
index f1aacce62e..5ab08e5eee 100644
--- a/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.c
+++ b/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.c
@@ -36,7 +36,7 @@ data2 (void)
}
static int __attribute__((noinline, noclone))
-different (int val)
+different (int val) /* different-d1 */
{
val++;
e (val, val);
@@ -45,7 +45,7 @@ asm ("breakhere_different:");
}
static int __attribute__((noinline, noclone))
-validity (int lost, int born)
+validity (int lost, int born) /* validity-d1 */
{
lost = data ();
e (0, 0.0);
@@ -54,7 +54,7 @@ asm ("breakhere_validity:");
}
static void __attribute__((noinline, noclone))
-invalid (int inv)
+invalid (int inv) /* invalid-d1 */
{
e (0, 0.0);
asm ("breakhere_invalid:");
diff --git a/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp b/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp
index cf60242c34..a2378fe85a 100644
--- a/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp
+++ b/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp
@@ -46,6 +46,9 @@ foreach name {different breakhere_different breakhere_validity breakhere_invalid
mi_create_breakpoint $name "break $name"
}
+set different_d1 [gdb_get_line_number "different-d1" ${testfile}.c]
+set validity_d1 [gdb_get_line_number "validity-d1" ${testfile}.c]
+set invalid_d1 [gdb_get_line_number "invalid-d1" ${testfile}.c]
# Test various kinds of `set print entry-values'.
@@ -132,16 +135,16 @@ with_test_prefix "entry-values=both" {
mi_gdb_test "-gdb-set print entry-values both" {\^done} "both: set print entry-values"
mi_send_resuming_command "exec-continue" "both: entry_equal: continue"
mi_expect_stop "breakpoint-hit" .* {{name="val",value="5"},{name="val@entry",value="5"}} .* .* {.* disp="keep"} "both: entry_equal: stop"
- mi_gdb_test "-stack-list-variables --all-values" {\^done,variables=\[{name="val",arg="1",value="5"},{name="val@entry",arg="1",value="5"}\]} "both: entry_equal: -stack-list-variables"
+ mi_gdb_test "-stack-list-variables --all-values" "\\^done,variables=\\\[\{name=\"val\",arg=\"1\",value=\"5\"\},\{name=\"val@entry\",arg=\"1\",shadowed_loc=\"$different_d1\",value=\"5\"\}\\\]" "both: entry_equal: -stack-list-variables"
mi_send_resuming_command "exec-continue" "both: entry_different: continue"
mi_expect_stop "breakpoint-hit" .* {{name="val",value="6"},{name="val@entry",value="5"}} .* .* {.* disp="keep"} "both: entry_different: stop"
- mi_gdb_test "-stack-list-variables --all-values" {\^done,variables=\[{name="val",arg="1",value="6"},{name="val@entry",arg="1",value="5"}\]} "both: entry_different: -stack-list-variables"
+ mi_gdb_test "-stack-list-variables --all-values" "\\^done,variables=\\\[\{name=\"val\",arg=\"1\",value=\"6\"\},\{name=\"val@entry\",arg=\"1\",shadowed_loc=\"$different_d1\",value=\"5\"\}\\\]" "both: entry_different: -stack-list-variables"
mi_send_resuming_command "exec-continue" "both: validity: continue"
mi_expect_stop "breakpoint-hit" .* {{name="lost",value="<optimized out>"},{name="lost@entry",value="5"},{name="born",value="10"},{name="born@entry",value="<optimized out>"}} .* .* {.* disp="keep"} "both: validity: stop"
- mi_gdb_test "-stack-list-variables --all-values" {\^done,variables=\[{name="lost",arg="1",value="<optimized out>"},{name="lost@entry",arg="1",value="5"},{name="born",arg="1",value="10"},{name="born@entry",arg="1",value="<optimized out>"}\]} "both: validity: -stack-list-variables"
+ mi_gdb_test "-stack-list-variables --all-values" "\\^done,variables=\\\[\{name=\"lost\",arg=\"1\",value=\"<optimized out>\"\},\{name=\"lost@entry\",arg=\"1\",shadowed_loc=\"$validity_d1\",value=\"5\"\},\{name=\"born\",arg=\"1\",value=\"10\"\},\{name=\"born@entry\",arg=\"1\",shadowed_loc=\"$validity_d1\",value=\"<optimized out>\"\}\\\]" "both: validity: -stack-list-variables"
mi_send_resuming_command "exec-continue" "both: invalid: continue"
mi_expect_stop "breakpoint-hit" .* {{name="inv",value="<optimized out>"},{name="inv@entry",value="<optimized out>"}} .* .* {.* disp="keep"} "both: invalid: stop"
- mi_gdb_test "-stack-list-variables --all-values" {\^done,variables=\[{name="inv",arg="1",value="<optimized out>"},{name="inv@entry",arg="1",value="<optimized out>"}\]} "both: invalid: -stack-list-variables"
+ mi_gdb_test "-stack-list-variables --all-values" "\\^done,variables=\\\[\{name=\"inv\",arg=\"1\",value=\"<optimized out>\"\},\{name=\"inv@entry\",arg=\"1\",shadowed_loc=\"$invalid_d1\",value=\"<optimized out>\"\}\\\]" "both: invalid: -stack-list-variables"
}
with_test_prefix "entry-values=compact" {
@@ -151,13 +154,13 @@ with_test_prefix "entry-values=compact" {
mi_gdb_test "-gdb-set print entry-values compact" {\^done} "compact: set print entry-values"
mi_send_resuming_command "exec-continue" "compact: entry_equal: continue"
mi_expect_stop "breakpoint-hit" .* {{name="val",value="5"},{name="val@entry",value="5"}} .* .* {.* disp="keep"} "compact: entry_equal: stop"
- mi_gdb_test "-stack-list-variables --all-values" {\^done,variables=\[{name="val",arg="1",value="5"},{name="val@entry",arg="1",value="5"}\]} "compact: entry_equal: -stack-list-variables"
+ mi_gdb_test "-stack-list-variables --all-values" "\\^done,variables=\\\[\{name=\"val\",arg=\"1\",value=\"5\"\},\{name=\"val@entry\",arg=\"1\",shadowed_loc=\"$different_d1\",value=\"5\"\}\\\]" "compact: entry_equal: -stack-list-variables"
mi_send_resuming_command "exec-continue" "compact: entry_different: continue"
mi_expect_stop "breakpoint-hit" .* {{name="val",value="6"},{name="val@entry",value="5"}} .* .* {.* disp="keep"} "compact: entry_different: stop"
- mi_gdb_test "-stack-list-variables --all-values" {\^done,variables=\[{name="val",arg="1",value="6"},{name="val@entry",arg="1",value="5"}\]} "compact: entry_different: -stack-list-variables"
+ mi_gdb_test "-stack-list-variables --all-values" "\\^done,variables=\\\[\{name=\"val\",arg=\"1\",value=\"6\"\},\{name=\"val@entry\",arg=\"1\",shadowed_loc=\"$different_d1\",value=\"5\"\}\\\]" "compact: entry_different: -stack-list-variables"
mi_send_resuming_command "exec-continue" "compact: validity: continue"
mi_expect_stop "breakpoint-hit" .* {{name="lost@entry",value="5"},{name="born",value="10"}} .* .* {.* disp="keep"} "compact: validity: stop"
- mi_gdb_test "-stack-list-variables --all-values" {\^done,variables=\[{name="lost@entry",arg="1",value="5"},{name="born",arg="1",value="10"}\]} "compact: validity: -stack-list-variables"
+ mi_gdb_test "-stack-list-variables --all-values" "\\^done,variables=\\\[\{name=\"lost@entry\",arg=\"1\",value=\"5\"\},\{name=\"born\",arg=\"1\",value=\"10\"\}\\\]" "compact: validity: -stack-list-variables"
mi_send_resuming_command "exec-continue" "compact: invalid: continue"
mi_expect_stop "breakpoint-hit" .* {{name="inv",value="<optimized out>"}} .* .* {.* disp="keep"} "compact: invalid: stop"
mi_gdb_test "-stack-list-variables --all-values" {\^done,variables=\[{name="inv",arg="1",value="<optimized out>"}\]} "compact: invalid: -stack-list-variables"
@@ -170,13 +173,13 @@ with_test_prefix "entry-values=default" {
mi_gdb_test "-gdb-set print entry-values default" {\^done} "default: set print entry-values"
mi_send_resuming_command "exec-continue" "default: entry_equal: continue"
mi_expect_stop "breakpoint-hit" .* {{name="val",value="5"},{name="val@entry",value="5"}} .* .* {.* disp="keep"} "default: entry_equal: stop"
- mi_gdb_test "-stack-list-variables --all-values" {\^done,variables=\[{name="val",arg="1",value="5"},{name="val@entry",arg="1",value="5"}\]} "default: entry_equal: -stack-list-variables"
+ mi_gdb_test "-stack-list-variables --all-values" "\\^done,variables=\\\[\{name=\"val\",arg=\"1\",value=\"5\"\},\{name=\"val@entry\",arg=\"1\",shadowed_loc=\"$different_d1\",value=\"5\"\}\\\]" "default: entry_equal: -stack-list-variables"
mi_send_resuming_command "exec-continue" "default: entry_different: continue"
mi_expect_stop "breakpoint-hit" .* {{name="val",value="6"},{name="val@entry",value="5"}} .* .* {.* disp="keep"} "default: entry_different: stop"
- mi_gdb_test "-stack-list-variables --all-values" {\^done,variables=\[{name="val",arg="1",value="6"},{name="val@entry",arg="1",value="5"}\]} "default: entry_different: -stack-list-variables"
+ mi_gdb_test "-stack-list-variables --all-values" "\\^done,variables=\\\[\{name=\"val\",arg=\"1\",value=\"6\"\},\{name=\"val@entry\",arg=\"1\",shadowed_loc=\"$different_d1\",value=\"5\"\}\\\]" "default: entry_different: -stack-list-variables"
mi_send_resuming_command "exec-continue" "default: validity: continue"
mi_expect_stop "breakpoint-hit" .* {{name="lost",value="<optimized out>"},{name="lost@entry",value="5"},{name="born",value="10"}} .* .* {.* disp="keep"} "default: validity: stop"
- mi_gdb_test "-stack-list-variables --all-values" {\^done,variables=\[{name="lost",arg="1",value="<optimized out>"},{name="lost@entry",arg="1",value="5"},{name="born",arg="1",value="10"}\]} "default: validity: -stack-list-variables"
+ mi_gdb_test "-stack-list-variables --all-values" "\\^done,variables=\\\[\{name=\"lost\",arg=\"1\",value=\"<optimized out>\"\},\{name=\"lost@entry\",arg=\"1\",shadowed_loc=\"$validity_d1\",value=\"5\"\},\{name=\"born\",arg=\"1\",value=\"10\"\}\\\]" "default: validity: -stack-list-variables"
mi_send_resuming_command "exec-continue" "default: invalid: continue"
mi_expect_stop "breakpoint-hit" .* {{name="inv",value="<optimized out>"}} .* .* {.* disp="keep"} "default: invalid: stop"
mi_gdb_test "-stack-list-variables --all-values" {\^done,variables=\[{name="inv",arg="1",value="<optimized out>"}\]} "default: invalid: -stack-list-variables"
diff --git a/gdb/testsuite/gdb.trace/entry-values.exp b/gdb/testsuite/gdb.trace/entry-values.exp
index bd8a8c5559..3485b6215c 100644
--- a/gdb/testsuite/gdb.trace/entry-values.exp
+++ b/gdb/testsuite/gdb.trace/entry-values.exp
@@ -239,6 +239,6 @@ gdb_test "bt 1" "#0 .* foo \\(i=\[-\]?$decimal, i@entry=2, j=\[-\]?$decimal, j@e
# Test that unavailable "j@entry" is not shown when command option
# --skip-unavailable is used.
gdb_test "interpreter-exec mi \"-stack-list-arguments --skip-unavailable --simple-values\"" \
- "\r\n\\^done,stack-args=\\\[frame={level=\"0\",args=\\\[{name=\"i\",type=\"int\",value=\".*\"},{name=\"i@entry\",type=\"int\",value=\"2\"},{name=\"j\",type=\"int\",value=\".*\"}\\\]},frame=.*\\\].*"
+ "\r\n\\^done,stack-args=\\\[frame={level=\"0\",args=\\\[{name=\"i\",type=\"int\",value=\".*\"},{name=\"i@entry\",shadowed_loc=\"NA\",type=\"int\",value=\"2\"},{name=\"j\",type=\"int\",value=\".*\"}\\\]},frame=.*\\\].*"
gdb_test "tfind" "Target failed to find requested trace frame\..*"
--
2.31.1
More information about the Gdb-patches
mailing list