From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from kwanyin.sergiodj.net (kwanyin.sergiodj.net [158.69.185.54]) by sourceware.org (Postfix) with ESMTPS id E2619395BC2B for ; Sat, 13 Jun 2020 03:04:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E2619395BC2B From: Sergio Durigan Junior To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 3/4] Remove a use of target_read_string References: <20200612215356.22145-1-tromey@adacore.com> <20200612215356.22145-4-tromey@adacore.com> X-URL: http://blog.sergiodj.net Date: Fri, 12 Jun 2020 23:04:51 -0400 In-Reply-To: <20200612215356.22145-4-tromey@adacore.com> (Tom Tromey's message of "Fri, 12 Jun 2020 15:53:55 -0600") Message-ID: <877dwb8y3w.fsf@paluero> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Jun 2020 03:04:54 -0000 On Friday, June 12 2020, Tom Tromey wrote: > 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. Thanks for catching this problem, Tom. > gdb/ChangeLog > 2020-06-02 Tom Tromey > > * 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 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 > . */ > if (h[EI_MAG0] == ELFMAG0 && h[EI_MAG1] == ELFMAG1 This looks OK to me. > 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 > #include "target-connection.h" > +#include "valprint.h" > > static void generic_tls_error (void) ATTRIBUTE_NORETURN; This hunk looks unrelated. Thanks, -- Sergio GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36 Please send encrypted e-mail if possible https://sergiodj.net/