Fix GDB crash when registers cannot be modified.
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sat, 13 Apr 2019 08:22:41 +0000 (10:22 +0200)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sat, 20 Apr 2019 13:37:45 +0000 (15:37 +0200)
commitf2ae8bc88390f91cca8531823db51a8e35f0a0a0
tree594a7dd4f714827d016216bb852dbf8a7208ba14
parent4884b57f24fca3d3abf73515e09a3917ed4f356c
Fix GDB crash when registers cannot be modified.

This crash was detected when using GDB with the valgrind gdbserver.
To reproduce:

valgrind sleep 10000

In another window:
gdb
target remote | vgdb
p printf("make sleep print something\n")
=>
terminate called after throwing an instance of 'gdb_exception_error'
Aborted

The problem is that the valgrind gdbserver does not allow to change
registers when the inferior is blocked in a system call.
GDB then raises an exception.  The exception causes the destructor
of
 typedef std::unique_ptr<infcall_suspend_state, infcall_suspend_state_deleter>
    infcall_suspend_state_up;
to be called.  This destructor itself tries to restore the value of
the registers, and fails similarly.  We must catch the exception in
the destructor to avoid crashing GDB.
If the destructor encounters a problem, no warning is produced if
there is an uncaught exception, as in this case, the user will already
be informed of a problem via this exception.

With this change, no crash anymore, and all the valgrind 3.15 tests
pass succesfully.

gdb/ChangeLog
2019-04-19  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* inferior.h (struct infcall_suspend_state_deleter):
Catch exception in destructor to avoid crash.
gdb/ChangeLog
This page took 0.024752 seconds and 4 git commands to generate.