diff options
author | Joel Brobecker <brobecker@gnat.com> | 2013-10-11 13:44:11 +0000 |
---|---|---|
committer | Joel Brobecker <brobecker@gnat.com> | 2013-10-11 13:44:11 +0000 |
commit | b4a5b78b782ac0a689ed6e6b8ca8b58ad8948258 (patch) | |
tree | b44f558e9c9d8dd4fffcf4a40376e5df9be9b229 /gdb | |
parent | 7ad1d32c17973b8ae448d92b21e45d4a9439e347 (diff) | |
download | gdb-b4a5b78b782ac0a689ed6e6b8ca8b58ad8948258.zip gdb-b4a5b78b782ac0a689ed6e6b8ca8b58ad8948258.tar.gz gdb-b4a5b78b782ac0a689ed6e6b8ca8b58ad8948258.tar.bz2 |
Rework a bit Ada exception catchpoint support (in prep for GDB/MI)
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.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 19 | ||||
-rw-r--r-- | gdb/ada-lang.c | 79 |
2 files changed, 48 insertions, 50 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ccb18d5..f53d6bb 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,24 @@ 2013-10-11 Joel Brobecker <brobecker@adacore.com> + * 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. + +2013-10-11 Joel Brobecker <brobecker@adacore.com> + * utils.h (perror_warning_with_name): Add declaration. * utils.c (perror_warning_with_name): New function. * cli/cli-cmds.c (source_script_with_search): Add call to 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 |