gdb/
authorPedro Alves <palves@redhat.com>
Thu, 1 Apr 2010 14:11:24 +0000 (14:11 +0000)
committerPedro Alves <palves@redhat.com>
Thu, 1 Apr 2010 14:11:24 +0000 (14:11 +0000)
* breakpoint.c (multi_start, multi_end, last_was_multi): Delete.
(prev_breakpoint_count): New.
(set_breakpoint_count): Adjust.
(rbreak_start_breakpoint_count): New.
(start_rbreak_breakpoints): Adjust.
(end_rbreak_breakpoints): Adjust.
(struct commands_info) <arg>: New field.
(do_map_commands_command): Tweak output to include breakpoint spec
range.
(commands_command_1): Adjust.  Avoid setting an xfree cleanup if
ARG was empty on entry.  Set INFO's arg.
(create_breakpoint): Adjust.

* NEWS: Clarify `commands' changes.

gdb/doc/
* gdb.texinfo (Break Commands): Clarify `commands' changes, and
add cross reference.

gdb/testsuite/
* gdb.base/commands.exp: Adjust.
* gdb.cp/extern-c.exp: Adjust.

gdb/ChangeLog
gdb/NEWS
gdb/breakpoint.c
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/commands.exp
gdb/testsuite/gdb.cp/extern-c.exp

index b29508e0d4114c6c3f867a0441e702a00b264d44..a40533cf1b176bf85bb143a7cdc3f276b0ada255 100644 (file)
@@ -1,3 +1,20 @@
+2010-04-01  Pedro Alves  <pedro@codesourcery.com>
+
+       * breakpoint.c (multi_start, multi_end, last_was_multi): Delete.
+       (prev_breakpoint_count): New.
+       (set_breakpoint_count): Adjust.
+       (rbreak_start_breakpoint_count): New.
+       (start_rbreak_breakpoints): Adjust.
+       (end_rbreak_breakpoints): Adjust.
+       (struct commands_info) <arg>: New field.
+       (do_map_commands_command): Tweak output to include breakpoint spec
+       range.
+       (commands_command_1): Adjust.  Avoid setting an xfree cleanup if
+       ARG was empty on entry.  Set INFO's arg.
+       (create_breakpoint): Adjust.
+
+       * NEWS: Clarify `commands' changes.
+
 2010-04-01  Pedro Alves  <pedro@codesourcery.com>
 
        * tracepoint.c: Include stack.h.
index 0d27faaf21c3bef0977aa17d0f3dfa8589ffe985..3d12fbead3ab5eed5842404fdf71bdb1de819766 100644 (file)
--- a/gdb/NEWS
+++ b/gdb/NEWS
   register EAX or 64-bit register RAX.
 
 * The `commands' command now accepts a range of breakpoints to modify.
-  A plain `commands' following an `rbreak' will affect all the
-  breakpoints set by `rbreak'.
+  A plain `commands' following a command that creates multiple
+  breakpoints affects all the breakpoints set by that command.  This
+  applies to breakpoints set by `rbreak', and also applies when a
+  single `break' command creates multiple breakpoints (e.g.,
+  breakpoints on overloaded c++ functions).
 
 * Python scripting
 
index dfd93f89f67b55b3040766d49b361daa0f6a28b2..01ec269323e4591004e1e099c583f2f8fdd67e7f 100644 (file)
@@ -388,13 +388,11 @@ VEC(bp_location_p) *moribund_locations = NULL;
 
 static int breakpoint_count;
 
-/* If the last command to create a breakpoint created multiple
-   breakpoints, this holds the start and end breakpoint numbers.  */
-static int multi_start;
-static int multi_end;
-/* True if the last breakpoint set was part of a group set with a
-   single command, e.g., "rbreak".  */
-static int last_was_multi;
+/* The value of `breakpoint_count' before the last command that
+   created breakpoints.  If the last (break-like) command created more
+   than one breakpoint, then the difference between BREAKPOINT_COUNT
+   and PREV_BREAKPOINT_COUNT is more than one.  */
+static int prev_breakpoint_count;
 
 /* Number of last tracepoint made.  */
 
@@ -412,29 +410,31 @@ breakpoint_enabled (struct breakpoint *b)
 static void
 set_breakpoint_count (int num)
 {
+  prev_breakpoint_count = breakpoint_count;
   breakpoint_count = num;
-  last_was_multi = 0;
   set_internalvar_integer (lookup_internalvar ("bpnum"), num);
 }
 
+/* Used by `start_rbreak_breakpoints' below, to record the current
+   breakpoint count before "rbreak" creates any breakpoint.  */
+static int rbreak_start_breakpoint_count;
+
 /* Called at the start an "rbreak" command to record the first
    breakpoint made.  */
+
 void
 start_rbreak_breakpoints (void)
 {
-  multi_start = breakpoint_count + 1;
+  rbreak_start_breakpoint_count = breakpoint_count;
 }
 
 /* Called at the end of an "rbreak" command to record the last
    breakpoint made.  */
+
 void
 end_rbreak_breakpoints (void)
 {
-  if (breakpoint_count >= multi_start)
-    {
-      multi_end = breakpoint_count;
-      last_was_multi = 1;
-    }
+  prev_breakpoint_count = rbreak_start_breakpoint_count;
 }
 
 /* Used in run_command to zero the hit count when a new run starts. */
@@ -894,9 +894,14 @@ struct commands_info
 {
   /* True if the command was typed at a tty.  */
   int from_tty;
+
+  /* The breakpoint range spec.  */
+  char *arg;
+
   /* Non-NULL if the body of the commands are being read from this
      already-parsed command.  */
   struct command_line *control;
+
   /* The command lines read from the user, or NULL if they have not
      yet been read.  */
   struct counted_command_line *cmd;
@@ -917,12 +922,23 @@ do_map_commands_command (struct breakpoint *b, void *data)
       if (info->control != NULL)
        l = copy_command_lines (info->control->body_list[0]);
       else
+       {
+         struct cleanup *old_chain;
+         char *str;
+
+         str = xstrprintf (_("Type commands for breakpoint(s) %s, one per line."),
+                           info->arg);
 
-       l = read_command_lines (_("Type commands for all specified breakpoints"),
-                               info->from_tty, 1,
-                               (breakpoint_is_tracepoint (b)
-                                ? check_tracepoint_command : 0),
-                               b);
+         old_chain = make_cleanup (xfree, str);
+
+         l = read_command_lines (str,
+                                 info->from_tty, 1,
+                                 (breakpoint_is_tracepoint (b)
+                                  ? check_tracepoint_command : 0),
+                                 b);
+
+         do_cleanups (old_chain);
+       }
 
       info->cmd = alloc_counted_command_line (l);
     }
@@ -955,16 +971,27 @@ commands_command_1 (char *arg, int from_tty, struct command_line *control)
 
   if (arg == NULL || !*arg)
     {
-      if (last_was_multi)
-       arg = xstrprintf ("%d-%d", multi_start, multi_end);
+      if (breakpoint_count - prev_breakpoint_count > 1)
+       arg = xstrprintf ("%d-%d", prev_breakpoint_count + 1, breakpoint_count);
       else if (breakpoint_count > 0)
        arg = xstrprintf ("%d", breakpoint_count);
+      else
+       {
+         /* So that we don't try to free the incoming non-NULL
+            argument in the cleanup below.  Mapping breakpoint
+            numbers will fail in this case.  */
+         arg = NULL;
+       }
     }
   else
     /* The command loop has some static state, so we need to preserve
        our argument.  */
     arg = xstrdup (arg);
-  make_cleanup (xfree, arg);
+
+  if (arg != NULL)
+    make_cleanup (xfree, arg);
+
+  info.arg = arg;
 
   map_breakpoint_numbers (arg, do_map_commands_command, &info);
 
@@ -7239,7 +7266,7 @@ create_breakpoint (struct gdbarch *gdbarch,
   int not_found = 0;
   enum bptype type_wanted;
   int task = 0;
-  int first_bp_set = breakpoint_count + 1;
+  int prev_bkpt_count = breakpoint_count;
 
   sals.sals = NULL;
   sals.nelts = 0;
@@ -7399,9 +7426,7 @@ create_breakpoint (struct gdbarch *gdbarch,
     {
       warning (_("Multiple breakpoints were set.\n"
                 "Use the \"delete\" command to delete unwanted breakpoints."));
-      multi_start = first_bp_set;
-      multi_end = breakpoint_count;
-      last_was_multi = 1;
+      prev_breakpoint_count = prev_bkpt_count;
     }
 
   /* That's it.  Discard the cleanups for data inserted into the
index 5cbd9c5c6f527bdd1bbaeacc778973ec0219cd19..a79215256b964594c363ce46981c47d869e653c3 100644 (file)
@@ -1,3 +1,8 @@
+2010-04-01  Pedro Alves  <pedro@codesourcery.com>
+
+       * gdb.texinfo (Break Commands): Clarify `commands' changes, and
+       add cross reference.
+
 2010-03-31  Pedro Alves  <pedro@codesourcery.com>
 
        * gdb.texinfo (TUI Commands): Mention that in some cases, these
index c9b1d08f31b6bac5b808ef3d4deabd3890c62977..5e02172850ebe6da46feb679c5750377b941ba53 100644 (file)
@@ -4343,8 +4343,9 @@ watchpoint, or catchpoint set (not to the breakpoint most recently
 encountered).  If the most recent breakpoints were set with a single
 command, then the @code{commands} will apply to all the breakpoints
 set by that command.  This applies to breakpoints set by
-@code{rbreak}, and also breakpoints set with @code{break} that have
-multiple locations.
+@code{rbreak}, and also applies when a single @code{break} command
+creates multiple breakpoints (@pxref{Ambiguous Expressions,,Ambiguous
+Expressions}).
 @end table
 
 Pressing @key{RET} as a means of repeating the last @value{GDBN} command is
index 5f48f55db1b6379839708bac1708fbd9127b9933..61f61931d787a7ae1941206af49745fe560f7636 100644 (file)
@@ -1,3 +1,8 @@
+2010-04-01  Pedro Alves  <pedro@codesourcery.com>
+
+       * gdb.base/commands.exp: Adjust.
+       * gdb.cp/extern-c.exp: Adjust.
+
 2010-04-01  Pedro Alves  <pedro@codesourcery.com>
 
        * gdb.trace/collection.c (local_test_func): Define a local struct,
index ee3d787322b1f0b35379e777ed1cc5727d8797fe..bc81f06a444fba24f5b6aa78e7f1f5d4a9b7a695 100644 (file)
@@ -299,7 +299,7 @@ proc watchpoint_command_test {} {
 
     send_gdb "commands $wp_id\n"
     gdb_expect {
-      -re "Type commands for all specified breakpoints.*>" {
+      -re "Type commands for breakpoint.*, one per line.*>" {
          pass "begin commands on watch"
       }
       -re "$gdb_prompt $" {fail "begin commands on watch"}
@@ -452,7 +452,7 @@ proc bp_deleted_in_command_test {} {
     
     send_gdb "commands\n"
     gdb_expect {
-      -re "Type commands for all specified breakpoints.*>" {
+      -re "Type commands for breakpoint.*>" {
           pass "begin commands in bp_deleted_in_command_test"
       }
       -re "$gdb_prompt $" {fail "begin commands in bp_deleted_in_command_test"}
@@ -519,7 +519,7 @@ proc temporary_breakpoint_commands {} {
     
     send_gdb "commands\n"
     gdb_expect {
-       -re "Type commands for all specified breakpoints.*>" {
+       -re "Type commands for breakpoint.*>" {
            pass "begin commands in bp_deleted_in_command_test"
        }
        -re "$gdb_prompt $" {fail "begin commands in bp_deleted_in_command_test"}
index 5ad4e9c00b678bb9927aaba6d33524d89d3fa59a..275ef2d976cf7803e11e149a757fe07dbcb6bd83 100644 (file)
@@ -48,7 +48,7 @@ gdb_test "rbreak c_funcs" \
 # Test that "commands" without an argument puts commands on both
 # breakpoints.
 gdb_test_multiple "commands" "set commands on multiple breakpoints" {
-  -re "Type commands for all specified breakpoints\r\nEnd with a line saying just \"end\".\r\n>$" {
+  -re "Type commands for breakpoint\\(s\\) 3-4, one per line\.\r\nEnd with a line saying just \"end\".\r\n>$" {
     gdb_test_multiple "set \$counter = \$counter + 1\nend" \
       "command details for multiple breakpoints" {
        -re "$gdb_prompt $" {
This page took 0.080504 seconds and 4 git commands to generate.