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.
This commit is contained in:
parent
7ad1d32c17
commit
b4a5b78b78
2 changed files with 48 additions and 50 deletions
|
@ -1,3 +1,22 @@
|
||||||
|
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>
|
2013-10-11 Joel Brobecker <brobecker@adacore.com>
|
||||||
|
|
||||||
* utils.h (perror_warning_with_name): Add declaration.
|
* utils.h (perror_warning_with_name): Add declaration.
|
||||||
|
|
|
@ -12175,43 +12175,34 @@ ada_exception_sal (enum exception_catchpoint_kind ex, char *excep_string,
|
||||||
return find_function_start_sal (sym, 1);
|
return find_function_start_sal (sym, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse the arguments (ARGS) of the "catch exception" command.
|
/* Create an Ada exception catchpoint.
|
||||||
|
|
||||||
If the user asked the catchpoint to catch only a specific
|
|
||||||
exception, then save the exception name in ADDR_STRING.
|
|
||||||
|
|
||||||
If the user provided a condition, then set COND_STRING to
|
EX_KIND is the kind of exception catchpoint to be created.
|
||||||
that condition expression (the memory must be deallocated
|
|
||||||
after use). Otherwise, set COND_STRING to NULL.
|
|
||||||
|
|
||||||
See ada_exception_sal for a description of all the remaining
|
EXCEPT_STRING, if not NULL, indicates the name of the exception
|
||||||
function arguments of this function. */
|
to which this catchpoint applies. If NULL, this catchpoint is
|
||||||
|
expected to trigger for all exceptions.
|
||||||
|
|
||||||
static struct symtab_and_line
|
COND_STRING, if not NULL, is the catchpoint condition.
|
||||||
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;
|
|
||||||
|
|
||||||
catch_ada_exception_command_split (args, &ex, excep_string, cond_string);
|
TEMPFLAG, if nonzero, means that the underlying breakpoint
|
||||||
return ada_exception_sal (ex, *excep_string, addr_string, ops);
|
should be temporary.
|
||||||
}
|
|
||||||
|
|
||||||
/* Create an Ada exception catchpoint. */
|
FROM_TTY is the usual argument passed to all commands implementations. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
create_ada_exception_catchpoint (struct gdbarch *gdbarch,
|
create_ada_exception_catchpoint (struct gdbarch *gdbarch,
|
||||||
struct symtab_and_line sal,
|
enum exception_catchpoint_kind ex_kind,
|
||||||
char *addr_string,
|
|
||||||
char *excep_string,
|
char *excep_string,
|
||||||
char *cond_string,
|
char *cond_string,
|
||||||
const struct breakpoint_ops *ops,
|
|
||||||
int tempflag,
|
int tempflag,
|
||||||
int from_tty)
|
int from_tty)
|
||||||
{
|
{
|
||||||
struct ada_catchpoint *c;
|
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);
|
c = XNEW (struct ada_catchpoint);
|
||||||
init_ada_exception_breakpoint (&c->base, gdbarch, sal, addr_string,
|
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 ();
|
struct gdbarch *gdbarch = get_current_arch ();
|
||||||
int tempflag;
|
int tempflag;
|
||||||
struct symtab_and_line sal;
|
enum exception_catchpoint_kind ex_kind;
|
||||||
char *addr_string = NULL;
|
|
||||||
char *excep_string = NULL;
|
char *excep_string = NULL;
|
||||||
char *cond_string = NULL;
|
char *cond_string = NULL;
|
||||||
const struct breakpoint_ops *ops = NULL;
|
|
||||||
|
|
||||||
tempflag = get_cmd_context (command) == CATCH_TEMPORARY;
|
tempflag = get_cmd_context (command) == CATCH_TEMPORARY;
|
||||||
|
|
||||||
if (!arg)
|
if (!arg)
|
||||||
arg = "";
|
arg = "";
|
||||||
sal = ada_decode_exception_location (arg, &addr_string, &excep_string,
|
catch_ada_exception_command_split (arg, &ex_kind, &excep_string,
|
||||||
&cond_string, &ops);
|
&cond_string);
|
||||||
create_ada_exception_catchpoint (gdbarch, sal, addr_string,
|
create_ada_exception_catchpoint (gdbarch, ex_kind,
|
||||||
excep_string, cond_string, ops,
|
excep_string, cond_string,
|
||||||
tempflag, from_tty);
|
tempflag, from_tty);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Assuming that ARGS contains the arguments of a "catch assert"
|
/* Split the arguments specified in a "catch assert" command.
|
||||||
command, parse those arguments and return a symtab_and_line object
|
|
||||||
for a failed assertion catchpoint.
|
|
||||||
|
|
||||||
Set ADDR_STRING to the name of the function where the real
|
ARGS contains the command's arguments (or the empty string if
|
||||||
breakpoint that implements the catchpoint is set.
|
no arguments were passed).
|
||||||
|
|
||||||
If ARGS contains a condition, set COND_STRING to that condition
|
If ARGS contains a condition, set COND_STRING to that condition
|
||||||
(the memory needs to be deallocated after use). Otherwise, set
|
(the memory needs to be deallocated after use). */
|
||||||
COND_STRING to NULL. */
|
|
||||||
|
|
||||||
static struct symtab_and_line
|
static void
|
||||||
ada_decode_assert_location (char *args, char **addr_string,
|
catch_ada_assert_command_split (char *args, char **cond_string)
|
||||||
char **cond_string,
|
|
||||||
const struct breakpoint_ops **ops)
|
|
||||||
{
|
{
|
||||||
args = skip_spaces (args);
|
args = skip_spaces (args);
|
||||||
|
|
||||||
|
@ -12281,8 +12265,6 @@ ada_decode_assert_location (char *args, char **addr_string,
|
||||||
the command. */
|
the command. */
|
||||||
else if (args[0] != '\0')
|
else if (args[0] != '\0')
|
||||||
error (_("Junk at end of arguments."));
|
error (_("Junk at end of arguments."));
|
||||||
|
|
||||||
return ada_exception_sal (ex_catch_assert, NULL, addr_string, ops);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Implement the "catch assert" command. */
|
/* Implement the "catch assert" command. */
|
||||||
|
@ -12293,19 +12275,16 @@ catch_assert_command (char *arg, int from_tty,
|
||||||
{
|
{
|
||||||
struct gdbarch *gdbarch = get_current_arch ();
|
struct gdbarch *gdbarch = get_current_arch ();
|
||||||
int tempflag;
|
int tempflag;
|
||||||
struct symtab_and_line sal;
|
|
||||||
char *addr_string = NULL;
|
|
||||||
char *cond_string = NULL;
|
char *cond_string = NULL;
|
||||||
const struct breakpoint_ops *ops = NULL;
|
|
||||||
|
|
||||||
tempflag = get_cmd_context (command) == CATCH_TEMPORARY;
|
tempflag = get_cmd_context (command) == CATCH_TEMPORARY;
|
||||||
|
|
||||||
if (!arg)
|
if (!arg)
|
||||||
arg = "";
|
arg = "";
|
||||||
sal = ada_decode_assert_location (arg, &addr_string, &cond_string, &ops);
|
catch_ada_assert_command_split (arg, &cond_string);
|
||||||
create_ada_exception_catchpoint (gdbarch, sal, addr_string,
|
create_ada_exception_catchpoint (gdbarch, ex_catch_assert,
|
||||||
NULL, cond_string, ops, tempflag,
|
NULL, cond_string,
|
||||||
from_tty);
|
tempflag, from_tty);
|
||||||
}
|
}
|
||||||
/* Operators */
|
/* Operators */
|
||||||
/* Information about operators given special treatment in functions
|
/* Information about operators given special treatment in functions
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue