This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA 07/13] Use gdb::def_vector in sparc64-tdep.c
>>>>> "Simon" == Simon Marchi <simon.marchi@polymtl.ca> writes:
Simon> It seems to me like the code doesn't use this as text, but binary
Simon> data. So it should probably have used gdb_byte in the first place. I
Simon> would then suggest using gdb::byte_vector (if you agree that gdb_byte
Simon> should be used here).
For consistency I changed the callees as well.
Tom
commit 0cd1a0cc08838934771cb8c4aa556dde7ee66f01
Author: Tom Tromey <tom@tromey.com>
Date: Wed Nov 1 16:37:27 2017 -0600
Use gdb::def_vector in sparc64-tdep.c
This removes a cleanup from sparc64-tdep.c, replacing it with
gdb::def_vector.
gdb/ChangeLog
2017-11-03 Tom Tromey <tom@tromey.com>
* sparc64-tdep.c (do_examine): Use gdb::def_vector.
(adi_read_versions): Change "tags" to "gdb_byte *".
(adi_print_versions): Likewise.
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 56b7e903bc..8f663938cb 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2017-11-03 Tom Tromey <tom@tromey.com>
+ * sparc64-tdep.c (do_examine): Use gdb::def_vector.
+ (adi_read_versions): Change "tags" to "gdb_byte *".
+ (adi_print_versions): Likewise.
+
+2017-11-03 Tom Tromey <tom@tromey.com>
+
* breakpoint.c
(scoped_rbreak_breakpoints::scoped_rbreak_breakpoints): Rename
from start_rbreak_breakpoints.
diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c
index a756834cba..eade0461d5 100644
--- a/gdb/sparc64-tdep.c
+++ b/gdb/sparc64-tdep.c
@@ -341,7 +341,7 @@ adi_is_addr_mapped (CORE_ADDR vaddr, size_t cnt)
for "SIZE" number of bytes. */
static int
-adi_read_versions (CORE_ADDR vaddr, size_t size, unsigned char *tags)
+adi_read_versions (CORE_ADDR vaddr, size_t size, gdb_byte *tags)
{
int fd = adi_tag_fd ();
if (fd == -1)
@@ -383,7 +383,7 @@ adi_write_versions (CORE_ADDR vaddr, size_t size, unsigned char *tags)
at "VADDR" with number of "CNT". */
static void
-adi_print_versions (CORE_ADDR vaddr, size_t cnt, unsigned char *tags)
+adi_print_versions (CORE_ADDR vaddr, size_t cnt, gdb_byte *tags)
{
int v_idx = 0;
const int maxelts = 8; /* # of elements per line */
@@ -415,21 +415,17 @@ static void
do_examine (CORE_ADDR start, int bcnt)
{
CORE_ADDR vaddr = adi_normalize_address (start);
- struct cleanup *cleanup;
CORE_ADDR vstart = adi_align_address (vaddr);
int cnt = adi_convert_byte_count (vaddr, bcnt, vstart);
- unsigned char *buf = (unsigned char *) xmalloc (cnt);
- cleanup = make_cleanup (xfree, buf);
- int read_cnt = adi_read_versions (vstart, cnt, buf);
+ gdb::def_vector<gdb_byte> buf (cnt);
+ int read_cnt = adi_read_versions (vstart, cnt, buf.data ());
if (read_cnt == -1)
error (_("No ADI information"));
else if (read_cnt < cnt)
error(_("No ADI information at %s"), paddress (target_gdbarch (), vaddr));
- adi_print_versions (vstart, cnt, buf);
-
- do_cleanups (cleanup);
+ adi_print_versions (vstart, cnt, buf.data ());
}
static void