[gdb/testsuite] Fix gdb.dwarf2/locexpr-data-member-location.exp with nopie
authorTom de Vries <tdevries@suse.de>
Fri, 6 May 2022 02:51:43 +0000 (04:51 +0200)
committerTom de Vries <tdevries@suse.de>
Fri, 6 May 2022 02:51:43 +0000 (04:51 +0200)
commit2899c914f476b549280167e8c52067c4422916b5
tree89cdb0cd0192bb24a20c4e7b364e79aebd022cf5
parent2392dc0f8e243a4f5f9d0db6cee64a1698886e56
[gdb/testsuite] Fix gdb.dwarf2/locexpr-data-member-location.exp with nopie

When running test-case gdb.dwarf2/locexpr-data-member-location.exp with
target board unix/-fno-PIE/-no-pie/-m32 I run into:
...
(gdb) step^M
26        return 0;^M
(gdb) FAIL: gdb.dwarf2/locexpr-data-member-location.exp: step into foo
...

The problem is that the test-case tries to mimic some gdb_compile_shlib
behaviour using:
...
set flags {additional_flags=-fpic debug}
get_func_info foo $flags
...
but this doesn't work with the target board setting, because we end up doing:
...
gcc locexpr-data-member-location-lib.c -fpic -g -lm -fno-PIE -no-pie -m32 \
  -o func_addr23029.x
...
while gdb_compile_shlib properly filters out the -fno-PIE -no-pie.

Consequently, the address for foo determined by get_func_info doesn't match
the actual address of foo.

Fix this by printing the address of foo using the result of gdb_compile_shlib.
gdb/testsuite/gdb.dwarf2/locexpr-data-member-location-lib.c
gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp
gdb/testsuite/lib/dwarf.exp