]> Git Repo - binutils.git/commitdiff
Show locno for 'multi location' breakpoint hit msg+conv var $_hit_bbnum $_hit_locno...
authorPhilippe Waroquiers <[email protected]>
Sat, 23 May 2020 20:27:28 +0000 (22:27 +0200)
committerPhilippe Waroquiers <[email protected]>
Sat, 19 Nov 2022 12:38:38 +0000 (13:38 +0100)
This implements the request given in PR breakpoints/12464.

Before this patch, when a breakpoint that has multiple locations is reached,
GDB printed:
  Thread 1 "zeoes" hit Breakpoint 1, some_func () at somefunc1.c:5

This patch changes the message so that bkpt_print_id prints the precise
encountered breakpoint:
  Thread 1 "zeoes" hit Breakpoint 1.2, some_func () at somefunc1.c:5

In mi mode, bkpt_print_id also (optionally) prints a new table field "locno":
  locno is printed when the breakpoint hit has more than one location.
Note that according to the GDB user manual node 'GDB/MI Development and Front
Ends', it is ok to add new fields without changing the MI version.

Also, when a breakpoint is reached, the convenience variables
$_hit_bpnum and $_hit_locno are set to the encountered breakpoint number
and location number.

$_hit_bpnum and $_hit_locno can a.o. be used in the command list of a
breakpoint, to disable the specific encountered breakpoint, e.g.
   disable $_hit_bpnum.$_hit_locno

In case the breakpoint has only one location, $_hit_locno is set to
the value 1, so as to allow a command such as:
  disable $_hit_bpnum.$_hit_locno
to disable the breakpoint even when the breakpoint has only one location.

This also fixes a strange behaviour: when a breakpoint X has only
one location,
  enable|disable X.1
is accepted but transforms the breakpoint in a multiple locations
breakpoint having only one location.

The changes in RFA v4 handle the comments of Tom Tromey:
 - Changed convenience var names from $bkptno/$locno to
   $_hit_bpnum/$_hit_locno.
 - updated the tests and user manual accordingly.
   User manual also explictly describes that $_hit_locno is set to 1
   for a breakpoint with a single location.
 - The variable values are now set in bpstat_do_actions_1 so that
   they are set for silent breakpoints, and when several breakpoints
   are hit at the same time, that the variables are set to the printed
   breakpoint.

The changes in RFA v3 handle the additional comments of Eli:
 GDB/NEW:
  - Use max 80-column
  - Use 'code location' instead of 'location'.
  - Fix typo $bkpno
  - Ensure that disable $bkptno and disable $bkptno.$locno have
    each their explanation inthe example
  - Reworded the 'breakpoint-hit' paragraph.
 gdb.texinfo:
  - Use 'code location' instead of 'location'.
  - Add a note to clarify the distinction between $bkptno and $bpnum.
  - Use @kbd instead of examples with only one command.

Compared to RFA v1, the changes in v2 handle the comments given by
Keith Seitz and Eli Zaretskii:
  - Use %s for the result of paddress
  - Use bkptno_numopt_re instead of 2 different -re cases
  - use C@t{++}
  - Add index entries for $bkptno and $locno
  - Added an example for "locno" in the mi interface
  - Added examples in the Break command manual.

28 files changed:
gdb/NEWS
gdb/ada-lang.c
gdb/break-catch-syscall.c
gdb/break-catch-throw.c
gdb/breakpoint.c
gdb/breakpoint.h
gdb/doc/gdb.texinfo
gdb/testsuite/gdb.ada/bp_inlined_func.exp
gdb/testsuite/gdb.ada/operator_bp.exp
gdb/testsuite/gdb.base/break.exp
gdb/testsuite/gdb.base/condbreak-multi-context.exp
gdb/testsuite/gdb.base/ctxobj.exp
gdb/testsuite/gdb.base/ena-dis-br.exp
gdb/testsuite/gdb.base/foll-exec-mode.exp
gdb/testsuite/gdb.base/pie-fork.exp
gdb/testsuite/gdb.base/step-over-exit.exp
gdb/testsuite/gdb.cp/mb-inline.exp
gdb/testsuite/gdb.cp/mb-templates.exp
gdb/testsuite/gdb.cp/ovldbreak.exp
gdb/testsuite/gdb.gdb/python-helper.exp
gdb/testsuite/gdb.mi/interrupt-thread-group.exp
gdb/testsuite/gdb.mi/user-selected-context-sync.exp
gdb/testsuite/gdb.multi/multi-arch-exec.exp
gdb/testsuite/gdb.multi/run-only-second-inf.exp
gdb/testsuite/gdb.multi/watchpoint-multi-exit.exp
gdb/testsuite/gdb.multi/watchpoint-multi.exp
gdb/testsuite/lib/gdb.exp
gdb/testsuite/lib/mi-support.exp

index 424e5ffd82912968128451f24f6816e67316b7db..dddef6525de80ea27b3b78dd9c638deba2563fd2 100644 (file)
--- a/gdb/NEWS
+++ b/gdb/NEWS
 * New convenience variable $_inferior_thread_count contains the number
   of live threads in the current inferior.
 
+* When a breakpoint with multiple code locations is hit, GDB now prints
+  the code location using the syntax <breakpoint_number>.<location_number>
+  such as in:
+     Thread 1 "zeoes" hit Breakpoint 2.3, some_func () at zeoes.c:8
+
+* When a breakpoint is hit, GDB now sets the convenience variables $_hit_bpnum
+  and $_hit_locno to the hit breakpoint number and code location number.
+  This allows to disable the last hit breakpoint using
+     (gdb) disable $_hit_bpnum
+   or disable only the specific breakpoint code location using
+     (gdb) disable $_hit_bpnum.$_hit_locno
+  These commands can be used inside the command list of a breakpoint to
+  automatically disable the just encountered breakpoint (or the just
+  encountered specific breakpoint code location).
+  When a breakpoint has only one location, $_hit_locno is set to 1 so that
+     (gdb) disable $_hit_bpnum.$_hit_locno
+  and
+     (gdb) disable $_hit_bpnum
+  are both disabling the breakpoint.
+
 * New commands
 
 maintenance set ignore-prologue-end-flag on|off
@@ -152,6 +172,12 @@ GNU/Linux/LoongArch (gdbserver)    loongarch*-*-linux*
 
 GNU/Linux/CSKY (gdbserver) csky*-*linux*
 
+* MI changes
+
+ ** The async record stating the stopped reason 'breakpoint-hit' now
+    contains an optional field locno giving the code location number
+    when the breakpoint has multiple code locations.
+
 * Python API
 
   ** GDB will now reformat the doc string for gdb.Command and
index 383f96bdc451217ad6345fc838567ef39c29a5b9..5054bdb2957210226630b9869e180d2fb03dc96a 100644 (file)
@@ -12356,7 +12356,7 @@ ada_catchpoint::print_it (const bpstat *bs) const
 
   uiout->text (disposition == disp_del
               ? "\nTemporary catchpoint " : "\nCatchpoint ");
-  uiout->field_signed ("bkptno", number);
+  print_num_locno (bs, uiout);
   uiout->text (", ");
 
   /* ada_exception_name_addr relies on the selected frame being the
index 805bb86cee6ff8eead85197943be22b575fd691b..3829d8286f3000c2bbb9d92d3e7c700507983d3c 100644 (file)
@@ -218,7 +218,7 @@ syscall_catchpoint::print_it (const bpstat *bs) const
                                                : EXEC_ASYNC_SYSCALL_RETURN));
       uiout->field_string ("disp", bpdisp_text (b->disposition));
     }
-  uiout->field_signed ("bkptno", b->number);
+  print_num_locno (bs, uiout);
 
   if (last.kind () == TARGET_WAITKIND_SYSCALL_ENTRY)
     uiout->text (" (call to syscall ");
index 6557ee71449e7c13425cf2396607424ced1836b5..0da3cbfb021aadb4a661c63c361f204991d6d949 100644 (file)
@@ -254,7 +254,7 @@ exception_catchpoint::print_it (const bpstat *bs) const
   bp_temp = disposition == disp_del;
   uiout->text (bp_temp ? "Temporary catchpoint "
                       : "Catchpoint ");
-  uiout->field_signed ("bkptno", number);
+  print_num_locno (bs, uiout);
   uiout->text ((kind == EX_EVENT_THROW ? " (exception thrown), "
                : (kind == EX_EVENT_CATCH ? " (exception caught), "
                   : " (exception rethrown), ")));
index 490708938ecd4d6fcd29a9d4d7a35e391d28a68b..7f6400db624583bb239157cd1c9609bd8338501e 100644 (file)
@@ -817,6 +817,19 @@ get_breakpoint (int num)
   return nullptr;
 }
 
+/* Return TRUE if NUM refer to an existing breakpoint that has
+   multiple code locations.  */
+
+static bool
+has_multiple_locations (int num)
+{
+  for (breakpoint *b : all_breakpoints ())
+    if (b->number == num)
+      return b->loc != nullptr && b->loc->next != nullptr;
+
+  return false;
+}
+
 \f
 
 /* Mark locations as "conditions have changed" in case the target supports
@@ -4441,15 +4454,7 @@ bpstat_explains_signal (bpstat *bsp, enum gdb_signal sig)
   return false;
 }
 
-/* Put in *NUM the breakpoint number of the first breakpoint we are
-   stopped at.  *BSP upon return is a bpstat which points to the
-   remaining breakpoints stopped at (but which is not guaranteed to be
-   good for anything but further calls to bpstat_num).
-
-   Return 0 if passed a bpstat which does not indicate any breakpoints.
-   Return -1 if stopped at a breakpoint that has been deleted since
-   we set it.
-   Return 1 otherwise.  */
+/* See breakpoint.h.  */
 
 int
 bpstat_num (bpstat **bsp, int *num)
@@ -4471,6 +4476,57 @@ bpstat_num (bpstat **bsp, int *num)
   return 1;
 }
 
+/* See breakpoint.h  */
+
+int
+bpstat_locno (const bpstat *bs)
+{
+  const struct breakpoint *b = bs->breakpoint_at;
+  const struct bp_location *bl = bs->bp_location_at.get ();
+
+  int locno = 0;
+
+  if (b != nullptr && b->loc->next != nullptr)
+    {
+      const bp_location *bl_i;
+
+      for (bl_i = b->loc;
+          bl_i != bl && bl_i->next != nullptr;
+          bl_i = bl_i->next)
+       locno++;
+
+      if (bl_i == bl)
+       locno++;
+      else
+       {
+         warning (_("location number not found for breakpoint %d address %s."),
+                  b->number, paddress (bl->gdbarch, bl->address));
+         locno = 0;
+       }
+    }
+
+  return locno;
+}
+
+/* See breakpoint.h.  */
+
+void
+print_num_locno (const bpstat *bs, struct ui_out *uiout)
+{
+  struct breakpoint *b = bs->breakpoint_at;
+
+  if (b == nullptr)
+    uiout->text (_("deleted breakpoint"));
+  else
+    {
+      uiout->field_signed ("bkptno", b->number);
+
+      int locno = bpstat_locno (bs);
+      if (locno != 0)
+       uiout->message (".%pF", signed_field ("locno", locno));
+    }
+}
+
 /* See breakpoint.h.  */
 
 void
@@ -4518,6 +4574,20 @@ command_line_is_silent (struct command_line *cmd)
   return cmd && (strcmp ("silent", cmd->line) == 0);
 }
 
+/* Sets the $_hit_bpnum and $_hit_locno to the bpnum and locno of bs.  */
+static void
+set_hit_convenience_vars (bpstat *bs)
+{
+  const struct breakpoint *b = bs->breakpoint_at;
+  if (b != nullptr)
+    {
+      int locno = bpstat_locno (bs);
+      set_internalvar_integer (lookup_internalvar ("_hit_bpnum"), b->number);
+      set_internalvar_integer (lookup_internalvar ("_hit_locno"),
+                              (locno > 0 ? locno : 1));
+    }
+}
+
 /* Execute all the commands associated with all the breakpoints at
    this location.  Any of these commands could cause the process to
    proceed beyond this point, etc.  We look out for such changes by
@@ -4532,6 +4602,7 @@ bpstat_do_actions_1 (bpstat **bsp)
 {
   bpstat *bs;
   bool again = false;
+  bpstat *bs_print_hit_var;
 
   /* Avoid endless recursion if a `source' command is contained
      in bs->commands.  */
@@ -4546,11 +4617,25 @@ bpstat_do_actions_1 (bpstat **bsp)
   /* This pointer will iterate over the list of bpstat's.  */
   bs = *bsp;
 
+  /* The $_hit_* convenience variables are set before running the
+     commands of bs.  In case we have several bs, after the loop,
+     we set again the variables to the first bs to print.  */
+  bs_print_hit_var = nullptr;
+
   breakpoint_proceeded = 0;
   for (; bs != NULL; bs = bs->next)
     {
       struct command_line *cmd = NULL;
 
+      /* Set the _hit_* convenience variables before running the commands of
+        each bs.  If this is the first bs to be printed, remember it so as to
+        set the convenience variable again to this bs after the loop so that in
+        case of multiple breakpoints, the variables are set to the breakpoint
+        printed for the user.  */
+      set_hit_convenience_vars (bs);
+      if (bs_print_hit_var == nullptr && bs->print)
+       bs_print_hit_var = bs;
+
       /* Take ownership of the BSP's command tree, if it has one.
 
         The command tree could legitimately contain commands like
@@ -4606,6 +4691,12 @@ bpstat_do_actions_1 (bpstat **bsp)
          break;
        }
     }
+
+  /* Now that we have executed the commands of all bs, set the _hit_*
+     convenience variables to the printed bs.  */
+  if (bs_print_hit_var != nullptr)
+    set_hit_convenience_vars (bs_print_hit_var);
+
   return again;
 }
 
@@ -4817,7 +4908,7 @@ bpstat_print (bpstat *bs, target_waitkind kind)
     {
       val = print_bp_stop_message (bs);
       if (val == PRINT_SRC_ONLY 
-         || val == PRINT_SRC_AND_LOC 
+         || val == PRINT_SRC_AND_LOC
          || val == PRINT_NOTHING)
        return val;
     }
@@ -9209,7 +9300,7 @@ ranged_breakpoint::print_it (const bpstat *bs) const
                      async_reason_lookup (EXEC_ASYNC_BREAKPOINT_HIT));
       uiout->field_string ("disp", bpdisp_text (disposition));
     }
-  uiout->field_signed ("bkptno", number);
+  print_num_locno (bs, uiout);
   uiout->text (", ");
 
   return PRINT_SRC_AND_LOC;
@@ -11630,12 +11721,13 @@ ordinary_breakpoint::print_it (const bpstat *bs) const
                           async_reason_lookup (EXEC_ASYNC_BREAKPOINT_HIT));
       uiout->field_string ("disp", bpdisp_text (disposition));
     }
+
   if (bp_temp)
-    uiout->message ("Temporary breakpoint %pF, ",
-                   signed_field ("bkptno", number));
+    uiout->text ("Temporary breakpoint ");
   else
-    uiout->message ("Breakpoint %pF, ",
-                   signed_field ("bkptno", number));
+    uiout->text ("Breakpoint ");
+  print_num_locno (bs, uiout);
+  uiout->text (", ");
 
   return PRINT_SRC_AND_LOC;
 }
@@ -13281,9 +13373,13 @@ enable_disable_command (const char *args, int from_tty, bool enable)
          extract_bp_number_and_location (num, bp_num_range, bp_loc_range);
 
          if (bp_loc_range.first == bp_loc_range.second
-             && bp_loc_range.first == 0)
+             && (bp_loc_range.first == 0
+                 || (bp_loc_range.first == 1
+                     && bp_num_range.first == bp_num_range.second
+                     && !has_multiple_locations (bp_num_range.first))))
            {
-             /* Handle breakpoint ids with formats 'x' or 'x-z'.  */
+             /* Handle breakpoint ids with formats 'x' or 'x-z'
+                or 'y.1' where y has only one code location.  */
              map_breakpoint_number_range (bp_num_range,
                                           enable
                                           ? enable_breakpoint
index 360fa760577396ada7bd529890abc1819302eca0..f7633d29cbfd0fc065325d70587e7a853e813006 100644 (file)
@@ -1241,6 +1241,20 @@ extern enum print_stop_action bpstat_print (bpstat *bs, target_waitkind kind);
    Return 1 otherwise.  */
 extern int bpstat_num (bpstat **, int *);
 
+/* If BS indicates a breakpoint and this breakpoint has several code locations,
+   return the location number of BS, otherwise return 0.  */
+
+extern int bpstat_locno (const bpstat *bs);
+
+/* Print BS breakpoint number optionally followed by a . and breakpoint locno.
+
+   For a breakpoint with only one code location, outputs the signed field
+   "bkptno" breakpoint number of BS (as returned by bpstat_num).
+   If BS has several code locations, outputs a '.' character followed by
+   the signed field "locno" (as returned by bpstat_locno).  */
+
+extern void print_num_locno (const bpstat *bs, struct ui_out *);
+
 /* Perform actions associated with the stopped inferior.  Actually, we
    just use this for breakpoint commands.  Perhaps other actions will
    go here later, but this is executed at a late time (from the
index bb7b2764408296a1e884701f5739e01abe80b980..bababf3c7ff862258c3fe68f7f39e5d3524d928d 100644 (file)
@@ -4375,9 +4375,75 @@ are operated on.
 @cindex latest breakpoint
 Breakpoints are set with the @code{break} command (abbreviated
 @code{b}).  The debugger convenience variable @samp{$bpnum} records the
-number of the breakpoint you've set most recently; see @ref{Convenience
-Vars,, Convenience Variables}, for a discussion of what you can do with
-convenience variables.
+number of the breakpoint you've set most recently:
+@smallexample
+(gdb) b main
+Breakpoint 1 at 0x11c6: file zeoes.c, line 24.
+(gdb) p $bpnum
+$1 = 1
+@end smallexample
+
+A breakpoint may be mapped to multiple code locations for example with
+inlined functions, Ada generics, C@t{++} templates or overloaded function names.
+@value{GDBN} then indicates the number of code locations in the breakpoint
+command output:
+@smallexample
+(gdb) b some_func
+Breakpoint 2 at 0x1179: some_func. (3 locations)
+(gdb) p $bpnum
+$2 = 2
+(gdb)
+@end smallexample
+
+@vindex $_hit_bpnum@r{, convenience variable}
+@vindex $_hit_locno@r{, convenience variable}
+When your program stops on a breakpoint, the convenience variables
+@samp{$_hit_bpnum} and @samp{$_hit_locno} are respectively set to the number of
+the encountered breakpoint and the number of the breakpoint's code location:
+@smallexample
+Thread 1 "zeoes" hit Breakpoint 2.1, some_func () at zeoes.c:8
+8        printf("some func\n");
+(gdb) p $_hit_bpnum
+$5 = 2
+(gdb) p $_hit_locno
+$6 = 1
+(gdb)
+@end smallexample
+
+Note that @samp{$_hit_bpnum} and @samp{$bpnum} are not equivalent:
+@samp{$_hit_bpnum} is set to the breakpoint number @b{last hit}, while
+@samp{$bpnum} is set to the breakpoint number @b{last set}.
+
+
+If the encountered breakpoint has only one code location, @samp{$_hit_locno}
+is set to 1:
+@smallexample
+Breakpoint 1, main (argc=1, argv=0x7fffffffe018) at zeoes.c:24
+24       if (argc > 1)
+(gdb) p $_hit_bpnum
+$3 = 1
+(gdb) p $_hit_locno
+$4 = 1
+(gdb)
+@end smallexample
+
+The @samp{$_hit_bpnum} and @samp{$_hit_locno} variables can typically be used
+in a breakpoint command list.
+(@pxref{Break Commands, ,Breakpoint Command Lists}).  For example, as
+part of the breakpoint command list, you can disable completely the
+encountered breakpoint using @kbd{disable $_hit_bpnum} or disable the
+specific encountered breakpoint location using
+@kbd{disable $_hit_bpnum.$_hit_locno}.
+If a breakpoint has only one location, @samp{$_hit_locno} is set to 1
+and the commands @kbd{disable $_hit_bpnum} and
+@kbd{disable $_hit_bpnum.$_hit_locno} both disable the breakpoint.
+
+You can also define aliases to easily disable the last hit location or
+last hit breakpoint:
+@smallexample
+(gdb) alias lld = disable $_hit_bpnum.$_hit_locno
+(gdb) alias lbd = disable $_hit_bpnum
+@end smallexample
 
 @table @code
 @item break @var{locspec}
@@ -5776,6 +5842,14 @@ Expressions}).
 Pressing @key{RET} as a means of repeating the last @value{GDBN} command is
 disabled within a @var{command-list}.
 
+Inside a command list, you can use the command
+@kbd{disable $_hit_bpnum} to disable the encountered breakpoint.
+
+If your breakpoint has several code locations, the command
+@kbd{disable $_hit_bpnum.$_hit_locno} will disable the specific breakpoint
+code location encountered.  If the breakpoint has only one location,
+this command will disable the encountered breakpoint.
+
 You can use breakpoint commands to start your program up again.  Simply
 use the @code{continue} command, or @code{step}, or any other command
 that resumes execution.
@@ -32840,6 +32914,20 @@ line="13",arch="i386:x86_64"@}
 (gdb)
 @end smallexample
 
+For a @samp{breakpoint-hit} stopped reason, when the breakpoint
+encountered has multiple locations, the field @samp{bkptno} is
+followed by the field @samp{locno}.
+
+@smallexample
+-exec-continue
+^running
+(gdb)
+@@Hello world
+*stopped,reason="breakpoint-hit",disp="keep",bkptno="2",locno="3",frame=@{
+func="foo",args=[],file="hello.c",fullname="/home/foo/bar/hello.c",
+line="13",arch="i386:x86_64"@}
+(gdb)
+@end smallexample
 
 @subheading The @code{-exec-finish} Command
 @findex -exec-finish
index 076e8c2425f1b499b7c2702b010477f5c69df448..3f94c1638198dff7fd005f309a6bbd99e828f661 100644 (file)
@@ -42,7 +42,7 @@ gdb_test "break read_small" \
 for {set i 0} {$i < 4} {incr i} {
     with_test_prefix "iteration $i" {
        gdb_test "continue" \
-           "Breakpoint $decimal, b\\.read_small \\(\\).*" \
+           "Breakpoint $bkptno_num_re, b\\.read_small \\(\\).*" \
            "stopped in read_small"
     }
 }
index 655e7af479fc816d2cd7ca1fc57bf055f9440865..e3928419ed6a7d4bbe011c6e2b978c1d6e605022 100644 (file)
@@ -56,7 +56,7 @@ foreach op { "*" "/" "mod" "rem" "**" "<" "<=" ">" ">=" "=" "and" "or" "xor" "&"
 foreach op { "+" "-" "*" "/" "mod" "rem" "**" "<" "<=" ">" ">=" "=" "and" "or" "xor" "&" "abs" "not"} {
     set op_re [string_to_regexp $op]
     gdb_test "continue" \
-             "Breakpoint $decimal, ops\\.\"$op_re\" .*"\
+             "Breakpoint $bkptno_numopt_re, ops\\.\"$op_re\" .*"\
              "continue to \"$op\""
 }
 
@@ -86,7 +86,7 @@ foreach op { "*" "/" "mod" "rem" "**" "<" "<=" ">" ">=" "=" "and" "or" "xor" "&"
 foreach op { "+" "-" "*" "/" "mod" "rem" "**" "<" "<=" ">" ">=" "=" "and" "or" "xor" "&" "abs" "not"} {
     set op_re [string_to_regexp $op]
     gdb_test "continue" \
-             "Breakpoint $decimal, ops\\.\"$op_re\" .*"\
+             "Breakpoint $bkptno_numopt_re, ops\\.\"$op_re\" .*"\
              "continue to ops.\"$op\""
 }
 
index 4421459154fe428d72f755b13fd9401cbb5c422a..cb5831ac6103d766545cd8a86a8b14017a8afc31 100644 (file)
@@ -541,13 +541,14 @@ if ![runto_main] then {
 gdb_test_multiple "break $bp_location1" \
     "set to-be-silent break bp_location1" {
        -re "Breakpoint (\[0-9\]*) at .*, line $bp_location1.*$gdb_prompt $" {
+           set bpno $expect_out(1,string)
            pass "set to-be-silent break bp_location1"
        }
     }
 
-gdb_test "commands $expect_out(1,string)\nsilent\nend" ">end" "set silent break bp_location1"
+gdb_test "commands $bpno\nsilent\nend" ">end" "set silent break bp_location1"
 
-gdb_test "info break $expect_out(1,string)" \
+gdb_test "info break $bpno" \
     "\[0-9\]*\[ \t\]*breakpoint.*:$bp_location1\r\n\[ \t\]*silent.*" \
     "info silent break bp_location1"
 
@@ -557,6 +558,10 @@ gdb_test "continue" "Continuing." \
 gdb_test "bt" "#0  main .* at .*:$bp_location1.*" \
     "stopped for silent break bp_location1"
 
+# Verify the $_hit_bpnum convenience variable is set to the silent hit bpno.
+gdb_test "printf \"%d\\n\", \$_hit_bpnum" "$bpno" \
+    "Silent breakpoint hit \$_hit_bpnum is silent $bpno"
 # Verify that GDB can at least parse a breakpoint with the
 # "thread" keyword.  (We won't attempt to test here that a
 # thread-specific breakpoint really triggers appropriately.
index b540df973a38a3c1775c68c0f9f545120ccf7435..742315178e30a2831106470bc3f4119b3e673c78 100644 (file)
@@ -140,11 +140,11 @@ with_test_prefix "scenario 1" {
     gdb_run_cmd
 
     # Check our conditional breakpoints.
-    gdb_test "" ".*Breakpoint \[0-9\]+, A::func .*" \
+    gdb_test "" ".*Breakpoint $bkptno_num_re, A::func .*" \
        "run until A::func"
     gdb_test "print a" " = 10"
 
-    gdb_test "continue" "Continuing.*Breakpoint \[0-9\]+, C::func .*" \
+    gdb_test "continue" "Continuing.*Breakpoint $bkptno_num_re, C::func .*" \
        "run until C::func"
     gdb_test "print c" " = 30"
 
@@ -208,11 +208,11 @@ with_test_prefix "scenario 2" {
     gdb_run_cmd
 
     # Check that we hit enabled locations only.
-    gdb_test "" ".*Breakpoint \[0-9\]+, A::func .*" \
+    gdb_test "" ".*Breakpoint $bkptno_num_re, A::func .*" \
        "run until A::func"
     gdb_test "print a" " = 10"
 
-    gdb_test "continue" "Continuing.*Breakpoint \[0-9\]+, C::func .*" \
+    gdb_test "continue" "Continuing.*Breakpoint $bkptno_num_re, C::func .*" \
        "run until C::func"
     gdb_test "print c" " = 30"
 
index 9c010f54d79ea740b53eaf529fab9e3931ef641a..3ca8111896c68b417dfc574c4ebb118e6e74cc3a 100644 (file)
@@ -67,9 +67,17 @@ gdb_test "break ctxobj-f.c:$bp_location" \
          "Breakpoint \[0-9\]+ at 0x\[0-9a-fA-F\]+: .*" \
          "break in get_version functions"
 
-gdb_test "continue" \
-         "Breakpoint $decimal, get_version_1 \\(\\).*" \
-         "continue to get_version_1"
+global expect_out
+set test "continue to get_version_1"
+gdb_test_multiple "continue" $test {
+    -re "Breakpoint ($bkptno_num_re), get_version_1 \\(\\).*" {
+       set bpno $expect_out(1,string)
+       pass $test
+    }
+}
+# Verify $_hit_bpnum.$_hit_locno convenience variables are set to the hit bpno.
+gdb_test "printf \"%d.%d\\n\", \$_hit_bpnum, \$_hit_locno" "$bpno" \
+    "$test \$_hit_bpnum.\$_hit_locno is $bpno"
 
 # Try printing "this_version_num".  There are two global variables
 # with that name, and some systems such as GNU/Linux merge them
@@ -100,10 +108,16 @@ gdb_test "print this_version_num == v" \
         "print libctxobj1's this_version_num from symtab"
 
 # Do the same, but from get_version_2.
-
-gdb_test "continue" \
-         "Breakpoint $decimal, get_version_2 \\(\\).*" \
-         "continue to get_version_2"
+set test "continue to get_version_2"
+gdb_test_multiple "continue" $test {
+    -re "Breakpoint ($bkptno_num_re), get_version_2 \\(\\).*" {
+       set bpno $expect_out(1,string)
+       pass $test
+    }
+}
+# Verify the $_hit_bpnum.$_hit_locno convenience variables are set to the hit bpno.
+gdb_test "printf \"%d.%d\\n\", \$_hit_bpnum, \$_hit_locno" "$bpno" \
+    "$test \$_hit_bpnum.\$_hit_locno is $bpno"
 
 gdb_test "print this_version_num == v" \
          " = 1" \
index 24925cf7185a1008a20906954d2d9f654b5c802d..93ac124dbc43d6a1741f0b58f2484bc5b97c705f 100644 (file)
@@ -67,14 +67,21 @@ gdb_test "info break $bp" \
 # See the comments in condbreak.exp for "run until breakpoint at
 # marker1" for an explanation of the xfail below.
 set test "continue to break marker1"
+set bpno 0
 gdb_test_multiple "continue" "$test" {
-    -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $" {
+    -re "Breakpoint (\[0-9\]*), marker1.*$gdb_prompt $" {
+       set bpno $expect_out(1,string)
        pass "$test"
     }
-    -re "Breakpoint \[0-9\]*, $hex in marker1.*$gdb_prompt $" {
+    -re "Breakpoint (\[0-9\]*), $hex in marker1.*$gdb_prompt $" {
+       set bpno $expect_out(1,string)
        xfail "$test"
     }
 }
+# Verify the $_hit_bbnum convenience variable is equal to the hit bpno.
+gdb_test "print \$_hit_bpnum" " = $bpno" "$test \$_hit_bpnum is $bpno"
+# Verify the $_hit_locno is 1, as there is only one code location.
+gdb_test "print \$_hit_locno" " = 1" "$test \$_hit_locno is 1"
 
 gdb_test_no_output "delete $bp" "delete break marker1"
 
@@ -359,7 +366,8 @@ with_test_prefix "4th breakpoint" {
 }
 
 # Perform tests for disable/enable commands on multiple
-# locations and breakpoints.
+# code locations and breakpoints.  If a breakpoint has only one code location,
+# enable/disable num  and enable/disable num.1 should be equivalent.
 #
 # WHAT - the command to test (disable/enable).
 #
@@ -372,7 +380,7 @@ proc test_ena_dis_br { what } {
     global b3
     global b4
     global gdb_prompt
-    
+
     # OPPOS    - the command opposite to WHAT.
     # WHAT_RES - whether breakpoints are expected to end
     #            up enabled or disabled.
@@ -395,13 +403,13 @@ proc test_ena_dis_br { what } {
        set p2 "pass"
     }
 
-    # Now enable(disable) $b.1 $b2.1.
+    # Now enable(disable) $b1.1 $b2.1.
     gdb_test_no_output "$what $b1.1 $b2.1" "$what \$b1.1 \$b2.1"
     set test1 "${what}d \$b1.1 and \$b2.1"
 
     # Now $b1.1 and $b2.1 should be enabled(disabled).
     gdb_test_multiple "info break" "$test1" {
-       -re "(${b1}.1)(\[^\n\r\]*)( n.*)(${b2}.1)(\[^\n\r\]*)( n.*)$gdb_prompt $" {
+       -re "(${b1})(\[^\n\r\]*)( n.*)(${b2})(\[^\n\r\]*)( n.*)$gdb_prompt $" {
            $p1 "$test1"
        }
        -re ".*$gdb_prompt $" {
@@ -420,19 +428,16 @@ proc test_ena_dis_br { what } {
        "${what}d \$b1"
 
     gdb_test_no_output "$oppos $b3" "$oppos \$b3"
+    # Now $b4 $b3 should be enabled(disabled)
+    set test1 "${what}d \$b4 and \$b3"
+    gdb_test "info break" "(${b3})(\[^\n\r]*)( $oppos_res.*).*(${b4})(\[^\n\r\]*)( $oppos_res.*)" "$test1"
+
     gdb_test_no_output "$what $b4 $b3.1" "$what \$b4 \$b3.1"
-    set test1 "${what}d \$b4 and \$b3.1,remain ${oppos}d \$b3"
+    set test1 "${what}d \$b4 and \$b3.1, changing \$b3"
+
+    # Now $b4 $b3 should be enabled(disabled)
+    gdb_test "info break" "(${b3})(\[^\n\r]*)( $what_res.*).*(${b4})(\[^\n\r\]*)( $what_res.*)" "$test1"
 
-    # Now $b4 $b3.1 should be enabled(disabled) and
-    # $b3 should remain disabled(enabled).
-    gdb_test_multiple "info break" "$test1" {
-       -re "(${b3})(\[^\n\r]*)( $oppos_res.*)(${b3}.1)(\[^\n\r\]*)( n.*)(${b4})(\[^\n\r\]*)( $what_res.*)$gdb_prompt $" {
-           $p1 "$test1"
-       }
-       -re "(${b3})(\[^\n\r]*)( $oppos_res.*)(${b4})(\[^\n\r\]*)( $what_res.*)$gdb_prompt $" {
-           $p2 "$test1"
-       }
-    }
 
     # Now enable(disable) '$b4.1 fooobaar'.  This should error on
     # fooobaar.
@@ -443,7 +448,7 @@ proc test_ena_dis_br { what } {
 
     # $b4.1 should be enabled(disabled).
     gdb_test_multiple "info break" "$test1" {
-        -re "(${b4}.1)(\[^\n\r\]*)( n.*)$gdb_prompt $" {
+        -re "(${b4})(\[^\n\r\]*)( n.*)$gdb_prompt $" {
            $p1 "$test1"
        }
        -re ".*$gdb_prompt $" {
index 918f3e4fd5fe1bab40b401937aacba16cd2cca20..cb6d975a767369a785b9971947e98d2068273ba2 100644 (file)
@@ -99,7 +99,7 @@ proc do_catch_exec_test { } {
 # before re-running.
 
 proc do_follow_exec_mode_tests { mode cmd infswitch } {
-    global binfile srcfile srcfile2 testfile testfile2
+    global binfile srcfile srcfile2 testfile testfile2 bkptno_numopt_re
     global gdb_prompt
 
     with_test_prefix "$mode,$cmd,$infswitch" {
@@ -125,7 +125,7 @@ proc do_follow_exec_mode_tests { mode cmd infswitch } {
        # Set up the output we expect to see after we execute past the exec.
        #
        set execd_line [gdb_get_line_number "after-exec" $srcfile2]
-       set expected_re ".*xecuting new program: .*${testfile2}.*Breakpoint .,.*${srcfile2}:${execd_line}.*$gdb_prompt $"
+       set expected_re ".*xecuting new program: .*${testfile2}.*Breakpoint ${bkptno_numopt_re},.*${srcfile2}:${execd_line}.*$gdb_prompt $"
 
        # Set a breakpoint after the exec call if we aren't single-stepping
        # past it.
@@ -189,7 +189,7 @@ proc do_follow_exec_mode_tests { mode cmd infswitch } {
                send_gdb "y\n"
                exp_continue
            }
-           -re "Starting program: .*$expected_inf.*Breakpoint .,.*\r\n$gdb_prompt $" {
+           -re "Starting program: .*$expected_inf.*Breakpoint $bkptno_numopt_re,.*\r\n$gdb_prompt $" {
                pass $test
            }
        }
index efc357d39a2dd89e1d4114680291133a17c78aba..19e9d3a5537c959c60daa7d1d365c4ebf09e4788 100644 (file)
@@ -54,10 +54,10 @@ proc_with_prefix test_detach_on_fork_follow_child {} {
 proc_with_prefix test_no_detach_on_fork {} {
     setup_test "off"
 
-    gdb_test "continue" "\r\nThread 1.1 .* hit Breakpoint 2, break_here.*" \
+    gdb_test "continue" "\r\nThread 1.1 .* hit Breakpoint 2.1, break_here.*" \
             "continue from thread 1.1"
     gdb_test "thread 2.1"
-    gdb_test "continue" "\r\nThread 2.1 .* hit Breakpoint 2, break_here.*" \
+    gdb_test "continue" "\r\nThread 2.1 .* hit Breakpoint 2.2, break_here.*" \
             "continue from thread 2.1"
 }
 
index f8bd99980fe747ce51a4ea44783458b0e24093a5..575319c564ca9d90540e65d9ab9bebff18a42f63 100644 (file)
@@ -91,7 +91,7 @@ delete_breakpoints
 
 gdb_test "break marker"
 
-gdb_test "continue" "Continuing\\..*Breakpoint $decimal, .*" \
+gdb_test "continue" "Continuing\\..*Breakpoint $bkptno_num_re, .*" \
     "continue to marker, first time"
 
 # Step 2, create a breakpoint which evaluates false, and force it
@@ -120,5 +120,5 @@ gdb_test "inferior 1" ".*Switching to inferior 1.*" \
 # Switch back to the parent process, continue to the marker to
 # test GDBserver's state is still correct.
 
-gdb_test "continue" "Continuing\\..*Breakpoint $decimal, .*" \
+gdb_test "continue" "Continuing\\..*Breakpoint $bkptno_numopt_re, .*" \
     "continue to marker, second time"
index bf74df4fee86784a22183d8753cbefc2b5a11a8d..fffb9a570080c4fc0cd77de60223074c3986bc9f 100644 (file)
@@ -42,7 +42,7 @@ gdb_test "info break" \
     "\[\r\n\]1\.1.* y .* at .*$hdrfile:$bp_location.*\[\r\n\]1\.2.* y .* at .*$hdrfile:$bp_location.*"
 
 gdb_run_cmd
-gdb_test "" "Breakpoint \[0-9\]+,.*foo \\(i=0\\).*" "run to breakpoint"
+gdb_test "" "Breakpoint $bkptno_num_re,.*foo \\(i=0\\).*" "run to breakpoint"
 
 gdb_test "continue" \
     ".*Breakpoint.*foo \\(i=1\\).*" \
@@ -55,7 +55,7 @@ gdb_test "continue" \
 gdb_test_no_output "disable 1.2" "disabling location: disable"
 
 gdb_run_cmd
-gdb_test "" "Breakpoint \[0-9\]+,.*foo \\(i=0\\).*" "disabling location: run to breakpoint"
+gdb_test "" "Breakpoint $bkptno_num_re,.*foo \\(i=0\\).*" "disabling location: run to breakpoint"
 
 gdb_test_multiple "info break" "disabled breakpoint 1.2" {
     -re "1\.2.* n .* at .*$hdrfile:$bp_location.*$gdb_prompt $" {
index 5d4c886825efb661625b84fb94d97e4b6ea2f805..72476d0c6f71fb25b9117e6f52423b82616d7cbb 100644 (file)
@@ -38,7 +38,7 @@ gdb_run_cmd
 
 set test "initial condition: run to breakpoint"
 gdb_test_multiple "" $test {
-    -re "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
+    -re "Breakpoint $bkptno_num_re,.*foo<int> \\(i=1\\).*$gdb_prompt $" {
        pass $test
        break
     }
@@ -63,7 +63,7 @@ gdb_test_no_output {condition $bpnum i==1} \
     "separate condition: set condition"
     
 gdb_run_cmd
-gdb_test "" "Breakpoint \[0-9\]+,.*foo<int> \\(i=1\\).*" "separate condition: run to breakpoint"
+gdb_test "" "Breakpoint $bkptno_num_re,.*foo<int> \\(i=1\\).*" "separate condition: run to breakpoint"
 
 gdb_test "continue" \
     ".*Breakpoint.*foo<double> \\(i=1\\).*" \
@@ -75,7 +75,7 @@ gdb_test "continue" \
 gdb_test_no_output {disable $bpnum.1} "disabling location: disable"
 
 gdb_run_cmd
-gdb_test "" "Breakpoint \[0-9\]+,.*foo<double> \\(i=1\\).*" "disabling location: run to breakpoint"
+gdb_test "" "Breakpoint $bkptno_num_re,.*foo<double> \\(i=1\\).*" "disabling location: run to breakpoint"
 
 # Try disabling entire breakpoint
 gdb_test_no_output {enable $bpnum.1} "disabling location: enable"
index 06adf82ecbbc40983b2745ac383798f866ea9b6d..0ed9eae055b3b3aa28aaa26b7d3b26ec3ec1127f 100644 (file)
@@ -380,7 +380,7 @@ gdb_test "info break" $bptable "breakpoint info (after setting on all)"
 
 # Run through each breakpoint.
 proc continue_to_bp_overloaded {bpnumber might_fail line argtype argument} {
-    global gdb_prompt hex decimal srcfile
+    global gdb_prompt hex decimal srcfile bkptno_num_re
 
     if {$argument == ""} {
         set actuals ""
@@ -398,11 +398,11 @@ proc continue_to_bp_overloaded {bpnumber might_fail line argtype argument} {
     }
 
     gdb_test_multiple "continue" "continue to bp overloaded : $argtype" {
-        -re "Continuing.\r\n\r\nBreakpoint $bpnumber, foo::overload1arg \\(this=${hex}(, )?$actuals\\) at .*$srcfile:$line\r\n$decimal\[\t \]+{ $body }.*$gdb_prompt $" {
+        -re "Continuing.\r\n\r\nBreakpoint $bkptno_num_re, foo::overload1arg \\(this=${hex}(, )?$actuals\\) at .*$srcfile:$line\r\n$decimal\[\t \]+{ $body }.*$gdb_prompt $" {
             pass "continue to bp overloaded : $argtype"
         }
 
-        -re "Continuing.\r\n\r\nBreakpoint $bpnumber, foo::overload1arg \\(this=${hex}, arg=.*\\) at .*$srcfile:$line\r\n$decimal\[\t \]+{ $body }.*$gdb_prompt $" {
+        -re "Continuing.\r\n\r\nBreakpoint $bkptno_num_re, foo::overload1arg \\(this=${hex}, arg=.*\\) at .*$srcfile:$line\r\n$decimal\[\t \]+{ $body }.*$gdb_prompt $" {
             if $might_kfail {
                 kfail "c++/8130" "continue to bp overloaded : $argtype"
             } else {
index ea362ef693d970e9655967d376beaa2e8cc07ccd..3585ac9f0bf0f5e1b8d724d976f773897d7a52d4 100644 (file)
@@ -49,7 +49,7 @@ gdb_exit
 # The main test.  This is called by the self-test framework once GDB
 # has been started on a copy of itself.
 proc test_python_helper {} {
-    global py_helper_script decimal hex gdb_prompt
+    global py_helper_script decimal hex gdb_prompt bkptno_numopt_re
     global inferior_spawn_id
 
     # Source the python helper script.  This script registers the
@@ -190,7 +190,7 @@ proc test_python_helper {} {
     # Send a command to the inner GDB, this should result in the outer
     # GDB stopping at the value_print breakpoint again.
     send_inferior "ptype global_c\n"
-    gdb_test -prompt $outer_prompt_re "" "Breakpoint $decimal, c_print_type.*" "hit breakpoint in outer gdb again"
+    gdb_test -prompt $outer_prompt_re "" "Breakpoint $bkptno_numopt_re, c_print_type.*" "hit breakpoint in outer gdb again"
 
     set answer [multi_line \
                    "$decimal = " \
index 19ccbe85e04f4a272bd4e358af075e06e3612ed4..c080955049cc4233c2f9d3720908c630446b6420 100644 (file)
@@ -69,7 +69,7 @@ if { $use_second_inferior } {
        "\\^running.*" \
        "run inferior 2"
 
-    mi_expect_stop "breakpoint-hit" "all_threads_started" ".*" ".*" ".*" {"" "disp=\"keep\""} \
+    mi_expect_stop "breakpoint-hit" "all_threads_started" ".*" ".*" ".*" {"" "disp=\"keep\"" "locno=\"[0-9]+\""} \
        "inferior i2 stops at all_threads_started"
 
     mi_send_resuming_command "exec-continue --thread-group i2" \
index d78c96ddef1ac384d5173b07fb9706efd9cccf50..9eec083068bcfa30a3277b772c668f2e380724cc 100644 (file)
@@ -307,8 +307,13 @@ proc test_continue_to_start { mode inf } {
 
            # Consume MI event output.
            with_spawn_id $mi_spawn_id {
-               mi_expect_stop "breakpoint-hit" "main" "" "$srcfile" \
-                   "$decimal" {"" "disp=\"del\""} "stop at breakpoint in main"
+               if { $inf == 1 } {
+                   mi_expect_stop "breakpoint-hit" "main" "" "$srcfile" \
+                       "$decimal" {"" "disp=\"del\""} "stop at breakpoint in main"
+               } else {
+                   mi_expect_stop "breakpoint-hit" "main" "" "$srcfile" \
+                       "$decimal" {"" "disp=\"del\"" "locno=\"[0-9]+\""} "stop at breakpoint in main"
+               }
            }
 
            if { $mode == "all-stop" } {
@@ -330,9 +335,15 @@ proc test_continue_to_start { mode inf } {
 
                    # Consume MI output.
                    with_spawn_id $mi_spawn_id {
-                       mi_expect_stop "breakpoint-hit" "child_sub_function" \
-                           "" "$srcfile" "$decimal" {"" "disp=\"del\""} \
-                           "thread $inf.$thread stops MI"
+                       if { $inf == 1} {
+                           mi_expect_stop "breakpoint-hit" "child_sub_function" \
+                               "" "$srcfile" "$decimal" {"" "disp=\"del\""} \
+                               "thread $inf.$thread stops MI"
+                       } else {
+                           mi_expect_stop "breakpoint-hit" "child_sub_function" \
+                               "" "$srcfile" "$decimal" {"" "disp=\"del\"" "locno=\"[0-9]+\""} \
+                               "thread $inf.$thread stops MI"
+                       }
                    }
                }
 
@@ -359,9 +370,15 @@ proc test_continue_to_start { mode inf } {
 
                # Consume MI output.
                with_spawn_id $mi_spawn_id {
-                   mi_expect_stop "breakpoint-hit" "child_sub_function" \
-                       "" "$srcfile" "$decimal" {"" "disp=\"del\""} \
-                       "thread $inf.2 stops MI"
+                   if { $inf == 1} {
+                       mi_expect_stop "breakpoint-hit" "child_sub_function" \
+                           "" "$srcfile" "$decimal" {"" "disp=\"del\""} \
+                           "thread $inf.2 stops MI"
+                   } else {
+                       mi_expect_stop "breakpoint-hit" "child_sub_function" \
+                           "" "$srcfile" "$decimal" {"" "disp=\"del\"" "locno=\"[0-9]+\""} \
+                           "thread $inf.2 stops MI"
+                   }
                }
            }
        }
@@ -434,7 +451,7 @@ proc_with_prefix test_setup { mode } {
 
        with_spawn_id $mi_spawn_id {
            mi_expect_stop "breakpoint-hit" "main" "" "$srcfile" "$decimal" \
-               {"" "disp=\"del\""} "main stop"
+               {"" "disp=\"del\"" "locno=\"[0-9]+\""} "main stop"
        }
 
        # Consume CLI output.
index a8e81e29ee9a64387c5c6eeeecbe5cbb0d92af41..3d77960988d9836910c87719f21caf940a2dfaf4 100644 (file)
@@ -148,6 +148,7 @@ proc build_executables { first_arch } {
 }
 
 proc do_test { first_arch mode selected_thread } {
+        global bkptno_numopt_re
        set from_exec "$first_arch-multi-arch-exec"
 
        clean_restart ${from_exec}
@@ -169,7 +170,7 @@ proc do_test { first_arch mode selected_thread } {
 
        # Test that GDB updates the target description / arch successfuly
        # after the exec.
-       gdb_test "continue" "Breakpoint 2, main.*" "continue across exec that changes architecture"
+       gdb_test "continue" "Breakpoint $bkptno_numopt_re, main.*" "continue across exec that changes architecture"
 }
 
 # Test both arch1=>arch2 and arch2=>arch1.
index fec2575f9047e5a6489f889e92189fba29c4f813..b94689d0bfa534020751237c629eeecec08dca33 100644 (file)
@@ -46,5 +46,5 @@ gdb_load $binfile
 if {[gdb_start_cmd] < 0} {
     fail "start the second inf"
 } else {
-    gdb_test "" ".*reakpoint ., main .*${srcfile}.*" "start the second inf"
+    gdb_test "" ".*reakpoint $bkptno_numopt_re, main .*${srcfile}.*" "start the second inf"
 }
index cbccba19d128bd7e16978a1b5e8c967cebddacd4..3c079facced71544e089d29216f00a3bb069d1c6 100644 (file)
@@ -27,7 +27,7 @@ if {[build_executable "failed to build" $testfile $srcfile {debug}]} {
 # child.  Can be either "kill", "detach", or "exit" (to continue it to
 # normal exit).
 proc do_test {dispose} {
-    global binfile
+    global binfile bkptno_numopt_re
 
     clean_restart $binfile
 
@@ -77,7 +77,7 @@ proc do_test {dispose} {
     #  Command aborted.
     #  (gdb)
     #
-    gdb_test "continue" "Breakpoint \[0-9\]+, marker .*" \
+    gdb_test "continue" "Breakpoint $bkptno_numopt_re, marker .*" \
        "continue in inferior 1"
 }
 
index e4329dca6c27e923d8b78aa4329bc75f402ab6fc..0fc1bee762fea7ff00d30b95e7fb1b2f41bb54a5 100644 (file)
@@ -84,11 +84,11 @@ if [skip_hw_watchpoint_multi_tests] {
        "Hardware access \\(read/write\\) watchpoint \[0-9\]+: c\r\n\r\nOld value = 0\r\nNew value = 3\r\n.*" \
        "catch c on inferior 2"
 
-    gdb_test "continue" "Breakpoint \[0-9\]+, marker_exit .*" "catch marker_exit in inferior 2"
+    gdb_test "continue" "Breakpoint $bkptno_numopt_re, marker_exit .*" "catch marker_exit in inferior 2"
 
     gdb_test "inferior 1" "witching to inferior 1 .*" "switch back to inferior 1 again"
 
     gdb_test "continue" "Hardware access \\(read/write\\) watchpoint \[0-9\]+: b\r\n\r\nOld value = 0\r\nNew value = 2\r\n.*" "catch b on inferior 1"
 }
 
-gdb_test "continue" "Breakpoint \[0-9\]+, marker_exit .*" "catch marker_exit in inferior 1"
+gdb_test "continue" "Breakpoint $bkptno_numopt_re, marker_exit .*" "catch marker_exit in inferior 1"
index a05b14b4b1ce094321cd103553ff9c3c3d24138a..7d05fbe557bba4dc97e67a40890dab4f45791291 100644 (file)
@@ -273,6 +273,14 @@ set inferior_exited_re "(?:\\\[Inferior \[0-9\]+ \\(\[^\n\r\]*\\) exited)"
 # E.g., $1, $2, etc.
 set valnum_re "\\\$$decimal"
 
+# A regular expression that matches a breakpoint hit with a breakpoint
+# having several code locations.
+set bkptno_num_re "$decimal\\.$decimal"
+
+# A regular expression that matches a breakpoint hit
+# with one or several code locations.
+set bkptno_numopt_re "($decimal\\.$decimal|$decimal)"
+
 ### Only procedures should come after this point.
 
 #
@@ -709,6 +717,7 @@ proc gdb_breakpoint { linespec args } {
 
 proc runto { linespec args } {
     global gdb_prompt
+    global bkptno_numopt_re
     global decimal
 
     delete_breakpoints
@@ -746,7 +755,7 @@ proc runto { linespec args } {
            }
            return 1
        }
-       -re "Breakpoint \[0-9\]*, \[0-9xa-f\]* in .*$gdb_prompt $" { 
+       -re "Breakpoint $bkptno_numopt_re, \[0-9xa-f\]* in .*$gdb_prompt $" {
            if { $print_pass } {
                pass $test_name
            }
index b11457693be82e88ef7f0fb2d4ce54e0c7f63290..a45c6f7be2849928419ffd43f3e8cd5ceca0cb0a 100644 (file)
@@ -1208,11 +1208,11 @@ proc mi_detect_async {} {
 # filename of a file without debug info.  ARGS should not include [] the
 # list of argument is enclosed in, and other regular expressions should
 # not include quotes.
-# If EXTRA is a list of one element, it's the regular expression
+# EXTRA can be a list of one, two or three elements.
+# The first element is the regular expression
 # for output expected right after *stopped, and before GDB prompt.
-# If EXTRA is a list of two elements, the first element is for
-# output right after *stopped, and the second element is output
-# right after reason field.  The regex after reason should not include
+# The third element is the regulation expression for the locno
+# right after bkptno field.  The locno regex should not include
 # the comma separating it from the following fields.
 #
 # When we fail to match output at all, -1 is returned.  If FILE does
@@ -1237,7 +1237,14 @@ proc mi_expect_stop { reason func args file line extra test } {
 
     set after_stopped ""
     set after_reason ""
-    if { [llength $extra] == 2 } {
+    set locno ""
+    if { [llength $extra] == 3 } {
+       set after_stopped [lindex $extra 0]
+       set after_reason [lindex $extra 1]
+       set after_reason "${after_reason},"
+       set locno [lindex $extra 2]
+       set locno "${locno},"
+    } elseif { [llength $extra] == 2 } {
        set after_stopped [lindex $extra 0]
        set after_reason [lindex $extra 1]
        set after_reason "${after_reason},"
@@ -1311,10 +1318,12 @@ proc mi_expect_stop { reason func args file line extra test } {
     set ebn ""
     if { $reason == "breakpoint-hit" } {
        set bn {bkptno="[0-9]+",}
+       set bn "${bn}${locno}"
     } elseif { $reason == "solib-event" } {
        set bn ".*"
     } elseif { $reason == "exception-caught" } {
        set ebn {bkptno="[0-9]+",}
+       set ebn "${ebn}${locno}"
        set bn ".*"
        set reason "breakpoint-hit"
     }
@@ -1328,6 +1337,7 @@ proc mi_expect_stop { reason func args file line extra test } {
     set a $after_reason
 
     verbose -log "mi_expect_stop: expecting: \\*stopped,${ebn}${r}${a}${bn}frame=\{addr=\"$hex\",func=\"$func\",args=$args,(?:file=\"$any$file\",fullname=\"${fullname_syntax}$file\",line=\"$line\",arch=\"$any\"|from=\"$file\")\}$after_stopped,thread-id=\"$decimal\",stopped-threads=$any\r\n($thread_selected_re|$breakpoint_re)*$prompt_re"
+
     gdb_expect {
        -re "\\*stopped,${ebn}${r}${a}${bn}frame=\{addr=\"$hex\",func=\"$func\",args=$args,(?:file=\"$any$file\",fullname=\"${fullname_syntax}$file\",line=\"($line)\",arch=\"$any\"|from=\"$file\")\}$after_stopped,thread-id=\"$decimal\",stopped-threads=$any\r\n($thread_selected_re|$breakpoint_re)*$prompt_re" {
            pass "$test"
This page took 0.141428 seconds and 4 git commands to generate.