Simplify gdb.threads/wp-replication.exp on counting HW watchpoints
authorYao Qi <yao.qi@linaro.org>
Fri, 30 Oct 2015 15:51:33 +0000 (15:51 +0000)
committerYao Qi <yao.qi@linaro.org>
Fri, 30 Oct 2015 15:54:58 +0000 (15:54 +0000)
commit4081c0f1222810746068579c6fbbcd8a9b59cbb8
tree56d33d087007a6d44c27bb0f3f4ae623ebc49ebf
parent10268a4c0d64b3892397aeaafbc4b91f6a1e0dc8
Simplify gdb.threads/wp-replication.exp on counting HW watchpoints

Nowadays, test gdb.threads/wp-replication.exp uses a while loop to
repeatedly insert HW watchpoint, resume and check no error message
coming out, in order to count HW watchpoints  There are some
drawbacks in this way,

 - the loop could be endless.  I think this is use to making trouble
   to S/390, since we had such comment

      # Some targets (like S/390) behave as though supporting
      # unlimited hardware watchpoints.  In this case we just take a
      # safe exit out of the loop.

   I hit this today too because a GDB internal error is triggered
   on "continue" in the loop, and $done is 0 invariantly, so the loop
   can't end.
 - the code counting hardware watchpoint is too complicated.  We can
   use "set breakpoint always-inserted on" to get the result of inserting
   HW watchpoint without resuming the inferior.  In this way,
   watch_count_done and empty_cycle in c file is no longer needed.

In this patch, I change to use "set breakpoint always-inserted on" trick,
and only iterate $NR_THREADS times, to count the HW watchpoint.  In this
way, the loop can't be endless, and GDB doesn't need to resume the inferior.

gdb/testsuite:

2015-10-30  Yao Qi  <yao.qi@linaro.org>

* gdb.threads/wp-replication.c (watch_count_done): Remove.
(empty_cycle): Remove.
(main): Don't call empty_cycle.  Don't use watch_count_done.
* gdb.threads/wp-replication.exp: Don't set breakpoint on
empty_cycle.  Rewrite the code counting HW watchpoints.
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.threads/wp-replication.c
gdb/testsuite/gdb.threads/wp-replication.exp