diff options
author | Pedro Alves <palves@redhat.com> | 2019-07-09 19:26:16 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2019-07-09 19:34:18 +0100 |
commit | cb1e4e32c2d9588e1d77ea49bafb5dcdc1cff764 (patch) | |
tree | 3c878afb8e0496bb08632c5fbcb50e9f167554e6 /gdb/testsuite/gdb.cp | |
parent | b58a68fe5709ed205c3ac54065f1783ce58d9a01 (diff) | |
download | gdb-cb1e4e32c2d9588e1d77ea49bafb5dcdc1cff764.zip gdb-cb1e4e32c2d9588e1d77ea49bafb5dcdc1cff764.tar.gz gdb-cb1e4e32c2d9588e1d77ea49bafb5dcdc1cff764.tar.bz2 |
"catch catch/throw/rethrow", breakpoint -> catchpoint
Currently, with:
(gdb) catch catch
Catchpoint 1 (catch)
(gdb) catch throw
Catchpoint 2 (throw)
(gdb) catch rethrow
Catchpoint 3 (rethrow)
You get:
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y 0x0000000000b122af exception catch
2 breakpoint keep y 0x0000000000b1288d exception throw
3 breakpoint keep y 0x0000000000b12931 exception rethrow
I think it doesn't make much sense usability-wise, to show a
catchpoint as a breakpoint. The fact that GDB sets a breakpoint at
some magic address in the C++ run time is an implementation detail,
IMO. And as seen in the previous patch, such a catchpoint can end up
with more than one location/address even, so showing a single address
isn't entirely accurate.
This commit hides the addresses from view, and makes GDB show
"catchpoint" for type as well:
(gdb) info breakpoints
Num Type Disp Enb Address What
1 catchpoint keep y exception catch
2 catchpoint keep y exception throw
3 catchpoint keep y exception rethrow
This comment in the code seems telling:
/* We need to reset 'type' in order for code in breakpoint.c to do
the right thing. */
cp->type = bp_breakpoint;
It kind of suggests that the reason catchpoints end up shown as
breakpoints was that it was easier to implement them that way, rather
than a desired property.
This commit fixes things up to make it possible to have bp_catch
breakpoints have software/hardware breakpoint locations, thus
eliminating the need for that hack:
- redo breakpoint_address_is_meaningful in terms of the location's
type rather than breakpoint type.
- teach bpstat_what about stepping over the catchpoint locations.
- install a allocate_location method for "catch catch/throw/rethrow",
one that forces the location type.
Note that this also reverts the gdb hunk from:
commit 2a8be20359dba9cc684fd3ffa222d985399f3b18
Commit: Tom Tromey <tom@tromey.com>
CommitDate: Sat Oct 6 22:17:45 2018 -0600
Fix Python gdb.Breakpoint.location crash
because now "catch throw" catchpoints hit the
if (obj->bp->type != bp_breakpoint)
Py_RETURN_NONE;
check above, and, adjusts the testcase to no longer expect to see the
catchpoint in the gdb.breakpoints() list.
(Note: might make sense to do the same to Ada exception catchpoints.)
gdb/ChangeLog:
2019-07-09 Pedro Alves <palves@redhat.com>
* break-catch-throw.c (print_one_exception_catchpoint): Skip the
"addr" field.
(allocate_location_exception_catchpoint): New.
(handle_gnu_v3_exceptions): Don't reset 'type' to bp_breakpoint.
(initialize_throw_catchpoint_ops): Install
allocate_location_exception_catchpoint as allocate_location
method.
* breakpoint.c (bpstat_what) <bp_catch>: Set action to
BPSTAT_WHAT_SINGLE if not stopping and the location's type is not
bp_loc_other.
(breakpoint_address_is_meaningful): Delete.
(bl_address_is_meaningful): New.
(breakpoint_locations_match): Adjust comment.
(bp_location_from_bp_type): New, factored out of...
(bp_location::bp_location(breakpoint *)): ... this.
(bp_location::bp_location(breakpoint *, bp_loc_type)): New,
factored out of...
(bp_location::bp_location(breakpoint *)): ... this. Reimplement.
(bp_loc_is_permanent): Use bl_address_is_meaningful instead of
breakpoint_address_is_meaningful.
(bp_locations_compare): Adjust comment.
(update_global_location_list): Use bl_address_is_meaningful
instead of breakpoint_address_is_meaningful.
* breakpoint.h (bp_location::bp_location(breakpoint *)): New
explicit.
(bp_location::bp_location(breakpoint *, bp_loc_type)): Declare.
* python/py-breakpoint.c (bppy_get_location): No longer check
whether location is null.
gdb/doc/ChangeLog:
2019-07-09 Pedro Alves <palves@redhat.com>
* gdb.texinfo (C++ Exception GDB/MI Catchpoint Commands): Adjust
examples to show type=catchpoint instead of type=breakpoint and an
address.
gdb/testsuite/ChangeLog:
2019-07-09 Pedro Alves <palves@redhat.com>
* gdb.cp/catch-multi-stdlib.exp: Adjust expected "info
breakpoints" output.
* gdb.cp/exception.exp: Adjust expected "info breakpoints" output.
* gdb.python/py-breakpoint.exp: No longer expect that "catch
throw" creates breakpoint.
* gdb.mi/mi-catch-cpp-exceptions.exp (setup_catchpoint): Expect
'type="catchpoint"'.
Diffstat (limited to 'gdb/testsuite/gdb.cp')
-rw-r--r-- | gdb/testsuite/gdb.cp/except-multi-location.exp | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/exception.exp | 18 |
2 files changed, 6 insertions, 18 deletions
diff --git a/gdb/testsuite/gdb.cp/except-multi-location.exp b/gdb/testsuite/gdb.cp/except-multi-location.exp index 60d6d0b..1258d89 100644 --- a/gdb/testsuite/gdb.cp/except-multi-location.exp +++ b/gdb/testsuite/gdb.cp/except-multi-location.exp @@ -74,9 +74,9 @@ proc test_multi_libstdcpp {static_bin static_lib} { set ws "\[ \t\]*" gdb_test "info breakpoints" \ [multi_line \ - "${decimal}${ws}breakpoint${ws}keep${ws}y${ws}${hex}${ws}exception catch" \ - "${decimal}${ws}breakpoint${ws}keep${ws}y${ws}${hex}${ws}exception throw" \ - "${decimal}${ws}breakpoint${ws}keep${ws}y${ws}${hex}${ws}exception rethrow"] + "${decimal}${ws}catchpoint${ws}keep${ws}y${ws}exception catch" \ + "${decimal}${ws}catchpoint${ws}keep${ws}y${ws}exception throw" \ + "${decimal}${ws}catchpoint${ws}keep${ws}y${ws}exception rethrow"] } # Try different static/not-static combinations. diff --git a/gdb/testsuite/gdb.cp/exception.exp b/gdb/testsuite/gdb.cp/exception.exp index 4761de2..0be382b 100644 --- a/gdb/testsuite/gdb.cp/exception.exp +++ b/gdb/testsuite/gdb.cp/exception.exp @@ -62,16 +62,10 @@ gdb_test "catch rethrow" "Catchpoint \[0-9\]+ \\(rethrow\\)" \ "catch rethrow (before inferior run)" -# The catchpoints should be listed in the list of breakpoints. -# In case of a statically linked test, we won't have a pending breakpoint. -# Hence we allow for both an address or "<PENDING>". If we ever become able -# to tell whether the target is linked statically or not, we can be more -# precise and require exact output. -set addr "\(<PENDING>|$hex\)" set re_head "Num${ws}Type${ws}Disp${ws}Enb${ws}Address${ws}What" -set re_2_bp "1${ws}breakpoint${ws}keep${ws}y${ws}$addr${ws}exception catch" -set re_3_bp "2${ws}breakpoint${ws}keep${ws}y${ws}$addr${ws}exception throw" -set re_4_bp "3${ws}breakpoint${ws}keep${ws}y${ws}$addr${ws}exception rethrow" +set re_2_bp "1${ws}catchpoint${ws}keep${ws}y${ws}exception catch" +set re_3_bp "2${ws}catchpoint${ws}keep${ws}y${ws}exception throw" +set re_4_bp "3${ws}catchpoint${ws}keep${ws}y${ws}exception rethrow" set name "info breakpoints (before inferior run)" gdb_test_multiple "info breakpoints" $name { @@ -100,12 +94,6 @@ if { !$ok } { continue } -set addr "$hex" -set re_head "Num${ws}Type${ws}Disp${ws}Enb${ws}Address${ws}What" -set re_2_bp "1${ws}breakpoint${ws}keep${ws}y${ws}$addr${ws}exception catch" -set re_3_bp "2${ws}breakpoint${ws}keep${ws}y${ws}$addr${ws}exception throw" -set re_4_bp "3${ws}breakpoint${ws}keep${ws}y${ws}$addr${ws}exception rethrow" - set name "info breakpoints (after inferior run)" gdb_test_multiple "info breakpoints" $name { -re "$re_head${ws}$re_2_bp${ws}$re_3_bp${ws}$re_4_bp\r\n$gdb_prompt $" { |