aboutsummaryrefslogtreecommitdiff
path: root/gdb/breakpoint.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/breakpoint.c
parent0f48b757071509040d800ff9f7c8726e5828bd1a (diff)
downloadgdb-630008884535a5b26828325e48e729034c110536.zip
gdb-630008884535a5b26828325e48e729034c110536.tar.gz
gdb-630008884535a5b26828325e48e729034c110536.tar.bz2
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/breakpoint.c')
-rw-r--r--gdb/breakpoint.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 93dfba6..0b29a8a 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -4204,15 +4204,25 @@ breakpoint_init_inferior (enum inf_context context)
/* Likewise for watchpoints on local expressions. */
if (w->exp_valid_block != NULL)
delete_breakpoint (b);
- else if (context == inf_starting)
+ else
{
- /* Reset val field to force reread of starting value in
- insert_breakpoints. */
- if (w->val)
- value_free (w->val);
- w->val = NULL;
- w->val_valid = 0;
- }
+ /* Get rid of existing locations, which are no longer
+ valid. New ones will be created in
+ update_watchpoint, when the inferior is restarted.
+ The next update_global_location_list call will
+ garbage collect them. */
+ b->loc = NULL;
+
+ if (context == inf_starting)
+ {
+ /* Reset val field to force reread of starting value in
+ insert_breakpoints. */
+ if (w->val)
+ value_free (w->val);
+ w->val = NULL;
+ w->val_valid = 0;
+ }
+ }
}
break;
default: