2011-05-24 Pedro Alves <pedro@codesourcery.com>
authorPedro Alves <palves@redhat.com>
Tue, 24 May 2011 15:03:30 +0000 (15:03 +0000)
committerPedro Alves <palves@redhat.com>
Tue, 24 May 2011 15:03:30 +0000 (15:03 +0000)
gdb/
* breakpoint.c (watchpoint_check): If the watchpoint went out of
scope, clear its command list.
(map_breakpoint_numbers): Don't walk the related breakpoints list
of each breakpoint.

gdb/testsuite/
* gdb.base/commands.exp (watchpoint_command_test): Check that the
watchpoint's command list didn't execute when the watchpoint went
out of scope.

gdb/ChangeLog
gdb/breakpoint.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/commands.exp

index 4a2e64bec1207215e957488d153e5cfda1707fe7..35012d2243bbdb772f8f2dadbbc4d185653e653b 100644 (file)
@@ -1,3 +1,10 @@
+2011-05-24  Pedro Alves  <pedro@codesourcery.com>
+
+       * breakpoint.c (watchpoint_check): If the watchpoint went out of
+       scope, clear its command list.
+       (map_breakpoint_numbers): Don't walk the related breakpoints list
+       of each breakpoint.
+
 2011-05-24  Tom Tromey  <tromey@redhat.com>
 
        * MAINTAINERS: Move Jim Blandy to past maintainers.
index c1e00136bb9d32fa76a32fc208f6229aae03b75a..1da1f9c96bfddc7b23af08e250189ec3dd5136d6 100644 (file)
@@ -3866,6 +3866,8 @@ watchpoint_check (void *p)
                   " deleted because the program has left the block in\n\
 which its expression is valid.\n");     
 
+      /* Make sure the watchpoint's commands aren't executed.  */
+      decref_counted_command_line (&b->commands);
       watchpoint_del_at_next_stop (b);
 
       return WP_DELETED;
@@ -11585,25 +11587,8 @@ map_breakpoint_numbers (char *args, void (*function) (struct breakpoint *,
          ALL_BREAKPOINTS_SAFE (b, tmp)
            if (b->number == num)
              {
-               struct breakpoint *related_breakpoint;
-
                match = 1;
-               related_breakpoint = b;
-               do
-                 {
-                   struct breakpoint *next_related_b;
-
-                   /* FUNCTION can be also delete_breakpoint.  */
-                   next_related_b = related_breakpoint->related_breakpoint;
-                   function (related_breakpoint, data);
-
-                   /* For delete_breakpoint of the last entry of the ring we
-                      were traversing we would never get back to B.  */
-                   if (next_related_b == related_breakpoint)
-                     break;
-                   related_breakpoint = next_related_b;
-                 }
-               while (related_breakpoint != b);
+               function (b, data);
                break;
              }
          if (match == 0)
index fad1f652575a22967691c6cb60c1ef10a7083318..0c2a6aa46b38293ff513a3288be5929b6fa343fc 100644 (file)
@@ -1,3 +1,9 @@
+2011-05-24  Pedro Alves  <pedro@codesourcery.com>
+
+       * gdb.base/commands.exp (watchpoint_command_test): Check that the
+       watchpoint's command list didn't execute when the watchpoint went
+       out of scope.
+
 2011-05-24  Pierre Muller  <muller@ics.u-strasbg.fr>
 
        Centralize -DSYMBOL_PREFIX=\"_\" additional flags in gdb.exp.
@@ -30,7 +36,6 @@
 
        Cope with async mode.
 
-       gdb/testsuite/
        * gdb.mi/mi-break.exp (test_breakpoint_commands): Split gdb_test
        into gdb_test + mi_expect_stop.
 
index a0ac25ba269b1fdd9fd6d9c469ea0f94f1850a1a..fb9cf4e9d5d1b5191c6723e174246489b06de6fd 100644 (file)
@@ -294,6 +294,9 @@ proc watchpoint_command_test {} {
            pass "begin commands on watch"
        }
     }
+    # See the 'No symbol "value...' fail below.  This command will
+    # fail if it's executed in the wrong frame.  If adjusting the
+    # test, make sure this property holds.
     gdb_test_multiple "print value" "add print command to watch" {
        -re ">$" {
            pass "add print command to watch"
@@ -308,9 +311,18 @@ proc watchpoint_command_test {} {
        "" \
        "end commands on watch"
 
-    gdb_test "continue" \
-       "Continuing.*\[Ww\]atchpoint $wp_id deleted because the program has left the block in.*which its expression is valid.*run.c:(57|82).*" \
-       "continue with watch"
+    set test "continue with watch"
+    gdb_test_multiple "continue" "$test" {
+       -re "No symbol \"value\" in current context.\r\n$gdb_prompt $" {
+           # Happens if GDB actually runs the watchpoints commands,
+           # even though the watchpoint was deleted for not being in
+           # scope.
+           fail $test
+       }
+       -re "Continuing.*\[Ww\]atchpoint $wp_id deleted because the program has left the block in.*which its expression is valid.*run.c:(57|82).*$gdb_prompt $" {
+           pass $test
+       }
+   }
 }
 
 proc test_command_prompt_position {} {