Fix breakpoints on file reloads for PIE binaries
authorAlan Hayward <alan.hayward@arm.com>
Mon, 8 Jul 2019 09:00:25 +0000 (10:00 +0100)
committerAlan Hayward <alan.hayward@arm.com>
Mon, 8 Jul 2019 09:13:46 +0000 (10:13 +0100)
commitea142fbfc9c1708a83d3532257d6728e1f5c142e
treef352e1434244ad934830c0a0fc50ea63e835a9ae
parent62a47958bd6e3cbd909c2f19cd4669a9670ce4f1
Fix breakpoints on file reloads for PIE binaries

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
This page took 0.025397 seconds and 4 git commands to generate.