From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA 1/9] Remove a cleanup from gdbserver
Date: Wed, 07 Feb 2018 22:04:00 -0000 [thread overview]
Message-ID: <20180207220434.6045-2-tom@tromey.com> (raw)
In-Reply-To: <20180207220434.6045-1-tom@tromey.com>
This removes a cleanup from gdbserver's set_raw_breakpoint_at,
replacing it with unique_xmalloc_ptr.
2018-02-07 Tom Tromey <tom@tromey.com>
* mem-break.c (set_raw_breakpoint_at): Use
gdb::unique_xmalloc_ptr.
---
gdb/gdbserver/ChangeLog | 5 +++++
gdb/gdbserver/mem-break.c | 11 ++++++-----
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 9559e63f92..902ee7c7fd 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,8 @@
+2018-02-07 Tom Tromey <tom@tromey.com>
+
+ * mem-break.c (set_raw_breakpoint_at): Use
+ gdb::unique_xmalloc_ptr.
+
2018-01-30 Pedro Alves <palves@redhat.com>
PR gdb/13211
diff --git a/gdb/gdbserver/mem-break.c b/gdb/gdbserver/mem-break.c
index bb385733fe..4c10fbba2c 100644
--- a/gdb/gdbserver/mem-break.c
+++ b/gdb/gdbserver/mem-break.c
@@ -431,7 +431,6 @@ set_raw_breakpoint_at (enum raw_bkpt_type type, CORE_ADDR where, int kind,
{
struct process_info *proc = current_process ();
struct raw_breakpoint *bp;
- struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
if (type == raw_bkpt_type_sw || type == raw_bkpt_type_hw)
{
@@ -450,13 +449,14 @@ set_raw_breakpoint_at (enum raw_bkpt_type type, CORE_ADDR where, int kind,
else
bp = find_raw_breakpoint_at (where, type, kind);
+ gdb::unique_xmalloc_ptr<struct raw_breakpoint> bp_holder;
if (bp == NULL)
{
- bp = XCNEW (struct raw_breakpoint);
+ bp_holder.reset (XCNEW (struct raw_breakpoint));
+ bp = bp_holder.get ();
bp->pc = where;
bp->kind = kind;
bp->raw_type = type;
- make_cleanup (xfree, bp);
}
if (!bp->inserted)
@@ -468,14 +468,15 @@ set_raw_breakpoint_at (enum raw_bkpt_type type, CORE_ADDR where, int kind,
debug_printf ("Failed to insert breakpoint at 0x%s (%d).\n",
paddress (where), *err);
- do_cleanups (old_chain);
return NULL;
}
bp->inserted = 1;
}
- discard_cleanups (old_chain);
+ /* If the breakpoint was allocated above, we know we want to keep it
+ now. */
+ bp_holder.release ();
/* Link the breakpoint in, if this is the first reference. */
if (++bp->refcount == 1)
--
2.13.6
next prev parent reply other threads:[~2018-02-07 22:04 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-07 22:04 [RFA 0/9] more cleanup removal Tom Tromey
2018-02-07 22:04 ` [RFA 4/9] Class-ify macro_buffer Tom Tromey
2018-02-07 22:04 ` [RFA 3/9] Return unique_xmalloc_ptr from macro scope functions Tom Tromey
2018-02-07 22:04 ` [RFA 2/9] Remove make_cleanup_restore_current_thread from gdbserver Tom Tromey
2018-02-07 22:04 ` [RFA 6/9] Remove cleanups from macro_define_command Tom Tromey
2018-02-07 22:04 ` [RFA 5/9] Use std::string in maybe_expand Tom Tromey
2018-02-07 22:04 ` [RFA 7/9] Use std::vector in find_source_lines Tom Tromey
2018-02-09 13:00 ` Tom Tromey
2018-02-09 13:11 ` Pedro Alves
2018-02-07 22:04 ` Tom Tromey [this message]
2018-02-07 22:04 ` [RFA 8/9] Use unique_xmalloc_ptr in build_id_to_debug_bfd Tom Tromey
2018-02-07 22:04 ` [RFA 9/9] Remove cleanups from solib.c Tom Tromey
2018-02-08 16:42 ` [RFA 0/9] more cleanup removal Pedro Alves
2018-02-08 18:45 ` Tom Tromey
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=20180207220434.6045-2-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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).