aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-lang.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-05-03 10:23:55 -0600
committerTom Tromey <tom@tromey.com>2018-05-04 12:12:16 -0600
commitcb7de75eb33b2ceda391c903cac5e5ed63933b99 (patch)
treefb7f9ceefc9264de9e66c4a6cc71bf82205380ca /gdb/ada-lang.c
parent49d83361cda4614f571f46c6bc0464092daf3dc9 (diff)
downloadgdb-cb7de75eb33b2ceda391c903cac5e5ed63933b99.zip
gdb-cb7de75eb33b2ceda391c903cac5e5ed63933b99.tar.gz
gdb-cb7de75eb33b2ceda391c903cac5e5ed63933b99.tar.bz2
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.
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r--gdb/ada-lang.c36
1 files changed, 14 insertions, 22 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index d086240..1af09bc 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -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,
}
}
+ 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;
}