aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2013-10-11 13:48:19 +0000
committerJoel Brobecker <brobecker@gnat.com>2013-10-11 13:48:19 +0000
commit349774efe258cff6b365b72df07f6ce2eb76cbd6 (patch)
treebf35bfb985653376ef70588140ebb7e97ea5bd45 /gdb/mi
parent761269c8497f8f5e1cee4a4695ba48fb74fa86a3 (diff)
downloadfsf-binutils-gdb-349774efe258cff6b365b72df07f6ce2eb76cbd6.zip
fsf-binutils-gdb-349774efe258cff6b365b72df07f6ce2eb76cbd6.tar.gz
fsf-binutils-gdb-349774efe258cff6b365b72df07f6ce2eb76cbd6.tar.bz2
New GDB/MI commands to catch Ada exceptions
This patch introduces two new GDB/MI commands implementing the equivalent of the "catch exception" and "catch assert" GDB/CLI commands. 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.
Diffstat (limited to 'gdb/mi')
-rw-r--r--gdb/mi/mi-cmd-catch.c131
-rw-r--r--gdb/mi/mi-cmds.c4
-rw-r--r--gdb/mi/mi-cmds.h2
3 files changed, 137 insertions, 0 deletions
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;