gdb/dwarf: Introduce dwarf2_per_cu_int_type function
authorAndrew Burgess <andrew.burgess@embecosm.com>
Fri, 29 Nov 2019 00:13:19 +0000 (00:13 +0000)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Sun, 1 Dec 2019 22:31:31 +0000 (22:31 +0000)
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

gdb/ChangeLog
gdb/dwarf2read.c

index 5da07259fc415ff1e7b154fa116b76156dc7bc0b..98a3c6598dc5e00a3f6e088150f9dd56a8348482 100644 (file)
@@ -1,3 +1,10 @@
+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
index 12a9773302e41b0fd351cc3537099068f0adc32f..cd114d0bf660bdac955114d07f85ff6be86d46fd 100644 (file)
@@ -1910,6 +1910,9 @@ static void process_queue (struct dwarf2_per_objfile *dwarf2_per_objfile);
 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 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
   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 @@ dwarf2_per_cu_addr_sized_int_type (struct dwarf2_per_cu_data *per_cu,
   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.  */
This page took 0.037974 seconds and 4 git commands to generate.