gdb/testsuite: make gdb.ada/mi_prot.exp stop at expected location
authorSimon Marchi <simon.marchi@polymtl.ca>
Thu, 14 Apr 2022 16:26:33 +0000 (12:26 -0400)
committerSimon Marchi <simon.marchi@polymtl.ca>
Mon, 18 Apr 2022 14:28:25 +0000 (10:28 -0400)
commitc67f4e53895da91ce7f2eff3544e9de02280f740
tree6ee4302b25889dbe8d877610c1c3ea6109bd73f9
parent2bb8c72b39f4dcce0be292b2c701edbe4dd4ca7c
gdb/testsuite: make gdb.ada/mi_prot.exp stop at expected location

This test attempts to run until the line marked "STOP", which is at
prot.adb:34.  It first runs until the "main" symbol, then tries to place
a breakpoint by line at line 34, without specifying the source file.  When looking at the logs:

    -break-insert -t 34^M
    ^done,bkpt={number="2",type="breakpoint",disp="del",enabled="y",addr="0x0000555555558a6c",func="adafinal",file="/home/simark/build/binutils-gdb-one-target/gdb/testsuite/outputs/gdb.ada/mi_pro    t/b~prot.adb",fullname="/home/simark/build/binutils-gdb-one-target/gdb/testsuite/outputs/gdb.ada/mi_prot/b~prot.adb",line="44",thread-groups=["i1"],times="0",original-location="/home/simark/b    uild/binutils-gdb-one-target/gdb/testsuite/outputs/gdb.ada/mi_prot/b~prot.adb:34"}^M
    ... continues ...
     *stopped,reason="breakpoint-hit",disp="del",bkptno="2",frame={addr="0x0000555555558a6c",func="adafinal",args=[],file="/home/simark/build/binutils-gdb-one-target/gdb/testsuite/outputs/gdb.ada/    mi_prot/b~prot.adb",fullname="/home/simark/build/binutils-gdb-one-target/gdb/testsuite/outputs/gdb.ada/mi_prot/b~prot.adb",line="44",arch="i386:x86-64"},thread-id="1",stopped-threads="all",co    re="8"^M

... we see that the breakpoint is placed in some generated file, not in
the test source file as we expect.  The problem is that "b main" in Ada
does not place a breakpoint on the "Ada main", but on some symbol in a
generated source file.  So when stopped at the "main" symbol, we are not
stopped in the file that contains the STOP marker at line 34.

The test passes anyway today, so it doesn't seem to matter that we are
stopped at an unexpected location.  But it starts failing with this
patch [1], because b~prot.adb:34 happens to be between two functions, so
the breakpoint doesn't resolve.

Fix this by placing the breakpoint at "$srcfile:$line", which works
regardless of what is the current source file.

However, this ends up introducing a path in the test name.  Modify
mi_tbreak and mi_continue_to_line to avoid that.

[1] https://sourceware.org/pipermail/gdb-patches/2022-April/187686.html

Change-Id: I742e2a9993046dcb5e30c64fe2ad920a363baf75
gdb/testsuite/gdb.ada/mi_prot.exp
gdb/testsuite/lib/mi-support.exp