From patchwork Thu Jan 23 00:57:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 37508 Received: (qmail 83352 invoked by alias); 23 Jan 2020 00:57:57 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 81319 invoked by uid 89); 23 Jan 2020 00:57:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: gateway30.websitewelcome.com Received: from gateway30.websitewelcome.com (HELO gateway30.websitewelcome.com) (192.185.198.26) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 23 Jan 2020 00:57:30 +0000 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway30.websitewelcome.com (Postfix) with ESMTP id B6AAB3C532 for ; Wed, 22 Jan 2020 18:57:28 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id uQoKiNCc09jb7uQoKiTpWo; Wed, 22 Jan 2020 18:57:28 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=HL5gaZrBh4CdQGMhXN2c9COT8R/uBnevN2Lup3yx74A=; b=JpUqIa0njEulvii9+GudB6KmNU 431TwGPu6VnF2P03nTeMU7eFEHyDZ1IKlUjU08z3OtuO1KH5I53qD/Uf/GX8TsMKW3YpeLO3q1ILU K41C2d7HJxeSIIV8Vb4WRcUF4; Received: from 75-166-123-50.hlrn.qwest.net ([75.166.123.50]:40832 helo=bapiya.Home) by box5379.bluehost.com with esmtpa (Exim 4.92) (envelope-from ) id 1iuQoK-004KqG-IB; Wed, 22 Jan 2020 17:57:28 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 36/38] Move two more functions to dwarf2/leb.h Date: Wed, 22 Jan 2020 17:57:08 -0700 Message-Id: <20200123005710.7978-37-tom@tromey.com> In-Reply-To: <20200123005710.7978-1-tom@tromey.com> References: <20200123005710.7978-1-tom@tromey.com> This moves read_n_bytes and read_direct_string to be with the the low-level value-reading code. 2020-01-22 Tom Tromey * dwarf2/read.c (read_n_bytes, read_direct_string): Move to read.c. * dwarf2/leb.h (read_n_bytes, read_direct_string): Move from read.c. Change-Id: Id07bfa13d93c0ac1f47a385749a8f01f4755b818 --- gdb/ChangeLog | 7 +++++++ gdb/dwarf2/leb.h | 27 +++++++++++++++++++++++++++ gdb/dwarf2/read.c | 31 ------------------------------- 3 files changed, 34 insertions(+), 31 deletions(-) diff --git a/gdb/dwarf2/leb.h b/gdb/dwarf2/leb.h index 9c30cbea734..f312fc261ee 100644 --- a/gdb/dwarf2/leb.h +++ b/gdb/dwarf2/leb.h @@ -134,4 +134,31 @@ extern LONGEST read_initial_length (bfd *abfd, const gdb_byte *buf, extern LONGEST read_offset (bfd *abfd, const gdb_byte *buf, unsigned int offset_size); +static inline const gdb_byte * +read_n_bytes (bfd *abfd, const gdb_byte *buf, unsigned int size) +{ + /* If the size of a host char is 8 bits, we can return a pointer + to the buffer, otherwise we have to copy the data to a buffer + allocated on the temporary obstack. */ + gdb_assert (HOST_CHAR_BIT == 8); + return buf; +} + +static inline const char * +read_direct_string (bfd *abfd, const gdb_byte *buf, + unsigned int *bytes_read_ptr) +{ + /* If the size of a host char is 8 bits, we can return a pointer + to the string, otherwise we have to copy the string to a buffer + allocated on the temporary obstack. */ + gdb_assert (HOST_CHAR_BIT == 8); + if (*buf == '\0') + { + *bytes_read_ptr = 1; + return NULL; + } + *bytes_read_ptr = strlen ((const char *) buf) + 1; + return (const char *) buf; +} + #endif /* GDB_DWARF2_LEB_H */ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index e47f7443a58..09840400cec 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1251,10 +1251,6 @@ static sect_offset read_abbrev_offset (struct dwarf2_per_objfile *dwarf2_per_objfile, struct dwarf2_section_info *, sect_offset); -static const gdb_byte *read_n_bytes (bfd *, const gdb_byte *, unsigned int); - -static const char *read_direct_string (bfd *, const gdb_byte *, unsigned int *); - static const char *read_indirect_string (struct dwarf2_per_objfile *dwarf2_per_objfile, bfd *, const gdb_byte *, const struct comp_unit_head *, unsigned int *); @@ -18776,33 +18772,6 @@ read_checked_initial_length_and_offset (bfd *abfd, const gdb_byte *buf, return length; } -static const gdb_byte * -read_n_bytes (bfd *abfd, const gdb_byte *buf, unsigned int size) -{ - /* If the size of a host char is 8 bits, we can return a pointer - to the buffer, otherwise we have to copy the data to a buffer - allocated on the temporary obstack. */ - gdb_assert (HOST_CHAR_BIT == 8); - return buf; -} - -static const char * -read_direct_string (bfd *abfd, const gdb_byte *buf, - unsigned int *bytes_read_ptr) -{ - /* If the size of a host char is 8 bits, we can return a pointer - to the string, otherwise we have to copy the string to a buffer - allocated on the temporary obstack. */ - gdb_assert (HOST_CHAR_BIT == 8); - if (*buf == '\0') - { - *bytes_read_ptr = 1; - return NULL; - } - *bytes_read_ptr = strlen ((const char *) buf) + 1; - return (const char *) buf; -} - /* Return pointer to string at section SECT offset STR_OFFSET with error reporting strings FORM_NAME and SECT_NAME. */