This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Remove cleanup from ppc-linux-nat.c
- From: Tom Tromey <tromey at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 16 Oct 2017 22:11:25 -0000
- Subject: [binutils-gdb] Remove cleanup from ppc-linux-nat.c
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a90ecff85af9d9275f540227825ba62bdafc976d
commit a90ecff85af9d9275f540227825ba62bdafc976d
Author: Tom Tromey <tom@tromey.com>
Date: Thu Oct 12 16:24:13 2017 -0600
Remove cleanup from ppc-linux-nat.c
This removes a cleanup from ppc-linux-nat.c, by using
unique_xmalloc_ptr. It also slightly simplifies the code by using
XDUP rather than XNEW and memcpy.
ChangeLog
2017-10-16 Tom Tromey <tom@tromey.com>
* ppc-linux-nat.c (hwdebug_insert_point): Use
gdb::unique_xmalloc_ptr, XDUP.
Diff:
---
gdb/ChangeLog | 5 +++++
gdb/ppc-linux-nat.c | 11 +++--------
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 248b5d8..adca693 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2017-10-16 Tom Tromey <tom@tromey.com>
+ * ppc-linux-nat.c (hwdebug_insert_point): Use
+ gdb::unique_xmalloc_ptr, XDUP.
+
+2017-10-16 Tom Tromey <tom@tromey.com>
+
* probe.c (parse_probes): Use std::string.
(info_probes_for_ops, enable_probes_command)
(disable_probes_command): Remove cleanups.
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index 45c8903..7c8ab6c 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -1541,16 +1541,13 @@ hwdebug_insert_point (struct ppc_hw_breakpoint *b, int tid)
{
int i;
long slot;
- struct ppc_hw_breakpoint *p = XNEW (struct ppc_hw_breakpoint);
+ gdb::unique_xmalloc_ptr<ppc_hw_breakpoint> p (XDUP (ppc_hw_breakpoint, b));
struct hw_break_tuple *hw_breaks;
- struct cleanup *c = make_cleanup (xfree, p);
struct thread_points *t;
struct hw_break_tuple *tuple;
- memcpy (p, b, sizeof (struct ppc_hw_breakpoint));
-
errno = 0;
- slot = ptrace (PPC_PTRACE_SETHWDEBUG, tid, 0, p);
+ slot = ptrace (PPC_PTRACE_SETHWDEBUG, tid, 0, p.get ());
if (slot < 0)
perror_with_name (_("Unexpected error setting breakpoint or watchpoint"));
@@ -1564,13 +1561,11 @@ hwdebug_insert_point (struct ppc_hw_breakpoint *b, int tid)
if (hw_breaks[i].hw_break == NULL)
{
hw_breaks[i].slot = slot;
- hw_breaks[i].hw_break = p;
+ hw_breaks[i].hw_break = p.release ();
break;
}
gdb_assert (i != max_slots_number);
-
- discard_cleanups (c);
}
/* This function is a generic wrapper that is responsible for removing a