public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
From: sergiodj+buildbot@sergiodj.net
To: gdb-testers@sourceware.org
Subject: [binutils-gdb] (Ada) New command to stop at start of exception handler.
Date: Wed, 03 Jan 2018 10:27:00 -0000	[thread overview]
Message-ID: <9f757bf7fcb8834ead780e0c4a76d6029b1402c2@gdb-build> (raw)

*** TEST RESULTS FOR COMMIT 9f757bf7fcb8834ead780e0c4a76d6029b1402c2 ***

Author: Xavier Roirand <roirand@adacore.com>
Branch: master
Commit: 9f757bf7fcb8834ead780e0c4a76d6029b1402c2

(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.


             reply	other threads:[~2018-01-03 10:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-03 10:27 sergiodj+buildbot [this message]
2018-01-03 10:27 ` Failures on Fedora-x86_64-m64, branch master sergiodj+buildbot
2018-01-03 10:44 ` Failures on Fedora-i686, " sergiodj+buildbot
2018-01-03 10:44 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " sergiodj+buildbot
2018-01-03 10:47 ` Failures on Ubuntu-AArch64-native-gdbserver-m64, " sergiodj+buildbot
2018-01-03 10:49 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, " sergiodj+buildbot
2018-01-03 10:50 ` Failures on Ubuntu-AArch32-native-extended-gdbserver-m32, " sergiodj+buildbot
2018-01-03 11:03 ` Failures on Fedora-x86_64-native-gdbserver-m64, " sergiodj+buildbot
2018-01-03 11:25 ` Failures on Ubuntu-AArch64-m64, " sergiodj+buildbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9f757bf7fcb8834ead780e0c4a76d6029b1402c2@gdb-build \
    --to=sergiodj+buildbot@sergiodj.net \
    --cc=gdb-testers@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).