public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Sourceware to Gerrit sync (Code Review)" <gerrit@gnutoolchain-gerrit.osci.io>
To: Andrew Burgess <andrew.burgess@embecosm.com>,	gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [pushed] gdb/dwarf: Introduce dwarf2_per_cu_int_type function
Date: Sun, 01 Dec 2019 22:33:00 -0000	[thread overview]
Message-ID: <20191201223309.5C0A728174@gnutoolchain-gerrit.osci.io> (raw)
In-Reply-To: <gerrit.1575070360000.I8b849dd338012ec033b3f0a57d65cec0d7a3bd97@gnutoolchain-gerrit.osci.io>

Sourceware to Gerrit sync has submitted this change.

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 5da0725..98a3c65 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
 2019-12-01  Andrew Burgess  <andrew.burgess@embecosm.com>
 
+	* 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-12-01  Andrew Burgess  <andrew.burgess@embecosm.com>
+
 	* dwarf2read.c (read_subrange_type): Read bit and byte stride and
 	create a range with stride where appropriate.
 	* f-valprint.c: Include 'gdbarch.h'.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 12a9773..cd114d0 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
@@ -17887,24 +17890,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);
@@ -17918,6 +17919,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.  */

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I8b849dd338012ec033b3f0a57d65cec0d7a3bd97
Gerrit-Change-Number: 736
Gerrit-PatchSet: 4
Gerrit-Owner: Andrew Burgess <andrew.burgess@embecosm.com>
Gerrit-Reviewer: Andrew Burgess <andrew.burgess@embecosm.com>
Gerrit-Reviewer: Simon Marchi <simon.marchi@polymtl.ca>
Gerrit-MessageType: merged

      parent reply	other threads:[~2019-12-01 22:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-29 23:32 [review] " Andrew Burgess (Code Review)
2019-11-30  3:55 ` Simon Marchi (Code Review)
2019-11-30 21:47 ` [review v2] " Andrew Burgess (Code Review)
2019-11-30 22:12 ` [review v3] " Andrew Burgess (Code Review)
2019-12-01 22:33 ` [pushed] " Sourceware to Gerrit sync (Code Review)
2019-12-01 22:33 ` Sourceware to Gerrit sync (Code Review) [this message]

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=20191201223309.5C0A728174@gnutoolchain-gerrit.osci.io \
    --to=gerrit@gnutoolchain-gerrit.osci.io \
    --cc=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=noreply@gnutoolchain-gerrit.osci.io \
    --cc=simon.marchi@polymtl.ca \
    /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).