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);
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)
/* 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. */
{
const char *s;
- s = cond_string;
+ s = cond_string.c_str ();
TRY
{
exp = parse_exp_1 (&s, bl->address,
ada_loc->excep_cond_expr = std::move (exp);
}
-
- do_cleanups (old_chain);
}
/* ada_catchpoint destructor. */
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
}
}
+ result += " = ";
+
if (is_standard_exc)
- ref_exc_expr = xstrprintf ("long_integer (&standard.%s)", excep_string);
+ string_appendf (result, "long_integer (&standard.%s)", excep_string);
else
- ref_exc_expr = xstrprintf ("long_integer (&%s)", excep_string);
+ 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;
}