public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [commit/Ada 1/4] Rework a bit Ada exception catchpoint support (in prep for GDB/MI)
  2013-10-08 11:48 GDB/MI: New commands to catch Ada exceptions Joel Brobecker
  2013-10-08 11:48 ` [RFA/commit 4/4] Adjust gdb.ada/mi_catch_ex.exp to use GDB/MI catch commands Joel Brobecker
@ 2013-10-08 11:48 ` Joel Brobecker
  2013-10-08 11:48 ` [commit/Ada 2/4] Add "ada_" prefix to enum ada_exception_catchpoint_kind Joel Brobecker
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Joel Brobecker @ 2013-10-08 11:48 UTC (permalink / raw)
  To: gdb-patches

Hello,

This patch reworks a bit how the different steps required to insert
an Ada exception catchpoints are organized. They used to be:

  1. Call a "decode" function which does:
        1.a.  Parse the command and its arguments
        1.b.  Create a SAL & OPS from some of those arguments

  2. Call create_ada_exception_catchpoint using SAL as well
     as some of the arguments extracted above.

The bulk of the change consists in integrating step (1.b) into
step (2) in order to turn create_ada_exception_catchpoint into
a function whose arguments are all user-level concepts. This
paves the way from a straightforward implementation of the equivalent
commands in the GDB/MI interpreter.

gdb/ChangeLog:

        * ada-lang.c (ada_decode_exception_location): Delete.
        (create_ada_exception_catchpoint): Remove arguments "sal",
        "addr_string" and "ops".  Add argument "ex_kind" instead.
        Adjust implementation accordingly, calling ada_exception_sal
        to get the entities it no longer gets passed as arguments.
        Document the function's arguments.
        (catch_ada_exception_command): Use catch_ada_exception_command_split
        instead of ada_decode_exception_location, and update call to
        create_ada_exception_catchpoint.
        (catch_ada_assert_command_split): Renames
        ada_decode_assert_location.  Remove parameters "addr_string" and
        "ops", and now returns void.  Adjust implementation accordingly.
        Update the function documentation.
        (catch_assert_command): Use catch_ada_assert_command_split
        instead of ada_decode_assert_location.  Update call to
        create_ada_exception_catchpoint.

Tested on x86_64-linux. I will check it in in a few days, pending
comments.

-- 
Joel

---
 gdb/ada-lang.c | 79 +++++++++++++++++++++-------------------------------------
 1 file changed, 29 insertions(+), 50 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 9ebc851..d6a6818 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -12175,43 +12175,34 @@ ada_exception_sal (enum exception_catchpoint_kind ex, char *excep_string,
   return find_function_start_sal (sym, 1);
 }
 
-/* Parse the arguments (ARGS) of the "catch exception" command.
- 
-   If the user asked the catchpoint to catch only a specific
-   exception, then save the exception name in ADDR_STRING.
+/* Create an Ada exception catchpoint.
 
-   If the user provided a condition, then set COND_STRING to
-   that condition expression (the memory must be deallocated
-   after use).  Otherwise, set COND_STRING to NULL.
+   EX_KIND is the kind of exception catchpoint to be created.
 
-   See ada_exception_sal for a description of all the remaining
-   function arguments of this function.  */
+   EXCEPT_STRING, if not NULL, indicates the name of the exception
+   to which this catchpoint applies.  If NULL, this catchpoint is
+   expected to trigger for all exceptions.
 
-static struct symtab_and_line
-ada_decode_exception_location (char *args, char **addr_string,
-                               char **excep_string,
-			       char **cond_string,
-                               const struct breakpoint_ops **ops)
-{
-  enum exception_catchpoint_kind ex;
+   COND_STRING, if not NULL, is the catchpoint condition.
 
-  catch_ada_exception_command_split (args, &ex, excep_string, cond_string);
-  return ada_exception_sal (ex, *excep_string, addr_string, ops);
-}
+   TEMPFLAG, if nonzero, means that the underlying breakpoint
+   should be temporary.
 
-/* Create an Ada exception catchpoint.  */
+   FROM_TTY is the usual argument passed to all commands implementations.  */
 
 static void
 create_ada_exception_catchpoint (struct gdbarch *gdbarch,
-				 struct symtab_and_line sal,
-				 char *addr_string,
+				 enum exception_catchpoint_kind ex_kind,
 				 char *excep_string,
 				 char *cond_string,
-				 const struct breakpoint_ops *ops,
 				 int tempflag,
 				 int from_tty)
 {
   struct ada_catchpoint *c;
+  char *addr_string = NULL;
+  const struct breakpoint_ops *ops = NULL;
+  struct symtab_and_line sal
+    = ada_exception_sal (ex_kind, excep_string, &addr_string, &ops);
 
   c = XNEW (struct ada_catchpoint);
   init_ada_exception_breakpoint (&c->base, gdbarch, sal, addr_string,
@@ -12231,38 +12222,31 @@ catch_ada_exception_command (char *arg, int from_tty,
 {
   struct gdbarch *gdbarch = get_current_arch ();
   int tempflag;
-  struct symtab_and_line sal;
-  char *addr_string = NULL;
+  enum exception_catchpoint_kind ex_kind;
   char *excep_string = NULL;
   char *cond_string = NULL;
-  const struct breakpoint_ops *ops = NULL;
 
   tempflag = get_cmd_context (command) == CATCH_TEMPORARY;
 
   if (!arg)
     arg = "";
-  sal = ada_decode_exception_location (arg, &addr_string, &excep_string,
-				       &cond_string, &ops);
-  create_ada_exception_catchpoint (gdbarch, sal, addr_string,
-				   excep_string, cond_string, ops,
+  catch_ada_exception_command_split (arg, &ex_kind, &excep_string,
+				     &cond_string);
+  create_ada_exception_catchpoint (gdbarch, ex_kind,
+				   excep_string, cond_string,
 				   tempflag, from_tty);
 }
 
-/* Assuming that ARGS contains the arguments of a "catch assert"
-   command, parse those arguments and return a symtab_and_line object
-   for a failed assertion catchpoint.
+/* Split the arguments specified in a "catch assert" command.
 
-   Set ADDR_STRING to the name of the function where the real
-   breakpoint that implements the catchpoint is set.
+   ARGS contains the command's arguments (or the empty string if
+   no arguments were passed).
 
    If ARGS contains a condition, set COND_STRING to that condition
-   (the memory needs to be deallocated after use).  Otherwise, set
-   COND_STRING to NULL.  */
+   (the memory needs to be deallocated after use).  */
 
-static struct symtab_and_line
-ada_decode_assert_location (char *args, char **addr_string,
-			    char **cond_string,
-                            const struct breakpoint_ops **ops)
+static void
+catch_ada_assert_command_split (char *args, char **cond_string)
 {
   args = skip_spaces (args);
 
@@ -12281,8 +12265,6 @@ ada_decode_assert_location (char *args, char **addr_string,
      the command.  */
   else if (args[0] != '\0')
     error (_("Junk at end of arguments."));
-
-  return ada_exception_sal (ex_catch_assert, NULL, addr_string, ops);
 }
 
 /* Implement the "catch assert" command.  */
@@ -12293,19 +12275,16 @@ catch_assert_command (char *arg, int from_tty,
 {
   struct gdbarch *gdbarch = get_current_arch ();
   int tempflag;
-  struct symtab_and_line sal;
-  char *addr_string = NULL;
   char *cond_string = NULL;
-  const struct breakpoint_ops *ops = NULL;
 
   tempflag = get_cmd_context (command) == CATCH_TEMPORARY;
 
   if (!arg)
     arg = "";
-  sal = ada_decode_assert_location (arg, &addr_string, &cond_string, &ops);
-  create_ada_exception_catchpoint (gdbarch, sal, addr_string,
-				   NULL, cond_string, ops, tempflag,
-				   from_tty);
+  catch_ada_assert_command_split (arg, &cond_string);
+  create_ada_exception_catchpoint (gdbarch, ex_catch_assert,
+				   NULL, cond_string,
+				   tempflag, from_tty);
 }
                                 /* Operators */
 /* Information about operators given special treatment in functions
-- 
1.8.1.2

^ permalink raw reply	[flat|nested] 11+ messages in thread

* GDB/MI: New commands to catch Ada exceptions
@ 2013-10-08 11:48 Joel Brobecker
  2013-10-08 11:48 ` [RFA/commit 4/4] Adjust gdb.ada/mi_catch_ex.exp to use GDB/MI catch commands Joel Brobecker
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Joel Brobecker @ 2013-10-08 11:48 UTC (permalink / raw)
  To: gdb-patches

Hello,

This patch series introduces two new GDB/MI commands to catch
Ada exceptions, implementing the equivalent of the "catch exception"
and "catch assert" CLI commands. I will present these commands
in the patch that actually implements them.

The first couple of patches are ada-lang.c cleanups, self contained
and useful on their own, so I think I will be checking them in
in a few days, pending comments.

The 3rd patch is the actual patch adding the new commands.

And the 4th patch updates an already-existing testcase that
was already testing Ada exception catching in GDB/MI mode, but
using the CLI ("catch ...") commands instead.

This is a bit of an RFC/RFA, as the patch introduces new commands,
and I want to make sure that we're happy with the user interface.
Once we've agreed on the commands' interface, I will write the NEWS
and doco patches.

Thank you!

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [RFA/RFC 3/4] New GDB/MI commands to catch Ada exceptions
  2013-10-08 11:48 GDB/MI: New commands to catch Ada exceptions Joel Brobecker
                   ` (2 preceding siblings ...)
  2013-10-08 11:48 ` [commit/Ada 2/4] Add "ada_" prefix to enum ada_exception_catchpoint_kind Joel Brobecker
@ 2013-10-08 11:48 ` Joel Brobecker
  2013-10-10 20:50 ` GDB/MI: New " Tom Tromey
  2013-10-11 10:44 ` [RFA/doco+NEWS] Document the -catch-assert and -catch-exception new GDB/MI commands Joel Brobecker
  5 siblings, 0 replies; 11+ messages in thread
From: Joel Brobecker @ 2013-10-08 11:48 UTC (permalink / raw)
  To: gdb-patches

This patch introduces two new GDB/MI commands implementing the equivalent
of the "catch exception" and  "catch assert" GDB/CLI commands. They are:

  -catch-exception [-c COND] [-d] [-e EXCEPTION_NAME] [-t] [-u]
  -catch-assert [-c COND] [-d] [-t]

The options mean:

  -c COND: Attach the given condition to the catchpoint
  -d: Make the newly created catchpoint disabled.
  -e EXCEPTION_NAME: The catchpoint will only stop when EXCEPTION_NAME
      is raised, and ignore other exceptions.
  -t: Create a temporary catchpoint
  -u: The catchpoint will only stop when an unhandled exception gets raised.

The command names are mapped directly from their CLI counterparts
("catch exception" and "catch assert"), and the options try to follow
the general scheme used by -break-insert or -catch-load. I am happy
making any change to their name of the options if it makes sense.

gdb/ChangeLog:

        * breakpoint.h (init_ada_exception_breakpoint): Add parameter
        "enabled".
        * breakpoint.c (init_ada_exception_breakpoint): Add parameter
        "enabled".  Set B->ENABLE_STATE accordingly.
        * ada-lang.h (ada_exception_catchpoint_kind): Move here from
        ada-lang.c.
        (create_ada_exception_catchpoint): Add declaration.
        * ada-lang.c (ada_exception_catchpoint_kind): Move to ada-lang.h.
        (create_ada_exception_catchpoint): Make non-static. Add new
        parameter "disabled". Use it in call to
        init_ada_exception_breakpoint.
        (catch_ada_exception_command): Add parameter "enabled" in call
        to create_ada_exception_catchpoint.
        (catch_assert_command): Likewise.

        * mi/mi-cmds.h (mi_cmd_catch_assert, mi_cmd_catch_exception):
        Add declarations.
        * mi/mi-cmds.c (mi_cmds): Add the "catch-assert" and
        "catch-exception" commands.
        * mi/mi-cmd-catch.c: Add #include "ada-lang.h".
        (mi_cmd_catch_assert, mi_cmd_catch_exception): New functions.

Tested on x86_64-linux.  Thoughts?

Thank you!
-- 
Joel

---
 gdb/ada-lang.c        |  21 +++-----
 gdb/ada-lang.h        |  15 ++++++
 gdb/breakpoint.c      |   3 +-
 gdb/breakpoint.h      |   1 +
 gdb/mi/mi-cmd-catch.c | 131 ++++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/mi/mi-cmds.c      |   4 ++
 gdb/mi/mi-cmds.h      |   2 +
 7 files changed, 162 insertions(+), 15 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 3c7e4cf..9ff3ab9 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -10981,16 +10981,6 @@ ada_modulus (struct type *type)
    variants of the runtime, we use a sniffer that will determine
    the runtime variant used by the program being debugged.  */
 
-/* The different types of catchpoints that we introduced for catching
-   Ada exceptions.  */
-
-enum ada_exception_catchpoint_kind
-{
-  ada_catch_exception,
-  ada_catch_exception_unhandled,
-  ada_catch_assert
-};
-
 /* Ada's standard exceptions.  */
 
 static char *standard_exc[] = {
@@ -12190,12 +12180,13 @@ ada_exception_sal (enum ada_exception_catchpoint_kind ex, char *excep_string,
 
    FROM_TTY is the usual argument passed to all commands implementations.  */
 
-static void
+void
 create_ada_exception_catchpoint (struct gdbarch *gdbarch,
 				 enum ada_exception_catchpoint_kind ex_kind,
 				 char *excep_string,
 				 char *cond_string,
 				 int tempflag,
+				 int disabled,
 				 int from_tty)
 {
   struct ada_catchpoint *c;
@@ -12206,7 +12197,7 @@ create_ada_exception_catchpoint (struct gdbarch *gdbarch,
 
   c = XNEW (struct ada_catchpoint);
   init_ada_exception_breakpoint (&c->base, gdbarch, sal, addr_string,
-				 ops, tempflag, from_tty);
+				 ops, tempflag, disabled, from_tty);
   c->excep_string = excep_string;
   create_excep_cond_exprs (c);
   if (cond_string != NULL)
@@ -12234,7 +12225,8 @@ catch_ada_exception_command (char *arg, int from_tty,
 				     &cond_string);
   create_ada_exception_catchpoint (gdbarch, ex_kind,
 				   excep_string, cond_string,
-				   tempflag, from_tty);
+				   tempflag, 1 /* enabled */,
+				   from_tty);
 }
 
 /* Split the arguments specified in a "catch assert" command.
@@ -12284,7 +12276,8 @@ catch_assert_command (char *arg, int from_tty,
   catch_ada_assert_command_split (arg, &cond_string);
   create_ada_exception_catchpoint (gdbarch, ada_catch_assert,
 				   NULL, cond_string,
-				   tempflag, from_tty);
+				   tempflag, 1 /* enabled */,
+				   from_tty);
 }
                                 /* Operators */
 /* Information about operators given special treatment in functions
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index 4ea25b8..151ced8 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -114,6 +114,16 @@ enum ada_renaming_category
     ADA_SUBPROGRAM_RENAMING
   };
 
+/* The different types of catchpoints that we introduced for catching
+   Ada exceptions.  */
+
+enum ada_exception_catchpoint_kind
+{
+  ada_catch_exception,
+  ada_catch_exception_unhandled,
+  ada_catch_assert
+};
+
 /* Ada task structures.  */
 
 struct ada_task_info
@@ -374,6 +384,11 @@ extern char *ada_main_name (void);
 
 extern char *ada_name_for_lookup (const char *name);
 
+extern void create_ada_exception_catchpoint
+  (struct gdbarch *gdbarch, enum ada_exception_catchpoint_kind ex_kind,
+   char *excep_string, char *cond_string, int tempflag, int disabled,
+   int from_tty);
+
 /* Tasking-related: ada-tasks.c */
 
 extern int valid_task_id (int);
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index d3e9e49..c31756d 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -11620,6 +11620,7 @@ init_ada_exception_breakpoint (struct breakpoint *b,
 			       char *addr_string,
 			       const struct breakpoint_ops *ops,
 			       int tempflag,
+			       int enabled,
 			       int from_tty)
 {
   if (from_tty)
@@ -11642,7 +11643,7 @@ init_ada_exception_breakpoint (struct breakpoint *b,
 
   init_raw_breakpoint (b, gdbarch, sal, bp_breakpoint, ops);
 
-  b->enable_state = bp_enabled;
+  b->enable_state = enabled ? bp_enabled : bp_disabled;
   b->disposition = tempflag ? disp_del : disp_donttouch;
   b->addr_string = addr_string;
   b->language = language_ada;
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index faedb4a..4a25fb7 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -1238,6 +1238,7 @@ extern void
 				 char *addr_string,
 				 const struct breakpoint_ops *ops,
 				 int tempflag,
+				 int enabled,
 				 int from_tty);
 
 extern void init_catchpoint (struct breakpoint *b,
diff --git a/gdb/mi/mi-cmd-catch.c b/gdb/mi/mi-cmd-catch.c
index cd932fe..23e30d0 100644
--- a/gdb/mi/mi-cmd-catch.c
+++ b/gdb/mi/mi-cmd-catch.c
@@ -23,10 +23,141 @@
 #include "breakpoint.h"
 #include "gdb.h"
 #include "libiberty.h"
+#include "ada-lang.h"
 #include "mi-cmds.h"
 #include "mi-getopt.h"
 #include "mi-cmd-break.h"
 
+/* Handler for the -catch-assert command.  */
+
+void
+mi_cmd_catch_assert (char *cmd, char *argv[], int argc)
+{
+  struct gdbarch *gdbarch = get_current_arch();
+  char *condition = NULL;
+  int enabled = 1;
+  int temp = 0;
+
+  int oind = 0;
+  char *oarg;
+
+  enum opt
+    {
+      OPT_CONDITION, OPT_DISABLED, OPT_TEMP,
+    };
+  static const struct mi_opt opts[] =
+    {
+      { "c", OPT_CONDITION, 1},
+      { "d", OPT_DISABLED, 0 },
+      { "t", OPT_TEMP, 0 },
+      { 0, 0, 0 }
+    };
+
+  for (;;)
+    {
+      int opt = mi_getopt ("-catch-assert", argc, argv, opts,
+			   &oind, &oarg);
+
+      if (opt < 0)
+        break;
+
+      switch ((enum opt) opt)
+        {
+	case OPT_CONDITION:
+	  condition = oarg;
+	  break;
+	case OPT_DISABLED:
+	  enabled = 0;
+	  break;
+	case OPT_TEMP:
+	  temp = 1;
+	  break;
+        }
+    }
+
+  /* This command does not accept any argument.  Make sure the user
+     did not provide any.  */
+  if (oind != argc)
+    error (_("Invalid argument: %s"), argv[oind]);
+
+  setup_breakpoint_reporting ();
+  create_ada_exception_catchpoint (gdbarch, ada_catch_assert,
+				   NULL, condition, temp, enabled, 0);
+}
+
+/* Handler for the -catch-exception command.  */
+
+void
+mi_cmd_catch_exception (char *cmd, char *argv[], int argc)
+{
+  struct gdbarch *gdbarch = get_current_arch();
+  char *condition = NULL;
+  int enabled = 1;
+  char *exception_name = NULL;
+  int temp = 0;
+  enum ada_exception_catchpoint_kind ex_kind = ada_catch_exception;
+
+  int oind = 0;
+  char *oarg;
+
+  enum opt
+    {
+      OPT_CONDITION, OPT_DISABLED, OPT_EXCEPTION_NAME, OPT_TEMP,
+      OPT_UNHANDLED,
+    };
+  static const struct mi_opt opts[] =
+    {
+      { "c", OPT_CONDITION, 1},
+      { "d", OPT_DISABLED, 0 },
+      { "e", OPT_EXCEPTION_NAME, 1 },
+      { "t", OPT_TEMP, 0 },
+      { "u", OPT_UNHANDLED, 0},
+      { 0, 0, 0 }
+    };
+
+  for (;;)
+    {
+      int opt = mi_getopt ("-catch-exception", argc, argv, opts,
+			   &oind, &oarg);
+
+      if (opt < 0)
+        break;
+
+      switch ((enum opt) opt)
+        {
+	case OPT_CONDITION:
+	  condition = oarg;
+	  break;
+	case OPT_DISABLED:
+	  enabled = 0;
+	  break;
+	case OPT_EXCEPTION_NAME:
+	  exception_name = oarg;
+	  break;
+	case OPT_TEMP:
+	  temp = 1;
+	  break;
+	case OPT_UNHANDLED:
+	  ex_kind = ada_catch_exception_unhandled;
+	  break;
+        }
+    }
+
+  /* This command does not accept any argument.  Make sure the user
+     did not provide any.  */
+  if (oind != argc)
+    error (_("Invalid argument: %s"), argv[oind]);
+
+  /* Specifying an exception name does not make sense when requesting
+     an unhandled exception breakpoint.  */
+  if (ex_kind == ada_catch_exception_unhandled && exception_name != NULL)
+    error (_("\"-e\" and \"-u\" are mutually exclusive"));
+
+  setup_breakpoint_reporting ();
+  create_ada_exception_catchpoint (gdbarch, ex_kind,
+				   exception_name, condition,
+				   temp, enabled, 0);
+}
 
 /* Common path for the -catch-load and -catch-unload.  */
 
diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c
index 0768b2a..1b8ec92 100644
--- a/gdb/mi/mi-cmds.c
+++ b/gdb/mi/mi-cmds.c
@@ -68,6 +68,10 @@ static struct mi_cmd mi_cmds[] =
 		   &mi_suppress_notification.breakpoint),
   DEF_MI_CMD_MI_1 ("break-watch", mi_cmd_break_watch,
 		   &mi_suppress_notification.breakpoint),
+  DEF_MI_CMD_MI_1 ("catch-assert", mi_cmd_catch_assert,
+                   &mi_suppress_notification.breakpoint),
+  DEF_MI_CMD_MI_1 ("catch-exception", mi_cmd_catch_exception,
+                   &mi_suppress_notification.breakpoint),
   DEF_MI_CMD_MI_1 ("catch-load", mi_cmd_catch_load,
                    &mi_suppress_notification.breakpoint),
   DEF_MI_CMD_MI_1 ("catch-unload", mi_cmd_catch_unload,
diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h
index a472582..bbca54d 100644
--- a/gdb/mi/mi-cmds.h
+++ b/gdb/mi/mi-cmds.h
@@ -39,6 +39,8 @@ extern mi_cmd_argv_ftype mi_cmd_dprintf_insert;
 extern mi_cmd_argv_ftype mi_cmd_break_commands;
 extern mi_cmd_argv_ftype mi_cmd_break_passcount;
 extern mi_cmd_argv_ftype mi_cmd_break_watch;
+extern mi_cmd_argv_ftype mi_cmd_catch_assert;
+extern mi_cmd_argv_ftype mi_cmd_catch_exception;
 extern mi_cmd_argv_ftype mi_cmd_catch_load;
 extern mi_cmd_argv_ftype mi_cmd_catch_unload;
 extern mi_cmd_argv_ftype mi_cmd_disassemble;
-- 
1.8.1.2

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [RFA/commit 4/4] Adjust gdb.ada/mi_catch_ex.exp to use GDB/MI catch commands...
  2013-10-08 11:48 GDB/MI: New commands to catch Ada exceptions Joel Brobecker
@ 2013-10-08 11:48 ` Joel Brobecker
  2013-10-08 11:48 ` [commit/Ada 1/4] Rework a bit Ada exception catchpoint support (in prep for GDB/MI) Joel Brobecker
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Joel Brobecker @ 2013-10-08 11:48 UTC (permalink / raw)
  To: gdb-patches

... in place of the CLI "catch ..." commands.  The latter were used
because the GDB/MI equivalents were not available at the time.

gdb/testsuite/ChangeLog:

        * gdb.ada/mi_catch_ex.exp: Adjusts all "catch ..." tests to
        use the appropriate GDB/MI command instead, and verify
        the test output.

Tested on x86_64-linux.
It's sufficiently straightforward that I'm tempted to call it obvious.
Hence the "commit" in "RFA/commit".

-- 
Joel

---
 gdb/testsuite/gdb.ada/mi_catch_ex.exp | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/gdb/testsuite/gdb.ada/mi_catch_ex.exp b/gdb/testsuite/gdb.ada/mi_catch_ex.exp
index d30d44b..f26fcdf 100644
--- a/gdb/testsuite/gdb.ada/mi_catch_ex.exp
+++ b/gdb/testsuite/gdb.ada/mi_catch_ex.exp
@@ -74,7 +74,9 @@ if ![mi_run_to_main] then {
    return 0
 }
 
-mi_gdb_test "catch exception"
+mi_gdb_test "-catch-exception" \
+            "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",addr=\"$hex\",what=\"all Ada exceptions\",.*}" \
+            "catch all exceptions"
 
 mi_execute_to "exec-continue" \
               "breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb\",exception-name=\"CONSTRAINT_ERROR" \
@@ -107,11 +109,17 @@ if ![mi_run_to_main] then {
    return 0
 }
 
-mi_gdb_test "catch exception Program_Error"
+mi_gdb_test "-catch-exception -e Program_Error" \
+            "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",addr=\"$hex\",what=\"`Program_Error' Ada exception\",.*}" \
+            "catch Program_Error"
 
-mi_gdb_test "catch assert"
+mi_gdb_test "-catch-assert" \
+            "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",addr=\"$hex\",what=\"failed Ada assertions\",.*}" \
+            "catch assert failures"
 
-mi_gdb_test "catch exception unhandled"
+mi_gdb_test "-catch-exception -u" \
+            "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",addr=\"$hex\",what=\"unhandled Ada exceptions\",.*}" \
+            "catch unhandled exceptions"
 
 mi_execute_to "exec-continue" \
               "breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb\",exception-name=\"PROGRAM_ERROR" \
-- 
1.8.1.2

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [commit/Ada 2/4] Add "ada_" prefix to enum ada_exception_catchpoint_kind
  2013-10-08 11:48 GDB/MI: New commands to catch Ada exceptions Joel Brobecker
  2013-10-08 11:48 ` [RFA/commit 4/4] Adjust gdb.ada/mi_catch_ex.exp to use GDB/MI catch commands Joel Brobecker
  2013-10-08 11:48 ` [commit/Ada 1/4] Rework a bit Ada exception catchpoint support (in prep for GDB/MI) Joel Brobecker
@ 2013-10-08 11:48 ` Joel Brobecker
  2013-10-08 11:48 ` [RFA/RFC 3/4] New GDB/MI commands to catch Ada exceptions Joel Brobecker
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Joel Brobecker @ 2013-10-08 11:48 UTC (permalink / raw)
  To: gdb-patches

This is in preparation for making that type public, in order to be
able to use make create_ada_exception_catchpoint public as well,
making it usable from the GDB/MI implementation.

Although this change wouldn't be as important if the type was to remain
private, I find it useful on its own as well, as I don't find the "ex_"
prefix to be all that intuitive.

gdb/ChangeLog:

        * ada-lang.c (enum ada_exception_catchpoint_kind): Renames
        "enum exception_catchpoint_kind".  Replace the "ex_" prefix
        of all its enumerates with "ada_".  Update the rest of this
        file throughout.

Tested on x86_64-linux.  I'd like to commit in a few days, pending
comments.

-- 
Joel

---
 gdb/ada-lang.c | 140 ++++++++++++++++++++++++++++-----------------------------
 1 file changed, 70 insertions(+), 70 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index d6a6818..3c7e4cf 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -10984,11 +10984,11 @@ ada_modulus (struct type *type)
 /* The different types of catchpoints that we introduced for catching
    Ada exceptions.  */
 
-enum exception_catchpoint_kind
+enum ada_exception_catchpoint_kind
 {
-  ex_catch_exception,
-  ex_catch_exception_unhandled,
-  ex_catch_assert
+  ada_catch_exception,
+  ada_catch_exception_unhandled,
+  ada_catch_assert
 };
 
 /* Ada's standard exceptions.  */
@@ -11312,22 +11312,22 @@ ada_unhandled_exception_name_addr_from_raise (void)
    Return zero if the address could not be computed, or if not relevant.  */
 
 static CORE_ADDR
-ada_exception_name_addr_1 (enum exception_catchpoint_kind ex,
+ada_exception_name_addr_1 (enum ada_exception_catchpoint_kind ex,
                            struct breakpoint *b)
 {
   struct ada_inferior_data *data = get_ada_inferior_data (current_inferior ());
 
   switch (ex)
     {
-      case ex_catch_exception:
+      case ada_catch_exception:
         return (parse_and_eval_address ("e.full_name"));
         break;
 
-      case ex_catch_exception_unhandled:
+      case ada_catch_exception_unhandled:
         return data->exception_info->unhandled_exception_name_addr ();
         break;
       
-      case ex_catch_assert:
+      case ada_catch_assert:
         return 0;  /* Exception name is not relevant in this case.  */
         break;
 
@@ -11345,7 +11345,7 @@ ada_exception_name_addr_1 (enum exception_catchpoint_kind ex,
    and zero is returned.  */
 
 static CORE_ADDR
-ada_exception_name_addr (enum exception_catchpoint_kind ex,
+ada_exception_name_addr (enum ada_exception_catchpoint_kind ex,
                          struct breakpoint *b)
 {
   volatile struct gdb_exception e;
@@ -11485,7 +11485,7 @@ create_excep_cond_exprs (struct ada_catchpoint *c)
    exception catchpoint kinds.  */
 
 static void
-dtor_exception (enum exception_catchpoint_kind ex, struct breakpoint *b)
+dtor_exception (enum ada_exception_catchpoint_kind ex, struct breakpoint *b)
 {
   struct ada_catchpoint *c = (struct ada_catchpoint *) b;
 
@@ -11498,7 +11498,7 @@ dtor_exception (enum exception_catchpoint_kind ex, struct breakpoint *b)
    structure for all exception catchpoint kinds.  */
 
 static struct bp_location *
-allocate_location_exception (enum exception_catchpoint_kind ex,
+allocate_location_exception (enum ada_exception_catchpoint_kind ex,
 			     struct breakpoint *self)
 {
   struct ada_catchpoint_location *loc;
@@ -11513,7 +11513,7 @@ allocate_location_exception (enum exception_catchpoint_kind ex,
    exception catchpoint kinds.  */
 
 static void
-re_set_exception (enum exception_catchpoint_kind ex, struct breakpoint *b)
+re_set_exception (enum ada_exception_catchpoint_kind ex, struct breakpoint *b)
 {
   struct ada_catchpoint *c = (struct ada_catchpoint *) b;
 
@@ -11569,7 +11569,7 @@ should_stop_exception (const struct bp_location *bl)
    for all exception catchpoint kinds.  */
 
 static void
-check_status_exception (enum exception_catchpoint_kind ex, bpstat bs)
+check_status_exception (enum ada_exception_catchpoint_kind ex, bpstat bs)
 {
   bs->stop = should_stop_exception (bs->bp_location_at);
 }
@@ -11578,7 +11578,7 @@ check_status_exception (enum exception_catchpoint_kind ex, bpstat bs)
    for all exception catchpoint kinds.  */
 
 static enum print_stop_action
-print_it_exception (enum exception_catchpoint_kind ex, bpstat bs)
+print_it_exception (enum ada_exception_catchpoint_kind ex, bpstat bs)
 {
   struct ui_out *uiout = current_uiout;
   struct breakpoint *b = bs->breakpoint_at;
@@ -11600,8 +11600,8 @@ print_it_exception (enum exception_catchpoint_kind ex, bpstat bs)
 
   switch (ex)
     {
-      case ex_catch_exception:
-      case ex_catch_exception_unhandled:
+      case ada_catch_exception:
+      case ada_catch_exception_unhandled:
 	{
 	  const CORE_ADDR addr = ada_exception_name_addr (ex, b);
 	  char exception_name[256];
@@ -11627,12 +11627,12 @@ print_it_exception (enum exception_catchpoint_kind ex, bpstat bs)
 	     it clearer to the user which kind of catchpoint just got
 	     hit.  We used ui_out_text to make sure that this extra
 	     info does not pollute the exception name in the MI case.  */
-	  if (ex == ex_catch_exception_unhandled)
+	  if (ex == ada_catch_exception_unhandled)
 	    ui_out_text (uiout, "unhandled ");
 	  ui_out_field_string (uiout, "exception-name", exception_name);
 	}
 	break;
-      case ex_catch_assert:
+      case ada_catch_assert:
 	/* In this case, the name of the exception is not really
 	   important.  Just print "failed assertion" to make it clearer
 	   that his program just hit an assertion-failure catchpoint.
@@ -11651,7 +11651,7 @@ print_it_exception (enum exception_catchpoint_kind ex, bpstat bs)
    for all exception catchpoint kinds.  */
 
 static void
-print_one_exception (enum exception_catchpoint_kind ex,
+print_one_exception (enum ada_exception_catchpoint_kind ex,
                      struct breakpoint *b, struct bp_location **last_loc)
 { 
   struct ui_out *uiout = current_uiout;
@@ -11669,7 +11669,7 @@ print_one_exception (enum exception_catchpoint_kind ex,
   *last_loc = b->loc;
   switch (ex)
     {
-      case ex_catch_exception:
+      case ada_catch_exception:
         if (c->excep_string != NULL)
           {
             char *msg = xstrprintf (_("`%s' Ada exception"), c->excep_string);
@@ -11682,11 +11682,11 @@ print_one_exception (enum exception_catchpoint_kind ex,
         
         break;
 
-      case ex_catch_exception_unhandled:
+      case ada_catch_exception_unhandled:
         ui_out_field_string (uiout, "what", "unhandled Ada exceptions");
         break;
       
-      case ex_catch_assert:
+      case ada_catch_assert:
         ui_out_field_string (uiout, "what", "failed Ada assertions");
         break;
 
@@ -11700,7 +11700,7 @@ print_one_exception (enum exception_catchpoint_kind ex,
    for all exception catchpoint kinds.  */
 
 static void
-print_mention_exception (enum exception_catchpoint_kind ex,
+print_mention_exception (enum ada_exception_catchpoint_kind ex,
                          struct breakpoint *b)
 {
   struct ada_catchpoint *c = (struct ada_catchpoint *) b;
@@ -11713,7 +11713,7 @@ print_mention_exception (enum exception_catchpoint_kind ex,
 
   switch (ex)
     {
-      case ex_catch_exception:
+      case ada_catch_exception:
         if (c->excep_string != NULL)
 	  {
 	    char *info = xstrprintf (_("`%s' Ada exception"), c->excep_string);
@@ -11726,11 +11726,11 @@ print_mention_exception (enum exception_catchpoint_kind ex,
           ui_out_text (uiout, _("all Ada exceptions"));
         break;
 
-      case ex_catch_exception_unhandled:
+      case ada_catch_exception_unhandled:
         ui_out_text (uiout, _("unhandled Ada exceptions"));
         break;
       
-      case ex_catch_assert:
+      case ada_catch_assert:
         ui_out_text (uiout, _("failed Ada assertions"));
         break;
 
@@ -11744,24 +11744,24 @@ print_mention_exception (enum exception_catchpoint_kind ex,
    for all exception catchpoint kinds.  */
 
 static void
-print_recreate_exception (enum exception_catchpoint_kind ex,
+print_recreate_exception (enum ada_exception_catchpoint_kind ex,
 			  struct breakpoint *b, struct ui_file *fp)
 {
   struct ada_catchpoint *c = (struct ada_catchpoint *) b;
 
   switch (ex)
     {
-      case ex_catch_exception:
+      case ada_catch_exception:
 	fprintf_filtered (fp, "catch exception");
 	if (c->excep_string != NULL)
 	  fprintf_filtered (fp, " %s", c->excep_string);
 	break;
 
-      case ex_catch_exception_unhandled:
+      case ada_catch_exception_unhandled:
 	fprintf_filtered (fp, "catch exception unhandled");
 	break;
 
-      case ex_catch_assert:
+      case ada_catch_assert:
 	fprintf_filtered (fp, "catch assert");
 	break;
 
@@ -11776,49 +11776,49 @@ print_recreate_exception (enum exception_catchpoint_kind ex,
 static void
 dtor_catch_exception (struct breakpoint *b)
 {
-  dtor_exception (ex_catch_exception, b);
+  dtor_exception (ada_catch_exception, b);
 }
 
 static struct bp_location *
 allocate_location_catch_exception (struct breakpoint *self)
 {
-  return allocate_location_exception (ex_catch_exception, self);
+  return allocate_location_exception (ada_catch_exception, self);
 }
 
 static void
 re_set_catch_exception (struct breakpoint *b)
 {
-  re_set_exception (ex_catch_exception, b);
+  re_set_exception (ada_catch_exception, b);
 }
 
 static void
 check_status_catch_exception (bpstat bs)
 {
-  check_status_exception (ex_catch_exception, bs);
+  check_status_exception (ada_catch_exception, bs);
 }
 
 static enum print_stop_action
 print_it_catch_exception (bpstat bs)
 {
-  return print_it_exception (ex_catch_exception, bs);
+  return print_it_exception (ada_catch_exception, bs);
 }
 
 static void
 print_one_catch_exception (struct breakpoint *b, struct bp_location **last_loc)
 {
-  print_one_exception (ex_catch_exception, b, last_loc);
+  print_one_exception (ada_catch_exception, b, last_loc);
 }
 
 static void
 print_mention_catch_exception (struct breakpoint *b)
 {
-  print_mention_exception (ex_catch_exception, b);
+  print_mention_exception (ada_catch_exception, b);
 }
 
 static void
 print_recreate_catch_exception (struct breakpoint *b, struct ui_file *fp)
 {
-  print_recreate_exception (ex_catch_exception, b, fp);
+  print_recreate_exception (ada_catch_exception, b, fp);
 }
 
 static struct breakpoint_ops catch_exception_breakpoint_ops;
@@ -11828,51 +11828,51 @@ static struct breakpoint_ops catch_exception_breakpoint_ops;
 static void
 dtor_catch_exception_unhandled (struct breakpoint *b)
 {
-  dtor_exception (ex_catch_exception_unhandled, b);
+  dtor_exception (ada_catch_exception_unhandled, b);
 }
 
 static struct bp_location *
 allocate_location_catch_exception_unhandled (struct breakpoint *self)
 {
-  return allocate_location_exception (ex_catch_exception_unhandled, self);
+  return allocate_location_exception (ada_catch_exception_unhandled, self);
 }
 
 static void
 re_set_catch_exception_unhandled (struct breakpoint *b)
 {
-  re_set_exception (ex_catch_exception_unhandled, b);
+  re_set_exception (ada_catch_exception_unhandled, b);
 }
 
 static void
 check_status_catch_exception_unhandled (bpstat bs)
 {
-  check_status_exception (ex_catch_exception_unhandled, bs);
+  check_status_exception (ada_catch_exception_unhandled, bs);
 }
 
 static enum print_stop_action
 print_it_catch_exception_unhandled (bpstat bs)
 {
-  return print_it_exception (ex_catch_exception_unhandled, bs);
+  return print_it_exception (ada_catch_exception_unhandled, bs);
 }
 
 static void
 print_one_catch_exception_unhandled (struct breakpoint *b,
 				     struct bp_location **last_loc)
 {
-  print_one_exception (ex_catch_exception_unhandled, b, last_loc);
+  print_one_exception (ada_catch_exception_unhandled, b, last_loc);
 }
 
 static void
 print_mention_catch_exception_unhandled (struct breakpoint *b)
 {
-  print_mention_exception (ex_catch_exception_unhandled, b);
+  print_mention_exception (ada_catch_exception_unhandled, b);
 }
 
 static void
 print_recreate_catch_exception_unhandled (struct breakpoint *b,
 					  struct ui_file *fp)
 {
-  print_recreate_exception (ex_catch_exception_unhandled, b, fp);
+  print_recreate_exception (ada_catch_exception_unhandled, b, fp);
 }
 
 static struct breakpoint_ops catch_exception_unhandled_breakpoint_ops;
@@ -11882,49 +11882,49 @@ static struct breakpoint_ops catch_exception_unhandled_breakpoint_ops;
 static void
 dtor_catch_assert (struct breakpoint *b)
 {
-  dtor_exception (ex_catch_assert, b);
+  dtor_exception (ada_catch_assert, b);
 }
 
 static struct bp_location *
 allocate_location_catch_assert (struct breakpoint *self)
 {
-  return allocate_location_exception (ex_catch_assert, self);
+  return allocate_location_exception (ada_catch_assert, self);
 }
 
 static void
 re_set_catch_assert (struct breakpoint *b)
 {
-  re_set_exception (ex_catch_assert, b);
+  re_set_exception (ada_catch_assert, b);
 }
 
 static void
 check_status_catch_assert (bpstat bs)
 {
-  check_status_exception (ex_catch_assert, bs);
+  check_status_exception (ada_catch_assert, bs);
 }
 
 static enum print_stop_action
 print_it_catch_assert (bpstat bs)
 {
-  return print_it_exception (ex_catch_assert, bs);
+  return print_it_exception (ada_catch_assert, bs);
 }
 
 static void
 print_one_catch_assert (struct breakpoint *b, struct bp_location **last_loc)
 {
-  print_one_exception (ex_catch_assert, b, last_loc);
+  print_one_exception (ada_catch_assert, b, last_loc);
 }
 
 static void
 print_mention_catch_assert (struct breakpoint *b)
 {
-  print_mention_exception (ex_catch_assert, b);
+  print_mention_exception (ada_catch_assert, b);
 }
 
 static void
 print_recreate_catch_assert (struct breakpoint *b, struct ui_file *fp)
 {
-  print_recreate_exception (ex_catch_assert, b, fp);
+  print_recreate_exception (ada_catch_assert, b, fp);
 }
 
 static struct breakpoint_ops catch_assert_breakpoint_ops;
@@ -11973,7 +11973,7 @@ ada_get_next_arg (char **argsp)
 
 static void
 catch_ada_exception_command_split (char *args,
-                                   enum exception_catchpoint_kind *ex,
+                                   enum ada_exception_catchpoint_kind *ex,
 				   char **excep_string,
 				   char **cond_string)
 {
@@ -12021,19 +12021,19 @@ catch_ada_exception_command_split (char *args,
   if (exception_name == NULL)
     {
       /* Catch all exceptions.  */
-      *ex = ex_catch_exception;
+      *ex = ada_catch_exception;
       *excep_string = NULL;
     }
   else if (strcmp (exception_name, "unhandled") == 0)
     {
       /* Catch unhandled exceptions.  */
-      *ex = ex_catch_exception_unhandled;
+      *ex = ada_catch_exception_unhandled;
       *excep_string = NULL;
     }
   else
     {
       /* Catch a specific exception.  */
-      *ex = ex_catch_exception;
+      *ex = ada_catch_exception;
       *excep_string = exception_name;
     }
   *cond_string = cond;
@@ -12043,7 +12043,7 @@ catch_ada_exception_command_split (char *args,
    implement a catchpoint of the EX kind.  */
 
 static const char *
-ada_exception_sym_name (enum exception_catchpoint_kind ex)
+ada_exception_sym_name (enum ada_exception_catchpoint_kind ex)
 {
   struct ada_inferior_data *data = get_ada_inferior_data (current_inferior ());
 
@@ -12051,13 +12051,13 @@ ada_exception_sym_name (enum exception_catchpoint_kind ex)
 
   switch (ex)
     {
-      case ex_catch_exception:
+      case ada_catch_exception:
         return (data->exception_info->catch_exception_sym);
         break;
-      case ex_catch_exception_unhandled:
+      case ada_catch_exception_unhandled:
         return (data->exception_info->catch_exception_unhandled_sym);
         break;
-      case ex_catch_assert:
+      case ada_catch_assert:
         return (data->exception_info->catch_assert_sym);
         break;
       default:
@@ -12070,17 +12070,17 @@ ada_exception_sym_name (enum exception_catchpoint_kind ex)
    of the EX kind.  */
 
 static const struct breakpoint_ops *
-ada_exception_breakpoint_ops (enum exception_catchpoint_kind ex)
+ada_exception_breakpoint_ops (enum ada_exception_catchpoint_kind ex)
 {
   switch (ex)
     {
-      case ex_catch_exception:
+      case ada_catch_exception:
         return (&catch_exception_breakpoint_ops);
         break;
-      case ex_catch_exception_unhandled:
+      case ada_catch_exception_unhandled:
         return (&catch_exception_unhandled_breakpoint_ops);
         break;
-      case ex_catch_assert:
+      case ada_catch_assert:
         return (&catch_assert_breakpoint_ops);
         break;
       default:
@@ -12143,7 +12143,7 @@ ada_exception_catchpoint_cond_string (const char *excep_string)
    type of catchpoint we need to create.  */
 
 static struct symtab_and_line
-ada_exception_sal (enum exception_catchpoint_kind ex, char *excep_string,
+ada_exception_sal (enum ada_exception_catchpoint_kind ex, char *excep_string,
 		   char **addr_string, const struct breakpoint_ops **ops)
 {
   const char *sym_name;
@@ -12192,7 +12192,7 @@ ada_exception_sal (enum exception_catchpoint_kind ex, char *excep_string,
 
 static void
 create_ada_exception_catchpoint (struct gdbarch *gdbarch,
-				 enum exception_catchpoint_kind ex_kind,
+				 enum ada_exception_catchpoint_kind ex_kind,
 				 char *excep_string,
 				 char *cond_string,
 				 int tempflag,
@@ -12222,7 +12222,7 @@ catch_ada_exception_command (char *arg, int from_tty,
 {
   struct gdbarch *gdbarch = get_current_arch ();
   int tempflag;
-  enum exception_catchpoint_kind ex_kind;
+  enum ada_exception_catchpoint_kind ex_kind;
   char *excep_string = NULL;
   char *cond_string = NULL;
 
@@ -12282,7 +12282,7 @@ catch_assert_command (char *arg, int from_tty,
   if (!arg)
     arg = "";
   catch_ada_assert_command_split (arg, &cond_string);
-  create_ada_exception_catchpoint (gdbarch, ex_catch_assert,
+  create_ada_exception_catchpoint (gdbarch, ada_catch_assert,
 				   NULL, cond_string,
 				   tempflag, from_tty);
 }
-- 
1.8.1.2

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: GDB/MI: New commands to catch Ada exceptions
  2013-10-08 11:48 GDB/MI: New commands to catch Ada exceptions Joel Brobecker
                   ` (3 preceding siblings ...)
  2013-10-08 11:48 ` [RFA/RFC 3/4] New GDB/MI commands to catch Ada exceptions Joel Brobecker
@ 2013-10-10 20:50 ` Tom Tromey
  2013-10-11 10:47   ` Joel Brobecker
  2013-10-11 13:52   ` checked in: " Joel Brobecker
  2013-10-11 10:44 ` [RFA/doco+NEWS] Document the -catch-assert and -catch-exception new GDB/MI commands Joel Brobecker
  5 siblings, 2 replies; 11+ messages in thread
From: Tom Tromey @ 2013-10-10 20:50 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:

Joel> This patch series introduces two new GDB/MI commands to catch
Joel> Ada exceptions, implementing the equivalent of the "catch exception"
Joel> and "catch assert" CLI commands. I will present these commands
Joel> in the patch that actually implements them.

I read through this series and it all looked fine to me.

Joel> Once we've agreed on the commands' interface, I will write the NEWS
Joel> and doco patches.

Actually, that's the only thing I noticed, and then I went back to
message #0 and found you'd already mentioned it :)

Tom

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [RFA/doco+NEWS] Document the -catch-assert and -catch-exception new GDB/MI commands.
  2013-10-08 11:48 GDB/MI: New commands to catch Ada exceptions Joel Brobecker
                   ` (4 preceding siblings ...)
  2013-10-10 20:50 ` GDB/MI: New " Tom Tromey
@ 2013-10-11 10:44 ` Joel Brobecker
  2013-10-11 11:21   ` Eli Zaretskii
  5 siblings, 1 reply; 11+ messages in thread
From: Joel Brobecker @ 2013-10-11 10:44 UTC (permalink / raw)
  To: gdb-patches

Hello,

This patch adds documentation for the new GDB/MI commands "-catch-assert"
and "-catch-exception", meant to provide the same functionality as
the "catch assert", "catch exception" and "catch exception unhandled"
CLI commands.

In the GDB Manual, there was already a section for catchpoint comments,
so that seemed like a natural place to document the new commands. But
commands related to a given concept seem to have traditionally been
organized alphabetically, and I didn't want future commands to break
down logical pairing of various commands. For instance, "-catch-load"
and "-catch-unload" are quite "distant" from each other, and it is easy
to imagine a new comment which would alphabetically fall in between,
causing them to be separated. So I introduced subsections to prevent
that from happening.

gdb/ChangeLog:

        * NEWS: Add entry documenting the new "-catch-assert" and
        "-catch-exception" GDB/MI commands.

gdb/doc/ChangeLog:

        * gdb.texinfo (Shared Library GDB/MI Catchpoint Commands):
        New subsection inside which the "-catch-load" and "-catch-unload"
        commands documentation is now placed.
        (Ada Exception GDB/MI Catchpoint Commands): New subsection
        documenting the "-catch-assert" and "-catch-exception" new
        GDB/MI commands.

Tested on x86_64-linux. OK to apply?

Thank you,
-- 
Joel

---
 gdb/NEWS            |  3 ++
 gdb/doc/gdb.texinfo | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 102 insertions(+)

diff --git a/gdb/NEWS b/gdb/NEWS
index 4e627b0..10834df 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -149,6 +149,9 @@ show range-stepping
      command, stopping the program's execution at the start of its
      main subprogram.
 
+  ** The new commands -catch-assert and -catch-exceptions insert
+     catchpoints stopping the program when Ada exceptions are raised.
+
 * New system-wide configuration scripts
   A GDB installation now provides scripts suitable for use as system-wide
   configuration scripts for the following systems:
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 24773ea..44fb174 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -30328,6 +30328,14 @@ thread-groups=["i1"],times="1"@}]@}
 This section documents @sc{gdb/mi} commands for manipulating
 catchpoints.
 
+@menu
+* Shared Library GDB/MI Catchpoint Commands::
+* Ada Exception GDB/MI Catchpoint Commands::
+@end menu
+
+@node Shared Library GDB/MI Catchpoint Commands
+@subsection Shared Library @sc{gdb/mi} Catchpoints
+
 @subheading The @code{-catch-load} Command
 @findex -catch-load
 
@@ -30386,6 +30394,97 @@ what="load of library matching bar.so",catch-type="unload",times="0"@}
 (gdb)
 @end smallexample
 
+@node Ada Exception GDB/MI Catchpoint Commands
+@subsection Ada Exception @sc{gdb/mi} Catchpoints
+
+The following @sc{gdb/mi} commands can be used to create catchpoints
+that stop the execution when Ada exceptions are being raised.
+
+@subheading The @code{-catch-assert} Command
+@findex -catch-assert
+
+@subsubheading Synopsis
+
+@smallexample
+ -catch-assert [ -c @var{condition}] [ -d ] [ -t ]
+@end smallexample
+
+Add a catchpoint for failed Ada assertions.
+
+The possible optional parameters for this command are:
+
+@table @samp
+@item -c @var{condition}
+Make the catchpoint conditional on @var{condition}.
+@item -d
+Create a disabled catchpoint.
+@item -t
+Create a temporary catchpoint.
+@end table
+
+@subsubheading @value{GDBN} Command
+
+The corresponding @value{GDBN} command is @samp{catch assert}.
+
+@subsubheading Example
+
+@smallexample
+-catch-assert
+^done,bkptno="5",bkpt=@{number="5",type="breakpoint",disp="keep",
+enabled="y",addr="0x0000000000404888",what="failed Ada assertions",
+thread-groups=["i1"],times="0",
+original-location="__gnat_debug_raise_assert_failure"@}
+(gdb)
+@end smallexample
+
+@subheading The @code{-catch-exception} Command
+@findex -catch-exception
+
+@subsubheading Synopsis
+
+@smallexample
+ -catch-exception [ -c @var{condition}] [ -d ] [ -e @var{exception-name} ]
+    [ -t ] [ -u ]
+@end smallexample
+
+Add a catchpoint stopping when Ada exceptions are raised.
+By default, the command stops the program when any Ada exception
+gets raised.  But it is also possible, by using some of the
+optional parameters described below, to create more selective
+catchpoints.
+
+The possible optional parameters for this command are:
+
+@table @samp
+@item -c @var{condition}
+Make the catchpoint conditional on @var{condition}.
+@item -d
+Create a disabled catchpoint.
+@item -e @var{exception-name}
+Only stop when @var{exception-name} is raised.  This option cannot
+be used combined with @samp{-u}.
+@item -t
+Create a temporary catchpoint.
+@item -u
+Stop only when an unhandled exception gets raised.  This option
+cannot be used combined with @samp{-e}.
+@end table
+
+@subsubheading @value{GDBN} Command
+
+The corresponding @value{GDBN} commands are @samp{catch exception}
+and @samp{catch exception unhandled}.
+
+@subsubheading Example
+
+@smallexample
+-catch-exception -e Program_Error
+^done,bkptno="4",bkpt=@{number="4",type="breakpoint",disp="keep",
+enabled="y",addr="0x0000000000404874",
+what="`Program_Error' Ada exception", thread-groups=["i1"],
+times="0",original-location="__gnat_debug_raise_exception"@}
+(gdb)
+@end smallexample
 
 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 @node GDB/MI Program Context
-- 
1.8.1.2

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: GDB/MI: New commands to catch Ada exceptions
  2013-10-10 20:50 ` GDB/MI: New " Tom Tromey
@ 2013-10-11 10:47   ` Joel Brobecker
  2013-10-11 13:52   ` checked in: " Joel Brobecker
  1 sibling, 0 replies; 11+ messages in thread
From: Joel Brobecker @ 2013-10-11 10:47 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

> Joel> This patch series introduces two new GDB/MI commands to catch
> Joel> Ada exceptions, implementing the equivalent of the "catch exception"
> Joel> and "catch assert" CLI commands. I will present these commands
> Joel> in the patch that actually implements them.
> 
> I read through this series and it all looked fine to me.

Thanks for the review, Tom.

> Joel> Once we've agreed on the commands' interface, I will write the NEWS
> Joel> and doco patches.
> 
> Actually, that's the only thing I noticed, and then I went back to
> message #0 and found you'd already mentioned it :)

I've just now posted a patch providing both doco & NEWS. I'll commit
the whole series when everything is approved.

-- 
Joel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFA/doco+NEWS] Document the -catch-assert and -catch-exception new GDB/MI commands.
  2013-10-11 10:44 ` [RFA/doco+NEWS] Document the -catch-assert and -catch-exception new GDB/MI commands Joel Brobecker
@ 2013-10-11 11:21   ` Eli Zaretskii
  2013-10-11 13:53     ` checked in: " Joel Brobecker
  0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2013-10-11 11:21 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

> From: Joel Brobecker <brobecker@adacore.com>
> Date: Fri, 11 Oct 2013 14:44:15 +0400
> 
> This patch adds documentation for the new GDB/MI commands "-catch-assert"
> and "-catch-exception", meant to provide the same functionality as
> the "catch assert", "catch exception" and "catch exception unhandled"
> CLI commands.
> 
> In the GDB Manual, there was already a section for catchpoint comments,
> so that seemed like a natural place to document the new commands. But
> commands related to a given concept seem to have traditionally been
> organized alphabetically, and I didn't want future commands to break
> down logical pairing of various commands. For instance, "-catch-load"
> and "-catch-unload" are quite "distant" from each other, and it is easy
> to imagine a new comment which would alphabetically fall in between,
> causing them to be separated. So I introduced subsections to prevent
> that from happening.
> 
> gdb/ChangeLog:
> 
>         * NEWS: Add entry documenting the new "-catch-assert" and
>         "-catch-exception" GDB/MI commands.
> 
> gdb/doc/ChangeLog:
> 
>         * gdb.texinfo (Shared Library GDB/MI Catchpoint Commands):
>         New subsection inside which the "-catch-load" and "-catch-unload"
>         commands documentation is now placed.
>         (Ada Exception GDB/MI Catchpoint Commands): New subsection
>         documenting the "-catch-assert" and "-catch-exception" new
>         GDB/MI commands.
> 
> Tested on x86_64-linux. OK to apply?

Yes, and thanks.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* checked in: GDB/MI: New commands to catch Ada exceptions
  2013-10-10 20:50 ` GDB/MI: New " Tom Tromey
  2013-10-11 10:47   ` Joel Brobecker
@ 2013-10-11 13:52   ` Joel Brobecker
  1 sibling, 0 replies; 11+ messages in thread
From: Joel Brobecker @ 2013-10-11 13:52 UTC (permalink / raw)
  To: gdb-patches

> Joel> This patch series introduces two new GDB/MI commands to catch
> Joel> Ada exceptions, implementing the equivalent of the "catch exception"
> Joel> and "catch assert" CLI commands. I will present these commands
> Joel> in the patch that actually implements them.
> 
> I read through this series and it all looked fine to me.

FYI: I have just checked in the entire series.

-- 
Joel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* checked in: [RFA/doco+NEWS] Document the -catch-assert and -catch-exception new GDB/MI commands.
  2013-10-11 11:21   ` Eli Zaretskii
@ 2013-10-11 13:53     ` Joel Brobecker
  0 siblings, 0 replies; 11+ messages in thread
From: Joel Brobecker @ 2013-10-11 13:53 UTC (permalink / raw)
  To: gdb-patches

> > gdb/ChangeLog:
> > 
> >         * NEWS: Add entry documenting the new "-catch-assert" and
> >         "-catch-exception" GDB/MI commands.
> > 
> > gdb/doc/ChangeLog:
> > 
> >         * gdb.texinfo (Shared Library GDB/MI Catchpoint Commands):
> >         New subsection inside which the "-catch-load" and "-catch-unload"
> >         commands documentation is now placed.
> >         (Ada Exception GDB/MI Catchpoint Commands): New subsection
> >         documenting the "-catch-assert" and "-catch-exception" new
> >         GDB/MI commands.
> > 
> > Tested on x86_64-linux. OK to apply?
> 
> Yes, and thanks.

Thank you, Eli. Checked in.

-- 
Joel

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-10-11 13:53 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-08 11:48 GDB/MI: New commands to catch Ada exceptions Joel Brobecker
2013-10-08 11:48 ` [RFA/commit 4/4] Adjust gdb.ada/mi_catch_ex.exp to use GDB/MI catch commands Joel Brobecker
2013-10-08 11:48 ` [commit/Ada 1/4] Rework a bit Ada exception catchpoint support (in prep for GDB/MI) Joel Brobecker
2013-10-08 11:48 ` [commit/Ada 2/4] Add "ada_" prefix to enum ada_exception_catchpoint_kind Joel Brobecker
2013-10-08 11:48 ` [RFA/RFC 3/4] New GDB/MI commands to catch Ada exceptions Joel Brobecker
2013-10-10 20:50 ` GDB/MI: New " Tom Tromey
2013-10-11 10:47   ` Joel Brobecker
2013-10-11 13:52   ` checked in: " Joel Brobecker
2013-10-11 10:44 ` [RFA/doco+NEWS] Document the -catch-assert and -catch-exception new GDB/MI commands Joel Brobecker
2013-10-11 11:21   ` Eli Zaretskii
2013-10-11 13:53     ` checked in: " Joel Brobecker

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