From patchwork Sat Nov 30 21:47:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 36392 Received: (qmail 8765 invoked by alias); 30 Nov 2019 21:47:36 -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 8747 invoked by uid 89); 30 Nov 2019 21:47:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy= X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 30 Nov 2019 21:47:35 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 698612032F; Sat, 30 Nov 2019 16:47:30 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [8.43.85.239]) by mx1.osci.io (Postfix) with ESMTP id 5598B2039A; Sat, 30 Nov 2019 16:47:26 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 3F55B28173; Sat, 30 Nov 2019 16:47:26 -0500 (EST) X-Gerrit-PatchSet: 2 Date: Sat, 30 Nov 2019 16:47:25 -0500 From: "Andrew Burgess (Code Review)" To: Simon Marchi , gdb-patches@sourceware.org Auto-Submitted: auto-generated X-Gerrit-MessageType: newpatchset Subject: [review v2] gdb/dwarf: Introduce dwarf2_per_cu_int_type function X-Gerrit-Change-Id: I8b849dd338012ec033b3f0a57d65cec0d7a3bd97 X-Gerrit-Change-Number: 736 X-Gerrit-ChangeURL: X-Gerrit-Commit: 185bc8235acd38644bd2bed875e262a8b5470cce In-Reply-To: References: Reply-To: andrew.burgess@embecosm.com, simon.marchi@polymtl.ca, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Message-Id: <20191130214726.3F55B28173@gnutoolchain-gerrit.osci.io> Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/736 ...................................................................... gdb/dwarf: Introduce dwarf2_per_cu_int_type function This is a minor refactor in preparation for the next commit. Splits the core of dwarf2_per_cu_addr_sized_int_type out into a separate function. There should be no user visible changes after this commit. gdb/ChangeLog: * dwarf2read.c (dwarf2_per_cu_int_type): New function, takes most of its implementation from... (dwarf2_per_cu_addr_sized_int_type): ...here, which now just calls the new function. Change-Id: I8b849dd338012ec033b3f0a57d65cec0d7a3bd97 --- M gdb/ChangeLog M gdb/dwarf2read.c 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7a285cb..5da5196 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2019-11-18 Andrew Burgess + + * dwarf2read.c (dwarf2_per_cu_int_type): New function, takes most + of its implementation from... + (dwarf2_per_cu_addr_sized_int_type): ...here, which now just calls + the new function. + 2019-11-28 Andrew Burgess * dwarf2read.c (read_subrange_type): Read bit and byte stride and diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 0d964b3..1a2acde 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -1910,6 +1910,9 @@ static struct type *dwarf2_per_cu_addr_type (struct dwarf2_per_cu_data *per_cu); static struct type *dwarf2_per_cu_addr_sized_int_type (struct dwarf2_per_cu_data *per_cu, bool unsigned_p); +static struct type *dwarf2_per_cu_int_type + (struct dwarf2_per_cu_data *per_cu, int size_in_bytes, + bool unsigned_p); /* Class, the destructor of which frees all allocated queue entries. This will only have work to do if an error was thrown while processing the @@ -17882,24 +17885,22 @@ return 1; } -/* Find an integer type the same size as the address size given in the - compilation unit header for PER_CU. UNSIGNED_P controls if the integer - is unsigned or not. */ +/* Find an integer type SIZE_IN_BYTES bytes in size and return it. + UNSIGNED_P controls if the integer is unsigned or not. */ static struct type * -dwarf2_per_cu_addr_sized_int_type (struct dwarf2_per_cu_data *per_cu, - bool unsigned_p) +dwarf2_per_cu_int_type (struct dwarf2_per_cu_data *per_cu, + int size_in_bytes, bool unsigned_p) { struct objfile *objfile = per_cu->dwarf2_per_objfile->objfile; - int addr_size = dwarf2_per_cu_addr_size (per_cu); struct type *int_type; /* Helper macro to examine the various builtin types. */ -#define TRY_TYPE(F) \ - int_type = (unsigned_p \ - ? objfile_type (objfile)->builtin_unsigned_ ## F \ - : objfile_type (objfile)->builtin_ ## F); \ - if (int_type != NULL && TYPE_LENGTH (int_type) == addr_size) \ +#define TRY_TYPE(F) \ + int_type = (unsigned_p \ + ? objfile_type (objfile)->builtin_unsigned_ ## F \ + : objfile_type (objfile)->builtin_ ## F); \ + if (int_type != NULL && TYPE_LENGTH (int_type) == size_in_bytes) \ return int_type TRY_TYPE (char); @@ -17913,6 +17914,18 @@ gdb_assert_not_reached ("unable to find suitable integer type"); } +/* Find an integer type the same size as the address size given in the + compilation unit header for PER_CU. UNSIGNED_P controls if the integer + is unsigned or not. */ + +static struct type * +dwarf2_per_cu_addr_sized_int_type (struct dwarf2_per_cu_data *per_cu, + bool unsigned_p) +{ + int addr_size = dwarf2_per_cu_addr_size (per_cu); + return dwarf2_per_cu_int_type (per_cu, addr_size, unsigned_p); +} + /* Read the DW_AT_type attribute for a sub-range. If this attribute is not present (which is valid) then compute the default type based on the compilation units address size. */