diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2019-05-08 19:01:36 +0100 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2019-06-15 23:22:22 +0100 |
commit | 30056ea04ae3ecd828e2a06e12e6f174ae6659c9 (patch) | |
tree | 0241b9853191c5363b2e5089b81ff95413df17c6 /gdb/doc | |
parent | gdb: Don't allow annotations to influence what else GDB prints (diff) | |
download | binutils-gdb-30056ea04ae3ecd828e2a06e12e6f174ae6659c9.tar.gz binutils-gdb-30056ea04ae3ecd828e2a06e12e6f174ae6659c9.tar.bz2 binutils-gdb-30056ea04ae3ecd828e2a06e12e6f174ae6659c9.zip |
gdb/mi: New commands to catch C++ exceptions
Adds some MI commands to catch C++ exceptions. The new commands are
-catch-throw, -catch-rethrow, and -catch-catch, these all correspond
to the CLI commands 'catch throw', 'catch rethrow', and 'catch catch'.
Each MI command takes two optional arguments, '-t' has the effect of
calling 'tcatch' instead of 'catch', for example:
(gdb)
-catch-throw -t
Is the same as:
(gdb) tcatch throw
There is also a '-r REGEXP' argument that can supply a regexp to match
against the exception type, so:
(gdb)
-catch-catch -r PATTERN
Is the same as:
(gdb) catch catch PATTERN
The change in print_mention_exception_catchpoint might seem a little
strange; changing the output from using ui_out::field_int and
ui_out::text to using ui_out::message.
The print_mention_exception_catchpoint is used as the 'print_mention'
method for the exception catchpoint breakpoint object. Most of the
other 'print_mention' methods (see breakpoint.c) use either
printf_filtered, of ui_out::message. Using field_int was causing an
unexpected field to be added to the MI output. Here's the output
without the change in print_mention_exception_catchpoint:
(gdb)
-catch-throw
^done,bkptno="1",bkpt={number="1",type="breakpoint",disp="keep",
enabled="y",addr="0x00000000004006c0",
what="exception throw",catch-type="throw",
thread-groups=["i1"],times="0"}
Notice the breakpoint number appears in both the 'bkptno' field, and
the 'number' field within the 'bkpt' tuple. Here's the output with
the change in print_mention_exception_catchpoint:
(gdb)
-catch-throw
^done,bkpt={number="1",type="breakpoint",disp="keep",
enabled="y",addr="0x00000000004006c0",
what="exception throw",catch-type="throw",
thread-groups=["i1"],times="0"}
gdb/ChangeLog:
* NEWS: Mention new MI commands.
* break-catch-throw.c (enum exception_event_kind): Move to
breakpoint.h.
(print_mention_exception_catchpoint): Output text as a single
message.
(catch_exception_command_1): Rename to...
(catch_exception_event): ...this, make non-static, update header
command, and change some parameter types.
(catch_catch_command): Update for changes to
catch_exception_command_1.
(catch_throw_command): Likewise.
(catch_rethrow_command): Likewise.
* breakpoint.c (enum exception_event_kind): Delete.
* breakpoint.h (enum exception_event_kind): Moved here from
break-catch-throw.c.
(catch_exception_event): Declare.
* mi/mi-cmd-catch.c (mi_cmd_catch_exception_event): New function.
(mi_cmd_catch_throw): New function.
(mi_cmd_catch_rethrow): New function.
(mi_cmd_catch_catch): New function.
* mi/mi-cmds.c (mi_cmds): Add 'catch-throw', 'catch-rethrow', and
'catch-catch' entries.
* mi/mi-cmds.h (mi_cmd_catch_throw): Declare.
(mi_cmd_catch_rethrow): Declare.
(mi_cmd_catch_catch): Declare.
gdb/doc/ChangeLog:
* gdb.texinfo (GDB/MI Catchpoint Commands): Add menu entry to new
node.
(C++ Exception GDB/MI Catchpoint Commands): New node to describe
new MI commands.
gdb/testsuite/ChangeLog:
* gdb.mi/mi-catch-cpp-exceptions.cc: New file.
* gdb.mi/mi-catch-cpp-exceptions.exp: New file.
* lib/mi-support.exp (mi_expect_stop): Handle 'exception-caught'
as a stop reason.
Diffstat (limited to 'gdb/doc')
-rw-r--r-- | gdb/doc/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/doc/gdb.texinfo | 140 |
2 files changed, 147 insertions, 0 deletions
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 17048c8b2da..f3142fd9ec8 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,10 @@ +2019-06-15 Andrew Burgess <andrew.burgess@embecosm.com> + + * gdb.texinfo (GDB/MI Catchpoint Commands): Add menu entry to new + node. + (C++ Exception GDB/MI Catchpoint Commands): New node to describe + new MI commands. + 2019-06-13 Pedro Alves <palves@redhat.com> * gdb.texinfo (Command Completion): Mention command options too. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index a5026dfc034..9a0320e5d8f 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -29793,6 +29793,7 @@ catchpoints. @menu * Shared Library GDB/MI Catchpoint Commands:: * Ada Exception GDB/MI Catchpoint Commands:: +* C++ Exception GDB/MI Catchpoint Commands:: @end menu @node Shared Library GDB/MI Catchpoint Commands @@ -29992,6 +29993,145 @@ times="0",original-location="__gnat_begin_handler"@} (gdb) @end smallexample +@node C++ Exception GDB/MI Catchpoint Commands +@subsection C@t{++} Exception @sc{gdb/mi} Catchpoints + +The following @sc{gdb/mi} commands can be used to create catchpoints +that stop the execution when C@t{++} exceptions are being throw, rethrown, +or caught. + +@subheading The @code{-catch-throw} Command +@findex -catch-throw + +@subsubheading Synopsis + +@smallexample + -catch-throw [ -t ] [ -r @var{regexp}] +@end smallexample + +Stop when the debuggee throws a C@t{++} exception. If @var{regexp} is +given, then only exceptions whose type matches the regular expression +will be caught. + +If @samp{-t} is given, then the catchpoint is enabled only for one +stop, the catchpoint is automatically deleted after stopping once for +the event. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} commands are @samp{catch throw} +and @samp{tcatch throw} (@pxref{Set Catchpoints}). + +@subsubheading Example + +@smallexample +-catch-throw -r exception_type +^done,bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y", + addr="0x00000000004006c0",what="exception throw", + catch-type="throw",thread-groups=["i1"], + regexp="exception_type",times="0"@} +(gdb) +-exec-run +^running +(gdb) +~"\n" +~"Catchpoint 1 (exception thrown), 0x00007ffff7ae00ed + in __cxa_throw () from /lib64/libstdc++.so.6\n" +*stopped,bkptno="1",reason="breakpoint-hit",disp="keep", + frame=@{addr="0x00007ffff7ae00ed",func="__cxa_throw", + args=[],from="/lib64/libstdc++.so.6",arch="i386:x86-64"@}, + thread-id="1",stopped-threads="all",core="6" +(gdb) +@end smallexample + +@subheading The @code{-catch-rethrow} Command +@findex -catch-rethrow + +@subsubheading Synopsis + +@smallexample + -catch-rethrow [ -t ] [ -r @var{regexp}] +@end smallexample + +Stop when a C@t{++} exception is re-thrown. If @var{regexp} is given, +then only exceptions whose type matches the regular expression will be +caught. + +If @samp{-t} is given, then the catchpoint is enabled only for one +stop, the catchpoint is automatically deleted after the first event is +caught. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} commands are @samp{catch rethrow} +and @samp{tcatch rethrow} (@pxref{Set Catchpoints}). + +@subsubheading Example + +@smallexample +-catch-rethrow -r exception_type +^done,bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y", + addr="0x00000000004006c0",what="exception rethrow", + catch-type="rethrow",thread-groups=["i1"], + regexp="exception_type",times="0"@} +(gdb) +-exec-run +^running +(gdb) +~"\n" +~"Catchpoint 1 (exception rethrown), 0x00007ffff7ae00ed + in __cxa_rethrow () from /lib64/libstdc++.so.6\n" +*stopped,bkptno="1",reason="breakpoint-hit",disp="keep", + frame=@{addr="0x00007ffff7ae00ed",func="__cxa_rethrow", + args=[],from="/lib64/libstdc++.so.6",arch="i386:x86-64"@}, + thread-id="1",stopped-threads="all",core="6" +(gdb) +@end smallexample + +@subheading The @code{-catch-catch} Command +@findex -catch-catch + +@subsubheading Synopsis + +@smallexample + -catch-catch [ -t ] [ -r @var{regexp}] +@end smallexample + +Stop when the debuggee catches a C@t{++} exception. If @var{regexp} +is given, then only exceptions whose type matches the regular +expression will be caught. + +If @samp{-t} is given, then the catchpoint is enabled only for one +stop, the catchpoint is automatically deleted after the first event is +caught. + +@subsubheading @value{GDBN} Command + +The corresponding @value{GDBN} commands are @samp{catch catch} +and @samp{tcatch catch} (@pxref{Set Catchpoints}). + +@subsubheading Example + +@smallexample +-catch-catch -r exception_type +^done,bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y", + addr="0x00000000004006c0",what="exception catch", + catch-type="catch",thread-groups=["i1"], + regexp="exception_type",times="0"@} +(gdb) +-exec-run +^running +(gdb) +~"\n" +~"Catchpoint 1 (exception caught), 0x00007ffff7ae00ed + in __cxa_begin_catch () from /lib64/libstdc++.so.6\n" +*stopped,bkptno="1",reason="breakpoint-hit",disp="keep", + frame=@{addr="0x00007ffff7ae00ed",func="__cxa_begin_catch", + args=[],from="/lib64/libstdc++.so.6",arch="i386:x86-64"@}, + thread-id="1",stopped-threads="all",core="6" +(gdb) +@end smallexample + @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @node GDB/MI Program Context @section @sc{gdb/mi} Program Context |