2021-01-01 16:03:39 +08:00
|
|
|
# Copyright 2011-2021 Free Software Foundation, Inc.
|
GDB/MI: crash printing "_task" (Ada) argument
In GDB/MI mode, trying to print the arguments of the frame corresponding
to the body of a task ("-stack-list-arguments 1") causes the debugger to
crash.
This is because the compiler adds an implicit argument to that task body
called "_task". mi/mi-cmd-stack.c:list_args_or_locals, which is
responsible for printing the value of our arguments, finds that our
"_task" symbol is an argument, and thus tries to fing the non-argument
equivalent:
if (SYMBOL_IS_ARGUMENT (sym))
sym2 = lookup_symbol (SYMBOL_NATURAL_NAME (sym),
block, VAR_DOMAIN,
(int *) NULL);
Unfortunately, it tries using the natural name, which doesn't always
work for Ada parameters, in particular those who are internally-
generated. In our case, The "_task" parameter's natural name is
"<_task>", and that symbol does not exist. So sym2 is NULL, thus
causing the crash a little later on when trying to dereference it.
We should be using the symbol linkage name in this case, the same
way iterate_over_block_arg_vars already does.
gdb/ChangeLog:
* mi/mi-cmd-stack.c (list_args_or_locals): For argument symbols,
use SYMBOL_LINKAGE_NAME to find the corresponding non-argument
symbol. Add assertion that sym2 is never NULL.
gdb/testsuite/ChangeLog:
* gdb.ada/mi_task_arg: New testcase.
2012-02-03 15:32:40 +08:00
|
|
|
#
|
|
|
|
# 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 "ada.exp"
|
|
|
|
|
2020-08-14 00:34:21 +08:00
|
|
|
if { [skip_ada_tests] } { return -1 }
|
|
|
|
|
2012-07-27 02:43:02 +08:00
|
|
|
standard_ada_testfile task_switch
|
GDB/MI: crash printing "_task" (Ada) argument
In GDB/MI mode, trying to print the arguments of the frame corresponding
to the body of a task ("-stack-list-arguments 1") causes the debugger to
crash.
This is because the compiler adds an implicit argument to that task body
called "_task". mi/mi-cmd-stack.c:list_args_or_locals, which is
responsible for printing the value of our arguments, finds that our
"_task" symbol is an argument, and thus tries to fing the non-argument
equivalent:
if (SYMBOL_IS_ARGUMENT (sym))
sym2 = lookup_symbol (SYMBOL_NATURAL_NAME (sym),
block, VAR_DOMAIN,
(int *) NULL);
Unfortunately, it tries using the natural name, which doesn't always
work for Ada parameters, in particular those who are internally-
generated. In our case, The "_task" parameter's natural name is
"<_task>", and that symbol does not exist. So sym2 is NULL, thus
causing the crash a little later on when trying to dereference it.
We should be using the symbol linkage name in this case, the same
way iterate_over_block_arg_vars already does.
gdb/ChangeLog:
* mi/mi-cmd-stack.c (list_args_or_locals): For argument symbols,
use SYMBOL_LINKAGE_NAME to find the corresponding non-argument
symbol. Add assertion that sym2 is never NULL.
gdb/testsuite/ChangeLog:
* gdb.ada/mi_task_arg: New testcase.
2012-02-03 15:32:40 +08:00
|
|
|
|
|
|
|
if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional_flags=-gnata ]] != "" } {
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
load_lib mi-support.exp
|
|
|
|
set MIFLAGS "-i=mi"
|
|
|
|
|
|
|
|
gdb_exit
|
|
|
|
if [mi_gdb_start] {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
mi_delete_breakpoints
|
|
|
|
mi_gdb_reinitialize_dir $srcdir/$subdir
|
|
|
|
mi_gdb_load ${binfile}
|
|
|
|
|
2012-03-06 05:21:13 +08:00
|
|
|
# This test won't work properly if system debuginfo is installed.
|
|
|
|
mi_gdb_test "-gdb-set debug-file-directory \"\"" ".*"
|
|
|
|
|
GDB/MI: crash printing "_task" (Ada) argument
In GDB/MI mode, trying to print the arguments of the frame corresponding
to the body of a task ("-stack-list-arguments 1") causes the debugger to
crash.
This is because the compiler adds an implicit argument to that task body
called "_task". mi/mi-cmd-stack.c:list_args_or_locals, which is
responsible for printing the value of our arguments, finds that our
"_task" symbol is an argument, and thus tries to fing the non-argument
equivalent:
if (SYMBOL_IS_ARGUMENT (sym))
sym2 = lookup_symbol (SYMBOL_NATURAL_NAME (sym),
block, VAR_DOMAIN,
(int *) NULL);
Unfortunately, it tries using the natural name, which doesn't always
work for Ada parameters, in particular those who are internally-
generated. In our case, The "_task" parameter's natural name is
"<_task>", and that symbol does not exist. So sym2 is NULL, thus
causing the crash a little later on when trying to dereference it.
We should be using the symbol linkage name in this case, the same
way iterate_over_block_arg_vars already does.
gdb/ChangeLog:
* mi/mi-cmd-stack.c (list_args_or_locals): For argument symbols,
use SYMBOL_LINKAGE_NAME to find the corresponding non-argument
symbol. Add assertion that sym2 is never NULL.
gdb/testsuite/ChangeLog:
* gdb.ada/mi_task_arg: New testcase.
2012-02-03 15:32:40 +08:00
|
|
|
if ![mi_runto "task_switch.break_me"] then {
|
2016-12-02 04:40:05 +08:00
|
|
|
fail "cannot run to main, testcase aborted"
|
GDB/MI: crash printing "_task" (Ada) argument
In GDB/MI mode, trying to print the arguments of the frame corresponding
to the body of a task ("-stack-list-arguments 1") causes the debugger to
crash.
This is because the compiler adds an implicit argument to that task body
called "_task". mi/mi-cmd-stack.c:list_args_or_locals, which is
responsible for printing the value of our arguments, finds that our
"_task" symbol is an argument, and thus tries to fing the non-argument
equivalent:
if (SYMBOL_IS_ARGUMENT (sym))
sym2 = lookup_symbol (SYMBOL_NATURAL_NAME (sym),
block, VAR_DOMAIN,
(int *) NULL);
Unfortunately, it tries using the natural name, which doesn't always
work for Ada parameters, in particular those who are internally-
generated. In our case, The "_task" parameter's natural name is
"<_task>", and that symbol does not exist. So sym2 is NULL, thus
causing the crash a little later on when trying to dereference it.
We should be using the symbol linkage name in this case, the same
way iterate_over_block_arg_vars already does.
gdb/ChangeLog:
* mi/mi-cmd-stack.c (list_args_or_locals): For argument symbols,
use SYMBOL_LINKAGE_NAME to find the corresponding non-argument
symbol. Add assertion that sym2 is never NULL.
gdb/testsuite/ChangeLog:
* gdb.ada/mi_task_arg: New testcase.
2012-02-03 15:32:40 +08:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
# Verify that "-stack-list-arguments" does not cause the debugger to
|
|
|
|
# crash when printing the arguments of frame 1 (due to the internally-
|
|
|
|
# generated argument "_task").
|
2019-10-15 08:21:37 +08:00
|
|
|
# Frame for task_switch.break_me
|
|
|
|
set frame0 "frame=\{level=\"0\",args=\\\[\\\]\}"
|
|
|
|
# Frame for task_switch.caller
|
[gdb/testsuite] Fix gdb.ada/mi_task_arg.exp for -m32
When running test-case gdb.ada/mi_task_arg.exp with target board unix/-m32, I
run into:
...
(gdb) ^M
Expecting: ^(-stack-list-arguments 1[^M
]+)?(\^done,stack-args=\[ \
frame={level="0",args=\[\]}, \
frame={level="1",args=\[{name="<_task>",value="0x[0-9A-Fa-f]+"}\]}, \
frame={level="2",args=\[({name="self_id",value="0x[0-9A-Fa-f]+"})?\]},.*[^M
]+[(]gdb[)] ^M
[ ]*)
-stack-list-arguments 1^M
^done,stack-args=[ \
frame={level="0",args=[]}, \
frame={level="1",args=[{name="<_task>",value="0x808abf0"}]}, \
frame={level="2",args=[{name="self_id",value="<optimized out>"}]}, \
frame={level="3",args=[]},frame={level="4",args=[]}]^M
(gdb) ^M
FAIL: gdb.ada/mi_task_arg.exp: -stack-list-arguments 1 (unexpected output)
...
The problem is that we're expecting a $hex for the value of self_id, but
instead get <optimized out>.
Looking at the debug info for self_id:
...
<1><12a1f>: Abbrev Number: 84 (DW_TAG_subprogram)
<12a20> DW_AT_name : system__tasking__stages__task_wrapper
...
<2><12a35>: Abbrev Number: 61 (DW_TAG_formal_parameter)
<12a36> DW_AT_name : self_id
<12a40> DW_AT_location : 0x459e (location list)
...
it refers to location information here:
...
0000459e 08053060 080531ac (DW_OP_fbreg: 0)
000045aa 0805327c 080532a5 (DW_OP_fbreg: 0)
000045b6 08053320 08053324 (DW_OP_fbreg: 0)
...
while the pc used to retrieve the location information is 0x080531c5:
...
$ gdb -batch outputs/gdb.ada/mi_task_arg/task_switch \
-ex "break 57" -ex run -ex bt
...
#0 task_switch.break_me () at task_switch.adb:57
#1 0x0804aaae in task_switch.caller (<_task>=0x808abf0) \
at task_switch.adb:51
#2 0x080531c5 in system.tasking.stages.task_wrapper \
(self_id=<optimized out>) at s-tassta.adb:1295
...
which indeed falls outside of the ranges listed in the location info.
Fix this by accepting <optimized out> as valid value of self_id.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-12-08 Tom de Vries <tdevries@suse.de>
* gdb.ada/mi_task_arg.exp: Accept <optimized out> as valid value of
self_id.
2020-12-08 16:29:40 +08:00
|
|
|
set frame1_args "\{name=\"<_task>\",value=\"$hex\"\}"
|
|
|
|
set frame1 "frame=\{level=\"1\",args=\\\[$frame1_args\\\]\}"
|
2019-10-15 08:21:37 +08:00
|
|
|
# Frame for system.tasking.stages.task_wrapper
|
[gdb/testsuite] Fix gdb.ada/mi_task_arg.exp for -m32
When running test-case gdb.ada/mi_task_arg.exp with target board unix/-m32, I
run into:
...
(gdb) ^M
Expecting: ^(-stack-list-arguments 1[^M
]+)?(\^done,stack-args=\[ \
frame={level="0",args=\[\]}, \
frame={level="1",args=\[{name="<_task>",value="0x[0-9A-Fa-f]+"}\]}, \
frame={level="2",args=\[({name="self_id",value="0x[0-9A-Fa-f]+"})?\]},.*[^M
]+[(]gdb[)] ^M
[ ]*)
-stack-list-arguments 1^M
^done,stack-args=[ \
frame={level="0",args=[]}, \
frame={level="1",args=[{name="<_task>",value="0x808abf0"}]}, \
frame={level="2",args=[{name="self_id",value="<optimized out>"}]}, \
frame={level="3",args=[]},frame={level="4",args=[]}]^M
(gdb) ^M
FAIL: gdb.ada/mi_task_arg.exp: -stack-list-arguments 1 (unexpected output)
...
The problem is that we're expecting a $hex for the value of self_id, but
instead get <optimized out>.
Looking at the debug info for self_id:
...
<1><12a1f>: Abbrev Number: 84 (DW_TAG_subprogram)
<12a20> DW_AT_name : system__tasking__stages__task_wrapper
...
<2><12a35>: Abbrev Number: 61 (DW_TAG_formal_parameter)
<12a36> DW_AT_name : self_id
<12a40> DW_AT_location : 0x459e (location list)
...
it refers to location information here:
...
0000459e 08053060 080531ac (DW_OP_fbreg: 0)
000045aa 0805327c 080532a5 (DW_OP_fbreg: 0)
000045b6 08053320 08053324 (DW_OP_fbreg: 0)
...
while the pc used to retrieve the location information is 0x080531c5:
...
$ gdb -batch outputs/gdb.ada/mi_task_arg/task_switch \
-ex "break 57" -ex run -ex bt
...
#0 task_switch.break_me () at task_switch.adb:57
#1 0x0804aaae in task_switch.caller (<_task>=0x808abf0) \
at task_switch.adb:51
#2 0x080531c5 in system.tasking.stages.task_wrapper \
(self_id=<optimized out>) at s-tassta.adb:1295
...
which indeed falls outside of the ranges listed in the location info.
Fix this by accepting <optimized out> as valid value of self_id.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-12-08 Tom de Vries <tdevries@suse.de>
* gdb.ada/mi_task_arg.exp: Accept <optimized out> as valid value of
self_id.
2020-12-08 16:29:40 +08:00
|
|
|
set frame2_args "(\{name=\"self_id\",value=\"($hex|<optimized out>)\"\})?"
|
|
|
|
set frame2 "frame=\{level=\"2\",args=\\\[$frame2_args\\\]\}"
|
GDB/MI: crash printing "_task" (Ada) argument
In GDB/MI mode, trying to print the arguments of the frame corresponding
to the body of a task ("-stack-list-arguments 1") causes the debugger to
crash.
This is because the compiler adds an implicit argument to that task body
called "_task". mi/mi-cmd-stack.c:list_args_or_locals, which is
responsible for printing the value of our arguments, finds that our
"_task" symbol is an argument, and thus tries to fing the non-argument
equivalent:
if (SYMBOL_IS_ARGUMENT (sym))
sym2 = lookup_symbol (SYMBOL_NATURAL_NAME (sym),
block, VAR_DOMAIN,
(int *) NULL);
Unfortunately, it tries using the natural name, which doesn't always
work for Ada parameters, in particular those who are internally-
generated. In our case, The "_task" parameter's natural name is
"<_task>", and that symbol does not exist. So sym2 is NULL, thus
causing the crash a little later on when trying to dereference it.
We should be using the symbol linkage name in this case, the same
way iterate_over_block_arg_vars already does.
gdb/ChangeLog:
* mi/mi-cmd-stack.c (list_args_or_locals): For argument symbols,
use SYMBOL_LINKAGE_NAME to find the corresponding non-argument
symbol. Add assertion that sym2 is never NULL.
gdb/testsuite/ChangeLog:
* gdb.ada/mi_task_arg: New testcase.
2012-02-03 15:32:40 +08:00
|
|
|
mi_gdb_test "-stack-list-arguments 1" \
|
2019-10-15 08:21:37 +08:00
|
|
|
"\\^done,stack-args=\\\[$frame0,$frame1,$frame2,.*" \
|
GDB/MI: crash printing "_task" (Ada) argument
In GDB/MI mode, trying to print the arguments of the frame corresponding
to the body of a task ("-stack-list-arguments 1") causes the debugger to
crash.
This is because the compiler adds an implicit argument to that task body
called "_task". mi/mi-cmd-stack.c:list_args_or_locals, which is
responsible for printing the value of our arguments, finds that our
"_task" symbol is an argument, and thus tries to fing the non-argument
equivalent:
if (SYMBOL_IS_ARGUMENT (sym))
sym2 = lookup_symbol (SYMBOL_NATURAL_NAME (sym),
block, VAR_DOMAIN,
(int *) NULL);
Unfortunately, it tries using the natural name, which doesn't always
work for Ada parameters, in particular those who are internally-
generated. In our case, The "_task" parameter's natural name is
"<_task>", and that symbol does not exist. So sym2 is NULL, thus
causing the crash a little later on when trying to dereference it.
We should be using the symbol linkage name in this case, the same
way iterate_over_block_arg_vars already does.
gdb/ChangeLog:
* mi/mi-cmd-stack.c (list_args_or_locals): For argument symbols,
use SYMBOL_LINKAGE_NAME to find the corresponding non-argument
symbol. Add assertion that sym2 is never NULL.
gdb/testsuite/ChangeLog:
* gdb.ada/mi_task_arg: New testcase.
2012-02-03 15:32:40 +08:00
|
|
|
"-stack-list-arguments 1"
|
|
|
|
|