[PATCH 2/2] gdb: add shadowed field in '-stack-list-locals/variables' mi commands
abdul.b.ijaz
abijaz@ecsmtp.iul.intel.com
Wed Jul 28 17:43:08 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' field in
'-stack-list-locals' mi command for value of super-block shadowed variable.
Suppose we have
int x = 42;
{
int x = 99;
x = 99; /* break here */
}
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 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="true",value="42"}]
(gdb)
-stack-list-locals 2
^done,locals=[{name="x",type="int",value="99"},{name="x",shadowed="true",type="int",value="42"}]
(gdb)
-stack-list-variables 0
^done,variables=[{name="x"},{name="x",shadowed="true"}]
(gdb)
-stack-list-variables 1
^done,variables=[{name="x",value="99"},{name="x",shadowed="true",value="42"}]
(gdb)
-stack-list-variables 2
^done,variables=[{name="x",type="int",value="99"},{name="x",shadowed="true",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-07-28 Abdul Basit Ijaz <abdul.b.ijaz@intel.com>
* mi/mi-cmd-stack.c (list_arg_or_local): Print shadowed field
with value true 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/testsuite/ChangeLog:
2021-07-28 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
field.
* gdb.trace/entry-values.exp: Ditto.
* gdb.mi/mi-var-shadowing.c: New file.
* gdb.mi/mi-var-shadowing.exp: New file.
2021-07-28 Abdul Basit Ijaz <abdul.b.ijaz@intel.com>
---
gdb/mi/mi-cmd-stack.c | 33 ++++-
gdb/testsuite/gdb.mi/mi-var-shadowing.c | 48 +++++++
gdb/testsuite/gdb.mi/mi-var-shadowing.exp | 132 ++++++++++++++++++
.../gdb.mi/mi2-amd64-entry-value.exp | 18 +--
gdb/testsuite/gdb.trace/entry-values.exp | 2 +-
5 files changed, 220 insertions(+), 13 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/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index 9bc9010239..673d3e3e3e 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,19 @@ 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 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)
+ uiout->field_string ("shadowed", "true");
+ else
+ collected_vars.insert (arg->sym->print_name ());
+
if (values == PRINT_SIMPLE_VALUES)
{
check_typedef (arg->sym->type);
@@ -572,6 +596,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 +688,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..5e72754a53
--- /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;
+ unsigned int val2 = 2;
+ a = 101; /* bp for locals 1 */
+ {
+ unsigned int val2 = 3;
+ unsigned int val3 = 4;
+ a = 102; /* bp for locals 2 */
+ {
+ unsigned int val1 = 5;
+ 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..2965202093
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/mi-var-shadowing.exp
@@ -0,0 +1,132 @@
+# 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 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=\"true\",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=\"true\",type=\"unsigned int\",value=\"1\"\},\{name=\"val2\",shadowed=\"true\",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=\"true\",type=\"unsigned int\",value=\"5\"\},\{name=\"val2\",shadowed=\"true\",type=\"unsigned int\",value=\"3\"\},\{name=\"val3\",shadowed=\"true\",type=\"unsigned int\",value=\"4\"\},\{name=\"a\",type=\"int\",value=\"103\"\},\{name=\"val1\",shadowed=\"true\",type=\"unsigned int\",value=\"1\"\},\{name=\"val2\",shadowed=\"true\",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=\"true\"}\\\]" \
+ "-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=\"true\"},{name=\"val2\",shadowed=\"true\"}\\\]" \
+ "-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=\"true\"},{name=\"val2\",shadowed=\"true\"},{name=\"val3\",shadowed=\"true\"},{name=\"a\"},{name=\"val1\",shadowed=\"true\"},{name=\"val2\",shadowed=\"true\"}\\\]" \
+ "-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.exp b/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp
index 4505bfada6..0bbe04fb6d 100644
--- a/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp
+++ b/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp
@@ -123,16 +123,16 @@ if {[mi_runto_main] == -1} {
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="true",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="true",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="true",value="5"},{name="born",arg="1",value="10"},{name="born@entry",arg="1",shadowed="true",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="true",value="<optimized out>"}\]} "both: invalid: -stack-list-variables"
if {[mi_runto_main] == -1} {
return -1
@@ -140,10 +140,10 @@ if {[mi_runto_main] == -1} {
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="true",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="true",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"
@@ -157,13 +157,13 @@ if {[mi_runto_main] == -1} {
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="true",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="true",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="true",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 3695a1ee11..487d496098 100644
--- a/gdb/testsuite/gdb.trace/entry-values.exp
+++ b/gdb/testsuite/gdb.trace/entry-values.exp
@@ -241,6 +241,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=\"true\",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