From: Sergio Durigan Junior <sergiodj@redhat.com>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA v2 2/4] C++-ify break-catch-throw
Date: Thu, 20 Jul 2017 17:57:00 -0000 [thread overview]
Message-ID: <87h8y7kn3x.fsf@redhat.com> (raw)
In-Reply-To: <20170719203225.6714-3-tom@tromey.com> (Tom Tromey's message of "Wed, 19 Jul 2017 14:32:23 -0600")
On Wednesday, July 19 2017, Tom Tromey wrote:
> This changes exception_catchpoint's "exception_rx' member to be a
> std::string, and updating the users.
>
> 2017-06-04 Tom Tromey <tom@tromey.com>
>
> * break-catch-throw.c (struct exception_catchpoint)
> <exception_rx>: Now a std::string.
> (~exception_catchpoint): REmove.
> (print_one_detail_exception_catchpoint): Update.
> (handle_gnu_v3_exceptions): Change type of except_rx.
> (extract_exception_regexp): Return a std::string.
> (catch_exception_command_1): Update.
> ---
> gdb/ChangeLog | 10 ++++++++++
> gdb/break-catch-throw.c | 40 +++++++++++++---------------------------
> 2 files changed, 23 insertions(+), 27 deletions(-)
>
> diff --git a/gdb/ChangeLog b/gdb/ChangeLog
> index 42bde4b..e178fa5 100644
> --- a/gdb/ChangeLog
> +++ b/gdb/ChangeLog
> @@ -1,5 +1,15 @@
> 2017-06-04 Tom Tromey <tom@tromey.com>
>
> + * break-catch-throw.c (struct exception_catchpoint)
> + <exception_rx>: Now a std::string.
> + (~exception_catchpoint): REmove.
> + (print_one_detail_exception_catchpoint): Update.
> + (handle_gnu_v3_exceptions): Change type of except_rx.
> + (extract_exception_regexp): Return a std::string.
> + (catch_exception_command_1): Update.
> +
> +2017-06-04 Tom Tromey <tom@tromey.com>
> +
> * break-catch-sig.c (gdb_signal_type): Remove typedef.
> (struct signal_catchpoint) <signals_to_be_caught>: Now a
> std::vector.
> diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
> index 0074d06..e71a885 100644
> --- a/gdb/break-catch-throw.c
> +++ b/gdb/break-catch-throw.c
> @@ -76,16 +76,14 @@ static struct breakpoint_ops gnu_v3_exception_catchpoint_ops;
>
> struct exception_catchpoint : public breakpoint
> {
> - ~exception_catchpoint () override;
> -
> /* The kind of exception catchpoint. */
>
> enum exception_event_kind kind;
>
> - /* If non-NULL, an xmalloc'd string holding the source form of the
> - regular expression to match against. */
> + /* If not empty, a string holding the source form of the regular
> + expression to match against. */
>
> - char *exception_rx;
> + std::string exception_rx;
>
> /* If non-NULL, a compiled regular expression which is used to
> determine which exceptions to stop on. */
> @@ -140,13 +138,6 @@ classify_exception_breakpoint (struct breakpoint *b)
> return cp->kind;
> }
>
> -/* exception_catchpoint destructor. */
> -
> -exception_catchpoint::~exception_catchpoint ()
> -{
> - xfree (this->exception_rx);
> -}
> -
> /* Implement the 'check_status' method. */
>
> static void
> @@ -319,10 +310,10 @@ print_one_detail_exception_catchpoint (const struct breakpoint *b,
> const struct exception_catchpoint *cp
> = (const struct exception_catchpoint *) b;
>
> - if (cp->exception_rx != NULL)
> + if (!cp->exception_rx.empty ())
> {
> uiout->text (_("\tmatching: "));
> - uiout->field_string ("regexp", cp->exception_rx);
> + uiout->field_string ("regexp", cp->exception_rx.c_str ());
> uiout->text ("\n");
> }
> }
> @@ -371,15 +362,15 @@ print_recreate_exception_catchpoint (struct breakpoint *b,
> }
>
> static void
> -handle_gnu_v3_exceptions (int tempflag, char *except_rx,
> +handle_gnu_v3_exceptions (int tempflag, std::string &&except_rx,
> const char *cond_string,
> enum exception_event_kind ex_event, int from_tty)
> {
> std::unique_ptr<compiled_regex> pattern;
>
> - if (except_rx != NULL)
> + if (!except_rx.empty ())
> {
> - pattern.reset (new compiled_regex (except_rx, REG_NOSUB,
> + pattern.reset (new compiled_regex (except_rx.c_str (), REG_NOSUB,
> _("invalid type-matching regexp")));
> }
>
> @@ -410,7 +401,7 @@ handle_gnu_v3_exceptions (int tempflag, char *except_rx,
> STRING is updated to point to the "if" token, if it exists, or to
> the end of the string. */
>
> -static char *
> +static std::string
> extract_exception_regexp (const char **string)
> {
> const char *start;
> @@ -435,8 +426,8 @@ extract_exception_regexp (const char **string)
>
> *string = last;
> if (last_space > start)
> - return savestring (start, last_space - start);
> - return NULL;
> + return std::string (start, last_space - start);
> + return std::string ();
> }
>
> /* Deal with "catch catch", "catch throw", and "catch rethrow"
> @@ -447,17 +438,14 @@ catch_exception_command_1 (enum exception_event_kind ex_event,
> char *arg_entry,
> int tempflag, int from_tty)
> {
> - char *except_rx;
> const char *cond_string = NULL;
> - struct cleanup *cleanup;
> const char *arg = arg_entry;
>
> if (!arg)
> arg = "";
> arg = skip_spaces_const (arg);
>
> - except_rx = extract_exception_regexp (&arg);
> - cleanup = make_cleanup (xfree, except_rx);
> + std::string except_rx = extract_exception_regexp (&arg);
>
> cond_string = ep_parse_optional_if_clause (&arg);
>
> @@ -469,10 +457,8 @@ catch_exception_command_1 (enum exception_event_kind ex_event,
> && ex_event != EX_EVENT_RETHROW)
> error (_("Unsupported or unknown exception event; cannot catch it"));
>
> - handle_gnu_v3_exceptions (tempflag, except_rx, cond_string,
> + handle_gnu_v3_exceptions (tempflag, std::move (except_rx), cond_string,
> ex_event, from_tty);
> -
> - discard_cleanups (cleanup);
> }
>
> /* Implementation of "catch catch" command. */
> --
> 2.9.3
LGTM.
--
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/
next prev parent reply other threads:[~2017-07-20 17:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-19 20:53 [RFA v2 0/4] C++-ify some breakpoint subclasses a bit more Tom Tromey
2017-07-19 20:51 ` [RFA v2 1/4] C++-ify break-catch-sig Tom Tromey
2017-07-20 18:13 ` Sergio Durigan Junior
2017-07-21 19:53 ` Simon Marchi
2017-07-22 3:53 ` Tom Tromey
2017-07-21 19:43 ` Simon Marchi
2017-07-19 20:53 ` [RFA v2 3/4] Use std::vector in syscall_catchpoint Tom Tromey
2017-07-20 17:55 ` Sergio Durigan Junior
2017-07-21 20:37 ` Simon Marchi
2017-07-19 20:53 ` [RFA v2 2/4] C++-ify break-catch-throw Tom Tromey
2017-07-20 17:57 ` Sergio Durigan Junior [this message]
2017-07-21 20:20 ` Simon Marchi
2017-07-19 20:54 ` [RFA v2 4/4] Use std::vector in struct catch_syscall_inferior_data Tom Tromey
2017-07-20 16:58 ` Sergio Durigan Junior
2017-07-22 3:43 ` Tom Tromey
2017-07-21 20:49 ` Simon Marchi
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=87h8y7kn3x.fsf@redhat.com \
--to=sergiodj@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/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