Fix breakpoints on file reloads for PIE binaries
authorAlan Hayward <alan.hayward@arm.com>
Wed, 7 Aug 2019 16:23:49 +0000 (18:23 +0200)
committerTom de Vries <tdevries@suse.de>
Wed, 7 Aug 2019 16:23:49 +0000 (18:23 +0200)
commit7e38ddcb2e86101f4dd0045dd8b204f8913c7946
treebf81fe7bfecb86130b70f3640a2b2d07424982f4
parent3b752ac2e6e7ba7306528b3affaa3c364e30044b
Fix breakpoints on file reloads for PIE binaries

[ Backport of master commit ea142fbfc9. ]

When a binary is built using PIE, reloading the file will cause GDB to error
on restart.  For example:
gdb ./a.out
(gdb) break main
(gdb) run
(gdb) file ./a.out
(gdb) continue

Will cause GDB to error with:
Continuing.
Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0x9e0
Command aborted.

This is due to the symbol offsets not being relocated after reloading the file.

Fix is to ensure solib_create_inferior_hook is called, in the same manner as
infrun.c:follow_exec().

Expand the idempotent test to cover PIE scenarios.

gdb/ChangeLog:

* symfile.c (symbol_file_command): Call solib_create_inferior_hook.

gdb/testsuite/ChangeLog:

* gdb.base/break-idempotent.exp: Test both PIE and non PIE.
gdb/ChangeLog
gdb/symfile.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/break-idempotent.exp