aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-02-05 10:53:57 +0100
committerTom Tromey <tom@tromey.com>2018-02-08 11:46:55 -0700
commit45dd3607e24aaf515b5d75c666b351575410392b (patch)
treefb30db0e1f2612aa09af2550c740b7d58b4c021b /gdb
parent8de3a6e2afe21ac93d610fa46fbc579a81ea2277 (diff)
downloadfsf-binutils-gdb-45dd3607e24aaf515b5d75c666b351575410392b.zip
fsf-binutils-gdb-45dd3607e24aaf515b5d75c666b351575410392b.tar.gz
fsf-binutils-gdb-45dd3607e24aaf515b5d75c666b351575410392b.tar.bz2
Remove a cleanup from gdbserver
This removes a cleanup from gdbserver's set_raw_breakpoint_at, replacing it with unique_xmalloc_ptr. 2018-02-08 Tom Tromey <tom@tromey.com> * mem-break.c (set_raw_breakpoint_at): Use gdb::unique_xmalloc_ptr.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/gdbserver/ChangeLog5
-rw-r--r--gdb/gdbserver/mem-break.c11
2 files changed, 11 insertions, 5 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 9559e63..145ba44 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,8 @@
+2018-02-08 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 bb38573..4c10fbb 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)