summaryrefslogtreecommitdiff
path: root/gdb/infcmd.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2016-07-01 11:16:32 +0100
committerPedro Alves <palves@redhat.com>2016-07-01 11:25:58 +0100
commit630008884535a5b26828325e48e729034c110536 (patch)
tree87f9363be7389f7d084ff798d2a1b3a87afde6bd /gdb/infcmd.c
parent0f48b757071509040d800ff9f7c8726e5828bd1a (diff)
Forget watchpoint locations when inferior exits or is killed/detached
If you have two inferiors (or more), set watchpoints in one of the inferiors, and then that inferior exits, until you manually delete the watchpoint (or something forces a breakpoint re-set), you can't resume the other inferior. This is exercised by the test added by this commit. Without the GDB fix, this test fails like this: FAIL: gdb.multi/watchpoint-multi-exit.exp: dispose=kill: continue to marker in inferior 1 FAIL: gdb.multi/watchpoint-multi-exit.exp: dispose=detach: continue to marker in inferior 1 FAIL: gdb.multi/watchpoint-multi-exit.exp: dispose=exit: continue to marker in inferior 1 and gdb.log shows (in all three cases): (gdb) continue Continuing. Warning: Could not insert hardware watchpoint 2. Could not insert hardware breakpoints: You may have requested too many hardware breakpoints/watchpoints. Command aborted. (gdb) FAIL: gdb.multi/watchpoint-multi-exit.exp: dispose=kill: continue to marker in inferior 1 The problem is that GDB doesn't forget about the locations of watchpoints set in the inferior that is now dead. When we try to continue the inferior that is still alive, we reach insert_breakpoint_locations, which has the the loop that triggers the error: /* If we failed to insert all locations of a watchpoint, remove them, as half-inserted watchpoint is of limited use. */ That loop finds locations that are not marked inserted, but which according to should_be_inserted should have been inserted, and so errors out. gdb/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> * breakpoint.c (breakpoint_init_inferior): Discard watchpoint locations. * infcmd.c (detach_command): Call breakpoint_init_inferior. gdb/testsuite/ChangeLog: 2016-07-01 Pedro Alves <palves@redhat.com> * gdb.multi/watchpoint-multi-exit.c: New file. * gdb.multi/watchpoint-multi-exit.exp: New file.
Diffstat (limited to 'gdb/infcmd.c')
-rw-r--r--gdb/infcmd.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index e9dcb46f6e..58ba1cb8d0 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -2998,6 +2998,13 @@ detach_command (char *args, int from_tty)
target_detach (args, from_tty);
+ /* The current inferior process was just detached successfully. Get
+ rid of breakpoints that no longer make sense. Note we don't do
+ this within target_detach because that is also used when
+ following child forks, and in that case we will want to transfer
+ breakpoints to the child, not delete them. */
+ breakpoint_init_inferior (inf_exited);
+
/* If the solist is global across inferiors, don't clear it when we
detach from a single inferior. */
if (!gdbarch_has_global_solist (target_gdbarch ()))