binutils-gdb/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location-lib.c
Tom de Vries 2899c914f4 [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.
2022-05-06 04:51:43 +02:00

36 lines
1.1 KiB
C

/* Copyright (C) 2021-2022 Free Software Foundation, Inc.
This file is part of GDB.
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 "locexpr-data-member-location.h"
struct A g_A = {3, 4};
struct B g_B = { {8, 9}, 10, 11 };
B *
foo ()
{ /* foo prologue */
asm ("foo_label: .globl foo_label");
return &g_B; /* foo return */
} /* foo end */
B *
bar (B *v)
{ /* bar prologue */
asm ("bar_label: .globl bar_label");
return v; /* bar return */
} /* bar end */