[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#862858: gcc-6.3.0 produces binary that gdb cannot automatically reload when it changes



Upon further investigation, the bug I encountered is rather with gdb than
gcc.

gdb does not seem to cope very well with position-independent
executables. Reloading a PIE file gets the entry point wrong.

Example below. Notice how the first time gdb seems a PIE executable (when
a.out has gone PIE compared to the previous one which wasn't), things go
well. Problem is on the second load.

cassoulet /tmp $ gdb 
GNU gdb (Debian 7.12-6) 7.12.0.20161007-git
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) shell gcc-6 -W -Wall -g -no-pie a.c
(gdb) file a.out
Reading symbols from a.out...done.
(gdb) b a
Breakpoint 1 at 0x4004fa: file a.c, line 5.
(gdb) r
Starting program: /tmp/a.out 

Breakpoint 1, a () at a.c:5
5           printf("Hello, world\n");
(gdb) shell gcc-6 -W -Wall -g -no-pie a.c
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
`/tmp/a.out' has changed; re-reading symbols.
Starting program: /tmp/a.out 

Breakpoint 1, a () at a.c:5
5           printf("Hello, world\n");
(gdb) shell gcc-6 -W -Wall -g -fPIE -pie a.c
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
`/tmp/a.out' has changed; re-reading symbols.
Starting program: /tmp/a.out 

Breakpoint 1, a () at a.c:5
5           printf("Hello, world\n");
(gdb) shell gcc-6 -W -Wall -g -fPIE -pie a.c
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
`/tmp/a.out' has changed; re-reading symbols.
Error in re-setting breakpoint 1: Cannot access memory at address 0x5555555546b0
Starting program: /tmp/a.out 
Hello, world
[Inferior 1 (process 24316) exited normally]
(gdb) 


E.


Reply to: