diff options
author | Xavier Roirand <roirand@adacore.com> | 2017-11-22 10:40:39 +0100 |
---|---|---|
committer | Xavier Roirand <roirand@adacore.com> | 2018-01-03 11:02:53 +0100 |
commit | 9f757bf7fcb8834ead780e0c4a76d6029b1402c2 (patch) | |
tree | 73e1c8207e49be351b83236f7a9a7a7c0fcb9011 /gdb/doc | |
parent | 219d1afa89d0d53ca93a684cac341f16470f3ca0 (diff) | |
download | gdb-9f757bf7fcb8834ead780e0c4a76d6029b1402c2.zip gdb-9f757bf7fcb8834ead780e0c4a76d6029b1402c2.tar.gz gdb-9f757bf7fcb8834ead780e0c4a76d6029b1402c2.tar.bz2 |
(Ada) New command to stop at start of exception handler.
When using gdb for debugging Ada source code, there are several catchpoint
types you can define in order to stop upon certain conditions. Let's
use this small example:
procedure Foo is
begin
begin
raise Constraint_Error;
exception
when Program_Error =>
null;
when Constraint_Error =>
null;
when others =>
null;
end;
end Foo;
One can stop when the exception is being raised by using the exception
catchpoint like below:
(gdb) catch exception
Catchpoint 1: all Ada exceptions
(gdb)
In that case, when running Foo, gdb will stop at the line where the exception
was raised:
begin
>>> raise Constraint_Error;
exception
This patch introduces new type of catchpoint, when the user wants to stop
at the location of the exception handling.
Imagine we want to stop on any exception handled by the program, we can do:
(gdb) catch handlers
Catchpoint 1: all Ada exceptions handlers
(gdb) r
Starting program: /tmp/foo
By doing so, when running Foo, gdb will stop here:
Catchpoint 1, exception at 0x000000000040255a in foo () at foo.adb:25
25 when Constraint_Error =>
(gdb)
It is also possible to stop when the Constraint_Error exception is being
handled in this program. With this patch, we can use:
(gdb) catch handlers Constraint_Error
Catchpoint 1: `Constraint_Error' Ada exception handlers
(gdb)
Like for other catchpoint, you can set a condition when adding a catchpoint
on exception handlers.
Here the handlers catchpoint checks Global_Var:
(gdb) catch handlers Constraint_Error if Global_Var /= 0
gdb/ChangeLog:
* ada-lang.h (ada_exception_catchpoint_kind) <ada_catch_handlers>:
Add field.
* ada-lang.c (struct exception_support_info) <catch_handlers_sym>:
Add field.
(default_exception_support_info) <catch_handlers_sym>: Add field.
(exception_support_info_fallback) <catch_handlers_sym>: Add field.
(ada_exception_name_addr_1): Add "catch handlers" handling.
(ada_exception_catchpoint_cond_string) <ex>: New parameter.
Update all callers.
(create_excep_cond_exprs) <ex>: Add parameter.
(re_set_exception): Update create_excep_cond_exprs call.
(print_it_exception, print_one_exception, print_mention_exception)
(print_recreate_exception): Add "catch handler" handling.
(allocate_location_catch_handlers, re_set_catch_handlers)
(check_status_catch_handlers, print_it_catch_handlers)
(print_one_catch_handlers, print_mention_catch_handlers)
(print_recreate_catch_handlers): New function.
(catch_handlers_breakpoint_ops): New variable.
(catch_ada_exception_command_split) <is_catch_handlers_cmd>:
Add parameter. Add "catch handler" handling.
(ada_exception_sym_name, ada_exception_breakpoint_ops):
Add "catch handler" handling.
(ada_exception_catchpoint_cond_string): Add "catch handler"
handling.
(create_ada_exception_catchpoint): Update create_excep_cond_exprs
call.
(catch_ada_handlers_command): New function.
(initialize_ada_catchpoint_ops): Initialize "catch handlers"
operations structure.
(_initialize_ada_language): Add "catch handlers" command entry.
* NEWS: Document "catch handlers" feature.
gdb/doc/ChangeLog:
* gdb.texinfo (Set Catchpoints): Add documentation for new
"catch handlers" action.
gdb/testsuite/ChangeLog:
* gdb.ada/excep_handle.exp: New testcase.
* gdb.ada/excep_handle/foo.adb: New file.
* gdb.ada/excep_handle/pck.ads: New file.
Tested on x86_64-linux.
Diffstat (limited to 'gdb/doc')
-rw-r--r-- | gdb/doc/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/doc/gdb.texinfo | 20 |
2 files changed, 25 insertions, 0 deletions
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 6a0dbda..5a3437c 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,8 @@ +2018-01-03 Xavier Roirand <roirand@adacore.com> + + * gdb.texinfo (Set Catchpoints): Add documentation for new + "catch handlers" action. + 2017-12-27 Stafford Horne <shorne@gmail.com> * gdb.texinfo (Target Description Format): Explain that arbitrary diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 6ffba3d..8bdafb0 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -4458,6 +4458,26 @@ called @code{Constraint_Error} is defined in package @code{Pck}, then the command to use to catch such exceptions is @kbd{catch exception Pck.Constraint_Error}. +@item handlers +@kindex catch handlers +@cindex Ada exception handlers catching +@cindex catch Ada exceptions when handled +An Ada exception being handled. If an exception name is +specified at the end of the command + (eg @kbd{catch handlers Program_Error}), the debugger will stop +only when this specific exception is handled. +Otherwise, the debugger stops execution when any Ada exception is handled. + +When inserting a handlers catchpoint on a user-defined +exception whose name is identical to one of the exceptions +defined by the language, the fully qualified name must be used +as the exception name. Otherwise, @value{GDBN} will assume that it +should stop on the pre-defined exception rather than the +user-defined one. For instance, assuming an exception called + @code{Constraint_Error} is defined in package @code{Pck}, then the +command to use to catch such exceptions handling is +@kbd{catch handlers Pck.Constraint_Error}. + @item exception unhandled @kindex catch exception unhandled An exception that was raised but is not handled by the program. |