diff options
author | Philippe Waroquiers <philippe.waroquiers@skynet.be> | 2020-05-23 22:27:28 +0200 |
---|---|---|
committer | Philippe Waroquiers <philippe.waroquiers@skynet.be> | 2022-11-19 13:38:38 +0100 |
commit | 78805ff8aecf0a8c828fb1e2c344fa3a56655120 (patch) | |
tree | cd4f81d81ae3f1c78f360e21d5e933a8ceb19745 /gdb/testsuite/lib | |
parent | 15253318be0995200cc59929ca32eedbfd041e45 (diff) | |
download | gdb-78805ff8aecf0a8c828fb1e2c344fa3a56655120.zip gdb-78805ff8aecf0a8c828fb1e2c344fa3a56655120.tar.gz gdb-78805ff8aecf0a8c828fb1e2c344fa3a56655120.tar.bz2 |
Show locno for 'multi location' breakpoint hit msg+conv var $_hit_bbnum $_hit_locno PR breakpoints/12464
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.
Diffstat (limited to 'gdb/testsuite/lib')
-rw-r--r-- | gdb/testsuite/lib/gdb.exp | 11 | ||||
-rw-r--r-- | gdb/testsuite/lib/mi-support.exp | 20 |
2 files changed, 25 insertions, 6 deletions
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index a05b14b..7d05fbe 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -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 } diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp index b114576..a45c6f7 100644 --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp @@ -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" |