From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA 2/6] Remove cleanup from create_excep_cond_exprs
Date: Thu, 30 Nov 2017 03:01:00 -0000 [thread overview]
Message-ID: <20171130030140.14830-3-tom@tromey.com> (raw)
In-Reply-To: <20171130030140.14830-1-tom@tromey.com>
This removes a cleanup from create_excep_cond_exprs by changing
ada_exception_catchpoint_cond_string to return a std::string.
ChangeLog
2017-11-29 Tom Tromey <tom@tromey.com>
* ada-lang.c (create_excep_cond_exprs): Update.
(ada_exception_catchpoint_cond_string): Return std::string.
---
gdb/ChangeLog | 5 +++++
gdb/ada-lang.c | 28 ++++++++++++----------------
2 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index d5dfa07b78..28df250104 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -12177,7 +12177,8 @@ ada_exception_name_addr (enum ada_exception_catchpoint_kind ex,
return result;
}
-static char *ada_exception_catchpoint_cond_string (const char *excep_string);
+static std::string ada_exception_catchpoint_cond_string
+ (const char *excep_string);
/* Ada catchpoints.
@@ -12242,9 +12243,7 @@ struct ada_catchpoint : public breakpoint
static void
create_excep_cond_exprs (struct ada_catchpoint *c)
{
- 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)
@@ -12256,8 +12255,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);
- old_chain = make_cleanup (xfree, cond_string);
+ std::string cond_string
+ = ada_exception_catchpoint_cond_string (c->excep_string);
/* Iterate over all the catchpoint's locations, and parse an
expression for each. */
@@ -12271,7 +12270,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,
@@ -12289,8 +12288,6 @@ create_excep_cond_exprs (struct ada_catchpoint *c)
ada_loc->excep_cond_expr = std::move (exp);
}
-
- do_cleanups (old_chain);
}
/* ada_catchpoint destructor. */
@@ -12898,12 +12895,9 @@ ada_exception_breakpoint_ops (enum ada_exception_catchpoint_kind ex)
/* Return the condition that will be used to match the current exception
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.
-
- The string returned is a newly allocated string that needs to be
- deallocated later. */
+ an exception catchpoint. */
-static char *
+static std::string
ada_exception_catchpoint_cond_string (const char *excep_string)
{
int i;
@@ -12931,11 +12925,13 @@ ada_exception_catchpoint_cond_string (const char *excep_string)
{
if (strcmp (standard_exc [i], excep_string) == 0)
{
- return xstrprintf ("long_integer (e) = long_integer (&standard.%s)",
- excep_string);
+ return
+ string_printf ("long_integer (e) = long_integer (&standard.%s)",
+ excep_string);
}
}
- return xstrprintf ("long_integer (e) = long_integer (&%s)", excep_string);
+ return string_printf ("long_integer (e) = long_integer (&%s)",
+ excep_string);
}
/* Return the symtab_and_line that should be used to insert an exception
--
2.13.6
next prev parent reply other threads:[~2017-11-30 3:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-30 3:01 [RFA 0/6] remove cleanups from Ada Tom Tromey
2017-11-30 3:01 ` [RFA 6/6] Remove unnecessary cleanup from ada_collect_symbol_completion_matches Tom Tromey
2017-11-30 3:01 ` [RFA 3/6] Remove cleanup from print_mention_exception Tom Tromey
2017-11-30 3:01 ` [RFA 1/6] Remove cleanup from old_renaming_is_invisible Tom Tromey
2017-11-30 3:01 ` [RFA 4/6] Remove some more cleanups from ada-lang.c Tom Tromey
2017-11-30 3:01 ` [RFA 5/6] Change Ada exceptions to use std::string Tom Tromey
2017-11-30 22:03 ` Joel Brobecker
2017-11-30 22:59 ` Joel Brobecker
2017-11-30 23:53 ` Tom Tromey
2017-12-01 12:10 ` Joel Brobecker
2017-11-30 3:01 ` Tom Tromey [this message]
2017-11-30 22:02 ` [RFA 0/6] remove cleanups from Ada Joel Brobecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171130030140.14830-3-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox