binutils-gdb/gdb/testsuite/gdb.multi
Pedro Alves 6300088845 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.
2016-07-01 11:25:58 +01:00
..
base.exp Add a new $_inferior convenience variable 2016-01-13 10:56:05 +00:00
bkpt-multi-exec.c [testsuite] Remove BASEDIR 2016-02-04 15:46:37 +00:00
bkpt-multi-exec.exp [testsuite] Remove BASEDIR 2016-02-04 15:46:37 +00:00
crashme.c
dummy-frame-restore.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
dummy-frame-restore.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
goodbye.c Fix gdb.multi/base.exp testsuite regression 2016-01-08 20:07:02 +01:00
hangout.c Fix gdb.multi/base.exp testsuite regression 2016-01-08 20:07:02 +01:00
hello.c Fix gdb.multi/base.exp testsuite regression 2016-01-08 20:07:02 +01:00
info-threads.exp Per-inferior/Inferior-qualified thread IDs 2016-01-13 10:59:43 +00:00
multi-arch-exec.c [testsuite] Remove BASEDIR 2016-02-04 15:46:37 +00:00
multi-arch-exec.exp [testsuite] Remove BASEDIR 2016-02-04 15:46:37 +00:00
multi-arch.exp Reapply: List inferiors/threads/pspaces in ascending order 2016-01-12 01:12:38 +00:00
multi-attach.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
multi-attach.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
tids.c Per-inferior/Inferior-qualified thread IDs 2016-01-13 10:59:43 +00:00
tids.exp Star wildcard ranges (e.g., "info thread 2.*") 2016-01-15 21:46:23 +00:00
watchpoint-multi-exit.c Forget watchpoint locations when inferior exits or is killed/detached 2016-07-01 11:25:58 +01:00
watchpoint-multi-exit.exp Forget watchpoint locations when inferior exits or is killed/detached 2016-07-01 11:25:58 +01:00
watchpoint-multi.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
watchpoint-multi.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00