]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Convert read_offset to method on comp_unit_head
authorTom Tromey <tom@tromey.com>
Sat, 8 Feb 2020 20:40:54 +0000 (13:40 -0700)
committerTom Tromey <tom@tromey.com>
Sat, 8 Feb 2020 20:43:24 +0000 (13:43 -0700)
This changes one of the read_offset overloads to be a method on
comp_unit_head.

2020-02-08  Tom Tromey  <tom@tromey.com>

* dwarf2/read.c (read_attribute_value, read_indirect_string)
(read_indirect_line_string): Update.
* dwarf2/comp-unit.c (read_offset): Remove.
(read_comp_unit_head): Update.
* dwarf2/comp-unit.h (struct comp_unit_head) <read_offset>: New
method.
(read_offset): Don't declare.

Change-Id: Ia595702a5748337b7c031352bc437956baab9990

gdb/ChangeLog
gdb/dwarf2/comp-unit.c
gdb/dwarf2/comp-unit.h
gdb/dwarf2/read.c

index c38bcae9d399b8a039d5e5b5f53f2dbe0c4a727b..db821ff24e43905328660c0d381a8acec37c6a85 100644 (file)
@@ -1,3 +1,13 @@
+2020-02-08  Tom Tromey  <tom@tromey.com>
+
+       * dwarf2/read.c (read_attribute_value, read_indirect_string)
+       (read_indirect_line_string): Update.
+       * dwarf2/comp-unit.c (read_offset): Remove.
+       (read_comp_unit_head): Update.
+       * dwarf2/comp-unit.h (struct comp_unit_head) <read_offset>: New
+       method.
+       (read_offset): Don't declare.
+
 2020-02-08  Tom Tromey  <tom@tromey.com>
 
        * Makefile.in (COMMON_SFILES): Add dwarf2/comp-unit.c.
index 03e804b7086b72f705e035edb4c6408905034e65..847a148cbd2528a758f4b84a1ad221db43fb2637 100644 (file)
@@ -129,9 +129,8 @@ read_comp_unit_head (struct comp_unit_head *cu_header,
       cu_header->addr_size = read_1_byte (abfd, info_ptr);
       info_ptr += 1;
     }
-  cu_header->abbrev_sect_off = (sect_offset) read_offset (abfd, info_ptr,
-                                                         cu_header,
-                                                         &bytes_read);
+  cu_header->abbrev_sect_off
+    = (sect_offset) cu_header->read_offset (abfd, info_ptr, &bytes_read);
   info_ptr += bytes_read;
   if (cu_header->version < 5)
     {
@@ -157,7 +156,7 @@ read_comp_unit_head (struct comp_unit_head *cu_header,
   if (section_kind == rcuh_kind::TYPE)
     {
       LONGEST type_offset;
-      type_offset = read_offset (abfd, info_ptr, cu_header, &bytes_read);
+      type_offset = cu_header->read_offset (abfd, info_ptr, &bytes_read);
       info_ptr += bytes_read;
       cu_header->type_cu_offset_in_tu = (cu_offset) type_offset;
       if (to_underlying (cu_header->type_cu_offset_in_tu) != type_offset)
@@ -222,16 +221,3 @@ read_and_check_comp_unit_head (struct dwarf2_per_objfile *dwarf2_per_objfile,
 
   return info_ptr;
 }
-
-/* See comp-unit.h.  */
-
-LONGEST
-read_offset (bfd *abfd, const gdb_byte *buf,
-            const struct comp_unit_head *cu_header,
-             unsigned int *bytes_read)
-{
-  LONGEST offset = read_offset (abfd, buf, cu_header->offset_size);
-
-  *bytes_read = cu_header->offset_size;
-  return offset;
-}
index b4483ac1f7acfd3197b7e97c0857ea6a8b44c396..e61b1000b9e42b1d27f1c8b861c2a1147d2d5ccc 100644 (file)
@@ -27,6 +27,7 @@
 #ifndef GDB_DWARF2_COMP_UNIT_H
 #define GDB_DWARF2_COMP_UNIT_H
 
+#include "dwarf2/leb.h"
 #include "gdbtypes.h"
 
 /* The data in a compilation unit header, after target2host
@@ -78,6 +79,16 @@ struct comp_unit_head
     sect_offset top = sect_off + get_length ();
     return off >= bottom && off < top;
   }
+
+  /* Read an offset from the data stream.  The size of the offset is
+     given by cu_header->offset_size.  */
+  LONGEST read_offset (bfd *abfd, const gdb_byte *buf,
+                      unsigned int *bytes_read) const
+  {
+    LONGEST offset = ::read_offset (abfd, buf, offset_size);
+    *bytes_read = offset_size;
+    return offset;
+  }
 };
 
 /* Expected enum dwarf_unit_type for read_comp_unit_head.  */
@@ -104,11 +115,4 @@ extern const gdb_byte *read_and_check_comp_unit_head
    const gdb_byte *info_ptr,
    rcuh_kind section_kind);
 
-/* Read an offset from the data stream.  The size of the offset is
-   given by cu_header->offset_size.  */
-
-extern LONGEST read_offset (bfd *abfd, const gdb_byte *buf,
-                           const struct comp_unit_head *cu_header,
-                           unsigned int *bytes_read);
-
 #endif /* GDB_DWARF2_COMP_UNIT_H */
index ef72214347f1e44fa40a44dcde60b98acdcdda8d..8ea0b60e187d6f99dea0642ad24a165f33dea236 100644 (file)
@@ -18448,12 +18448,12 @@ read_attribute_value (const struct die_reader_specs *reader,
       if (cu->header.version == 2)
        DW_UNSND (attr) = read_address (abfd, info_ptr, cu, &bytes_read);
       else
-       DW_UNSND (attr) = read_offset (abfd, info_ptr,
-                                      &cu->header, &bytes_read);
+       DW_UNSND (attr) = cu->header.read_offset (abfd, info_ptr,
+                                                 &bytes_read);
       info_ptr += bytes_read;
       break;
     case DW_FORM_GNU_ref_alt:
-      DW_UNSND (attr) = read_offset (abfd, info_ptr, &cu->header, &bytes_read);
+      DW_UNSND (attr) = cu->header.read_offset (abfd, info_ptr, &bytes_read);
       info_ptr += bytes_read;
       break;
     case DW_FORM_addr:
@@ -18497,7 +18497,7 @@ read_attribute_value (const struct die_reader_specs *reader,
       DW_BLOCK (attr) = blk;
       break;
     case DW_FORM_sec_offset:
-      DW_UNSND (attr) = read_offset (abfd, info_ptr, &cu->header, &bytes_read);
+      DW_UNSND (attr) = cu->header.read_offset (abfd, info_ptr, &bytes_read);
       info_ptr += bytes_read;
       break;
     case DW_FORM_string:
@@ -18530,8 +18530,8 @@ read_attribute_value (const struct die_reader_specs *reader,
     case DW_FORM_GNU_strp_alt:
       {
        struct dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile);
-       LONGEST str_offset = read_offset (abfd, info_ptr, cu_header,
-                                         &bytes_read);
+       LONGEST str_offset = cu_header->read_offset (abfd, info_ptr,
+                                                    &bytes_read);
 
        DW_STRING (attr) = read_indirect_string_from_dwz (objfile,
                                                          dwz, str_offset);
@@ -18892,7 +18892,7 @@ read_indirect_string (struct dwarf2_per_objfile *dwarf2_per_objfile, bfd *abfd,
                      const struct comp_unit_head *cu_header,
                      unsigned int *bytes_read_ptr)
 {
-  LONGEST str_offset = read_offset (abfd, buf, cu_header, bytes_read_ptr);
+  LONGEST str_offset = cu_header->read_offset (abfd, buf, bytes_read_ptr);
 
   return read_indirect_string_at_offset (dwarf2_per_objfile, abfd, str_offset);
 }
@@ -18907,7 +18907,7 @@ read_indirect_line_string (struct dwarf2_per_objfile *dwarf2_per_objfile,
                           const struct comp_unit_head *cu_header,
                           unsigned int *bytes_read_ptr)
 {
-  LONGEST str_offset = read_offset (abfd, buf, cu_header, bytes_read_ptr);
+  LONGEST str_offset = cu_header->read_offset (abfd, buf, bytes_read_ptr);
 
   return read_indirect_line_string_at_offset (dwarf2_per_objfile, abfd,
                                              str_offset);