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 Tom de Vries <tdevries@suse.de>
+
+ * gdb.ada/mi_task_arg.exp: Accept <optimized out> as valid value of
+ self_id.
+
2020-12-07 Pedro Alves <pedro@palves.net>
* gdb.base/break-on-linker-gcd-function.exp: Remove unused
# Frame for task_switch.break_me
set frame0 "frame=\{level=\"0\",args=\\\[\\\]\}"
# Frame for task_switch.caller
-set frame1 "frame=\{level=\"1\",args=\\\[\{name=\"<_task>\",value=\"$hex\"\}\\\]\}"
+set frame1_args "\{name=\"<_task>\",value=\"$hex\"\}"
+set frame1 "frame=\{level=\"1\",args=\\\[$frame1_args\\\]\}"
# Frame for system.tasking.stages.task_wrapper
-set frame2 "frame=\{level=\"2\",args=\\\[(\{name=\"self_id\",value=\"$hex\"\})?\\\]\}"
+set frame2_args "(\{name=\"self_id\",value=\"($hex|<optimized out>)\"\})?"
+set frame2 "frame=\{level=\"2\",args=\\\[$frame2_args\\\]\}"
mi_gdb_test "-stack-list-arguments 1" \
"\\^done,stack-args=\\\[$frame0,$frame1,$frame2,.*" \
"-stack-list-arguments 1"