aboutsummaryrefslogtreecommitdiff
path: root/gdb/linux-tdep.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2020-06-15 06:28:09 -0600
committerTom Tromey <tromey@adacore.com>2020-06-15 06:28:10 -0600
commita5d871ddaf2aa8462922ed25b0c0dc7f02128cb9 (patch)
tree58bb13fd9e677c9592da1f9a740b091d0654aff0 /gdb/linux-tdep.c
parent670e35fad9c17e8e166c5a6260201eebcc2ba9e6 (diff)
downloadgdb-a5d871ddaf2aa8462922ed25b0c0dc7f02128cb9.zip
gdb-a5d871ddaf2aa8462922ed25b0c0dc7f02128cb9.tar.gz
gdb-a5d871ddaf2aa8462922ed25b0c0dc7f02128cb9.tar.bz2
Remove a use of target_read_string
linux-tdep.c:dump_mapping_p uses target_read_string, but in a way that does not really make sense. It's better to use target_read_memory here. gdb/ChangeLog 2020-06-15 Tom Tromey <tromey@adacore.com> * linux-tdep.c (dump_mapping_p): Use target_read_memory.
Diffstat (limited to 'gdb/linux-tdep.c')
-rw-r--r--gdb/linux-tdep.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 0f95593..2dcdc63 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -701,22 +701,16 @@ dump_mapping_p (filter_flags filterflags, const struct smaps_vmflags *v,
if (!dump_p && private_p && offset == 0
&& (filterflags & COREFILTER_ELF_HEADERS) != 0)
{
- /* Let's check if we have an ELF header. */
- gdb::unique_xmalloc_ptr<char> header;
- int errcode;
-
/* Useful define specifying the size of the ELF magical
header. */
#ifndef SELFMAG
#define SELFMAG 4
#endif
- /* Read the first SELFMAG bytes and check if it is ELFMAG. */
- if (target_read_string (addr, &header, SELFMAG, &errcode) == SELFMAG
- && errcode == 0)
+ /* Let's check if we have an ELF header. */
+ gdb_byte h[SELFMAG];
+ if (target_read_memory (addr, h, SELFMAG) == 0)
{
- const char *h = header.get ();
-
/* The EI_MAG* and ELFMAG* constants come from
<elf/common.h>. */
if (h[EI_MAG0] == ELFMAG0 && h[EI_MAG1] == ELFMAG1