public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Use unique_xmalloc_ptr in solib_catchpoint Date: Wed, 20 Oct 2021 17:09:09 +0000 (GMT) [thread overview] Message-ID: <20211020170909.0FEFA3858C3A@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b00577cd7bbcd77af96b14d3993430c076a87d17 commit b00577cd7bbcd77af96b14d3993430c076a87d17 Author: Tom Tromey <tom@tromey.com> Date: Sat Oct 2 16:40:00 2021 -0600 Use unique_xmalloc_ptr in solib_catchpoint This changes struct solib_catchpoint to use a unique_xmalloc_ptr, removing a bit of manual memory management. Diff: --- gdb/breakpoint.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index e742a1eccfe..7a9541836c9 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -7973,22 +7973,15 @@ static struct breakpoint_ops catch_vfork_breakpoint_ops; struct solib_catchpoint : public breakpoint { - ~solib_catchpoint () override; - /* True for "catch load", false for "catch unload". */ bool is_load; /* Regular expression to match, if any. COMPILED is only valid when REGEX is non-NULL. */ - char *regex; + gdb::unique_xmalloc_ptr<char> regex; std::unique_ptr<compiled_regex> compiled; }; -solib_catchpoint::~solib_catchpoint () -{ - xfree (this->regex); -} - static int insert_catch_solib (struct bp_location *ignore) { @@ -8104,14 +8097,16 @@ print_one_catch_solib (struct breakpoint *b, struct bp_location **locs) if (self->is_load) { if (self->regex) - msg = string_printf (_("load of library matching %s"), self->regex); + msg = string_printf (_("load of library matching %s"), + self->regex.get ()); else msg = _("load of library"); } else { if (self->regex) - msg = string_printf (_("unload of library matching %s"), self->regex); + msg = string_printf (_("unload of library matching %s"), + self->regex.get ()); else msg = _("unload of library"); } @@ -8139,7 +8134,7 @@ print_recreate_catch_solib (struct breakpoint *b, struct ui_file *fp) b->disposition == disp_del ? "tcatch" : "catch", self->is_load ? "load" : "unload"); if (self->regex) - fprintf_unfiltered (fp, " %s", self->regex); + fprintf_unfiltered (fp, " %s", self->regex.get ()); fprintf_unfiltered (fp, "\n"); } @@ -8162,7 +8157,7 @@ add_solib_catchpoint (const char *arg, bool is_load, bool is_temp, bool enabled) { c->compiled.reset (new compiled_regex (arg, REG_NOSUB, _("Invalid regexp"))); - c->regex = xstrdup (arg); + c->regex = make_unique_xstrdup (arg); } c->is_load = is_load;
reply other threads:[~2021-10-20 17:09 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20211020170909.0FEFA3858C3A@sourceware.org \ --to=tromey@sourceware.org \ --cc=gdb-cvs@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: linkBe 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; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).