Return std::string from ada_exception_catchpoint_cond_string

This changes ada_exception_catchpoint_cond_string to return a
std::string, allowing for the removal of a cleanup in
create_excep_cond_exprs.

ChangeLog
2018-05-04  Tom Tromey  <tom@tromey.com>

	* ada-lang.c (create_excep_cond_exprs): Update.
	(ada_exception_catchpoint_cond_string): Use std::string.
This commit is contained in:
Tom Tromey 2018-05-03 10:23:55 -06:00
parent 49d83361cd
commit cb7de75eb3
2 changed files with 21 additions and 24 deletions

View File

@ -1,3 +1,8 @@
2018-05-04 Tom Tromey <tom@tromey.com>
* ada-lang.c (create_excep_cond_exprs): Update.
(ada_exception_catchpoint_cond_string): Use std::string.
2018-05-04 Tom Tromey <tom@tromey.com>
* ada-lang.c (xget_renaming_scope): Return std::string.

View File

@ -12431,7 +12431,7 @@ ada_exception_name_addr (enum ada_exception_catchpoint_kind ex,
return result;
}
static char *ada_exception_catchpoint_cond_string
static std::string ada_exception_catchpoint_cond_string
(const char *excep_string,
enum ada_exception_catchpoint_kind ex);
@ -12499,9 +12499,7 @@ static void
create_excep_cond_exprs (struct ada_catchpoint *c,
enum ada_exception_catchpoint_kind ex)
{
struct cleanup *old_chain;
struct bp_location *bl;
char *cond_string;
/* Nothing to do if there's no specific exception to catch. */
if (c->excep_string == NULL)
@ -12513,8 +12511,8 @@ create_excep_cond_exprs (struct ada_catchpoint *c,
/* Compute the condition expression in text form, from the specific
expection we want to catch. */
cond_string = ada_exception_catchpoint_cond_string (c->excep_string, ex);
old_chain = make_cleanup (xfree, cond_string);
std::string cond_string
= ada_exception_catchpoint_cond_string (c->excep_string, ex);
/* Iterate over all the catchpoint's locations, and parse an
expression for each. */
@ -12528,7 +12526,7 @@ create_excep_cond_exprs (struct ada_catchpoint *c,
{
const char *s;
s = cond_string;
s = cond_string.c_str ();
TRY
{
exp = parse_exp_1 (&s, bl->address,
@ -12546,8 +12544,6 @@ create_excep_cond_exprs (struct ada_catchpoint *c,
ada_loc->excep_cond_expr = std::move (exp);
}
do_cleanups (old_chain);
}
/* ada_catchpoint destructor. */
@ -13248,29 +13244,25 @@ ada_exception_breakpoint_ops (enum ada_exception_catchpoint_kind ex)
being raised with the exception that the user wants to catch. This
assumes that this condition is used when the inferior just triggered
an exception catchpoint.
EX: the type of catchpoints used for catching Ada exceptions.
The string returned is a newly allocated string that needs to be
deallocated later. */
EX: the type of catchpoints used for catching Ada exceptions. */
static char *
static std::string
ada_exception_catchpoint_cond_string (const char *excep_string,
enum ada_exception_catchpoint_kind ex)
{
int i;
bool is_standard_exc = false;
const char *actual_exc_expr;
char *ref_exc_expr;
std::string result;
if (ex == ada_catch_handlers)
{
/* For exception handlers catchpoints, the condition string does
not use the same parameter as for the other exceptions. */
actual_exc_expr = ("long_integer (GNAT_GCC_exception_Access"
"(gcc_exception).all.occurrence.id)");
result = ("long_integer (GNAT_GCC_exception_Access"
"(gcc_exception).all.occurrence.id)");
}
else
actual_exc_expr = "long_integer (e)";
result = "long_integer (e)";
/* The standard exceptions are a special case. They are defined in
runtime units that have been compiled without debugging info; if
@ -13300,13 +13292,13 @@ ada_exception_catchpoint_cond_string (const char *excep_string,
}
}
if (is_standard_exc)
ref_exc_expr = xstrprintf ("long_integer (&standard.%s)", excep_string);
else
ref_exc_expr = xstrprintf ("long_integer (&%s)", excep_string);
result += " = ";
if (is_standard_exc)
string_appendf (result, "long_integer (&standard.%s)", excep_string);
else
string_appendf (result, "long_integer (&%s)", excep_string);
char *result = xstrprintf ("%s = %s", actual_exc_expr, ref_exc_expr);
xfree (ref_exc_expr);
return result;
}