From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH 3/4] Remove a use of target_read_string
Date: Fri, 12 Jun 2020 15:53:55 -0600 [thread overview]
Message-ID: <20200612215356.22145-4-tromey@adacore.com> (raw)
In-Reply-To: <20200612215356.22145-1-tromey@adacore.com>
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-02 Tom Tromey <tromey@adacore.com>
* linux-tdep.c (dump_mapping_p): Use target_read_memory.
---
gdb/ChangeLog | 4 ++++
gdb/linux-tdep.c | 12 +++---------
gdb/target.c | 1 +
3 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 0f9559355f1..2dcdc630769 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
diff --git a/gdb/target.c b/gdb/target.c
index 14c494688e0..897b8fdd32b 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -50,6 +50,7 @@
#include "terminal.h"
#include <unordered_map>
#include "target-connection.h"
+#include "valprint.h"
static void generic_tls_error (void) ATTRIBUTE_NORETURN;
--
2.21.3
next prev parent reply other threads:[~2020-06-12 21:53 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-12 21:53 [PATCH 0/4] Unify string-reading APIs Tom Tromey
2020-06-12 21:53 ` [PATCH 1/4] Remove read_memory_string Tom Tromey
2020-06-13 14:19 ` Simon Marchi
2020-06-15 12:37 ` Pedro Alves
2020-06-12 21:53 ` [PATCH 2/4] Rewrite target_read_string Tom Tromey
2020-06-12 21:53 ` Tom Tromey [this message]
2020-06-13 3:04 ` [PATCH 3/4] Remove a use of target_read_string Sergio Durigan Junior
2020-06-15 12:13 ` Tom Tromey
2020-06-12 21:53 ` [PATCH 4/4] Change target_read_string API Tom Tromey
2020-06-13 14:40 ` Simon Marchi
2020-06-13 14:40 ` [PATCH 0/4] Unify string-reading APIs Simon Marchi
2020-06-15 12:27 ` 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=20200612215356.22145-4-tromey@adacore.com \
--to=tromey@adacore.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).