Rename dwarf2/comp-unit.h
authorTom Tromey <tom@tromey.com>
Mon, 17 May 2021 20:16:06 +0000 (14:16 -0600)
committerTom Tromey <tom@tromey.com>
Mon, 17 May 2021 20:16:07 +0000 (14:16 -0600)
Simon pointed out that dwarf2/cu.h and dwarf2/comp-unit.h seemingly
mean the same thing.  He suggested renaming the latter to
comp-unit-head.h, which is what this patch does.

gdb/ChangeLog
2021-05-17  Tom Tromey  <tom@tromey.com>

* dwarf2/read.h: Update include.
* dwarf2/read.c: Update include.
* dwarf2/line-header.c: Update include.
* dwarf2/cu.h: Update include.
* dwarf2/comp-unit-head.h: Rename from comp-unit.h.
* dwarf2/comp-unit-head.c: Rename from comp-unit.c.
* Makefile.in (COMMON_SFILES): Update.

gdb/ChangeLog
gdb/Makefile.in
gdb/dwarf2/comp-unit-head.c [new file with mode: 0644]
gdb/dwarf2/comp-unit-head.h [new file with mode: 0644]
gdb/dwarf2/comp-unit.c [deleted file]
gdb/dwarf2/comp-unit.h [deleted file]
gdb/dwarf2/cu.h
gdb/dwarf2/line-header.c
gdb/dwarf2/read.c
gdb/dwarf2/read.h

index 7ca4738be02bd6e50f214fea47e4044e61713001..82131c11038dc41be98cd016fea1933de72410a8 100644 (file)
@@ -1,3 +1,13 @@
+2021-05-17  Tom Tromey  <tom@tromey.com>
+
+       * dwarf2/read.h: Update include.
+       * dwarf2/read.c: Update include.
+       * dwarf2/line-header.c: Update include.
+       * dwarf2/cu.h: Update include.
+       * dwarf2/comp-unit-head.h: Rename from comp-unit.h.
+       * dwarf2/comp-unit-head.c: Rename from comp-unit.c.
+       * Makefile.in (COMMON_SFILES): Update.
+
 2021-05-17  Tom Tromey  <tom@tromey.com>
 
        * dwarf2/read.c (maybe_queue_comp_unit)
index 1f37fe43024b3327351355fbd4401b2af3504420..a9fade803b0d0c8b5f6a5ce8d165eab044759044 100644 (file)
@@ -1025,7 +1025,7 @@ COMMON_SFILES = \
        dummy-frame.c \
        dwarf2/abbrev.c \
        dwarf2/attribute.c \
-       dwarf2/comp-unit.c \
+       dwarf2/comp-unit-head.c \
        dwarf2/cu.c \
        dwarf2/dwz.c \
        dwarf2/expr.c \
diff --git a/gdb/dwarf2/comp-unit-head.c b/gdb/dwarf2/comp-unit-head.c
new file mode 100644 (file)
index 0000000..8cc741d
--- /dev/null
@@ -0,0 +1,246 @@
+/* DWARF 2 debugging format support for GDB.
+
+   Copyright (C) 1994-2021 Free Software Foundation, Inc.
+
+   Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology,
+   Inc.  with support from Florida State University (under contract
+   with the Ada Joint Program Office), and Silicon Graphics, Inc.
+   Initial contribution by Brent Benson, Harris Computer Systems, Inc.,
+   based on Fred Fish's (Cygnus Support) implementation of DWARF 1
+   support.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include "defs.h"
+#include "dwarf2/comp-unit-head.h"
+#include "dwarf2/leb.h"
+#include "dwarf2/read.h"
+#include "dwarf2/section.h"
+#include "dwarf2/stringify.h"
+
+/* See comp-unit-head.h.  */
+
+const gdb_byte *
+read_comp_unit_head (struct comp_unit_head *cu_header,
+                    const gdb_byte *info_ptr,
+                    struct dwarf2_section_info *section,
+                    rcuh_kind section_kind)
+{
+  int signed_addr;
+  unsigned int bytes_read;
+  const char *filename = section->get_file_name ();
+  bfd *abfd = section->get_bfd_owner ();
+
+  cu_header->length = read_initial_length (abfd, info_ptr, &bytes_read);
+  cu_header->initial_length_size = bytes_read;
+  cu_header->offset_size = (bytes_read == 4) ? 4 : 8;
+  info_ptr += bytes_read;
+  unsigned version = read_2_bytes (abfd, info_ptr);
+  if (version < 2 || version > 5)
+    error (_("Dwarf Error: wrong version in compilation unit header "
+          "(is %d, should be 2, 3, 4 or 5) [in module %s]"),
+          version, filename);
+  cu_header->version = version;
+  info_ptr += 2;
+  if (cu_header->version < 5)
+    switch (section_kind)
+      {
+      case rcuh_kind::COMPILE:
+       cu_header->unit_type = DW_UT_compile;
+       break;
+      case rcuh_kind::TYPE:
+       cu_header->unit_type = DW_UT_type;
+       break;
+      default:
+       internal_error (__FILE__, __LINE__,
+                       _("read_comp_unit_head: invalid section_kind"));
+      }
+  else
+    {
+      cu_header->unit_type = static_cast<enum dwarf_unit_type>
+                                                (read_1_byte (abfd, info_ptr));
+      info_ptr += 1;
+      switch (cu_header->unit_type)
+       {
+       case DW_UT_compile:
+       case DW_UT_partial:
+       case DW_UT_skeleton:
+       case DW_UT_split_compile:
+         if (section_kind != rcuh_kind::COMPILE)
+           error (_("Dwarf Error: wrong unit_type in compilation unit header "
+                  "(is %s, should be %s) [in module %s]"),
+                  dwarf_unit_type_name (cu_header->unit_type),
+                  dwarf_unit_type_name (DW_UT_type), filename);
+         break;
+       case DW_UT_type:
+       case DW_UT_split_type:
+         section_kind = rcuh_kind::TYPE;
+         break;
+       default:
+         error (_("Dwarf Error: wrong unit_type in compilation unit header "
+                "(is %#04x, should be one of: %s, %s, %s, %s or %s) "
+                "[in module %s]"), cu_header->unit_type,
+                dwarf_unit_type_name (DW_UT_compile),
+                dwarf_unit_type_name (DW_UT_skeleton),
+                dwarf_unit_type_name (DW_UT_split_compile),
+                dwarf_unit_type_name (DW_UT_type),
+                dwarf_unit_type_name (DW_UT_split_type), filename);
+       }
+
+      cu_header->addr_size = read_1_byte (abfd, info_ptr);
+      info_ptr += 1;
+    }
+  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)
+    {
+      cu_header->addr_size = read_1_byte (abfd, info_ptr);
+      info_ptr += 1;
+    }
+  signed_addr = bfd_get_sign_extend_vma (abfd);
+  if (signed_addr < 0)
+    internal_error (__FILE__, __LINE__,
+                   _("read_comp_unit_head: dwarf from non elf file"));
+  cu_header->signed_addr_p = signed_addr;
+
+  bool header_has_signature = section_kind == rcuh_kind::TYPE
+    || cu_header->unit_type == DW_UT_skeleton
+    || cu_header->unit_type == DW_UT_split_compile;
+
+  if (header_has_signature)
+    {
+      cu_header->signature = read_8_bytes (abfd, info_ptr);
+      info_ptr += 8;
+    }
+
+  if (section_kind == rcuh_kind::TYPE)
+    {
+      LONGEST type_offset;
+      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)
+       error (_("Dwarf Error: Too big type_offset in compilation unit "
+              "header (is %s) [in module %s]"), plongest (type_offset),
+              filename);
+    }
+
+  return info_ptr;
+}
+
+/* Subroutine of read_and_check_comp_unit_head and
+   read_and_check_type_unit_head to simplify them.
+   Perform various error checking on the header.  */
+
+static void
+error_check_comp_unit_head (dwarf2_per_objfile *per_objfile,
+                           struct comp_unit_head *header,
+                           struct dwarf2_section_info *section,
+                           struct dwarf2_section_info *abbrev_section)
+{
+  const char *filename = section->get_file_name ();
+
+  if (to_underlying (header->abbrev_sect_off)
+      >= abbrev_section->get_size (per_objfile->objfile))
+    error (_("Dwarf Error: bad offset (%s) in compilation unit header "
+          "(offset %s + 6) [in module %s]"),
+          sect_offset_str (header->abbrev_sect_off),
+          sect_offset_str (header->sect_off),
+          filename);
+
+  /* Cast to ULONGEST to use 64-bit arithmetic when possible to
+     avoid potential 32-bit overflow.  */
+  if (((ULONGEST) header->sect_off + header->get_length ())
+      > section->size)
+    error (_("Dwarf Error: bad length (0x%x) in compilation unit header "
+          "(offset %s + 0) [in module %s]"),
+          header->length, sect_offset_str (header->sect_off),
+          filename);
+}
+
+/* See comp-unit-head.h.  */
+
+const gdb_byte *
+read_and_check_comp_unit_head (dwarf2_per_objfile *per_objfile,
+                              struct comp_unit_head *header,
+                              struct dwarf2_section_info *section,
+                              struct dwarf2_section_info *abbrev_section,
+                              const gdb_byte *info_ptr,
+                              rcuh_kind section_kind)
+{
+  const gdb_byte *beg_of_comp_unit = info_ptr;
+
+  header->sect_off = (sect_offset) (beg_of_comp_unit - section->buffer);
+
+  info_ptr = read_comp_unit_head (header, info_ptr, section, section_kind);
+
+  header->first_die_cu_offset = (cu_offset) (info_ptr - beg_of_comp_unit);
+
+  error_check_comp_unit_head (per_objfile, header, section, abbrev_section);
+
+  return info_ptr;
+}
+
+CORE_ADDR
+comp_unit_head::read_address (bfd *abfd, const gdb_byte *buf,
+                             unsigned int *bytes_read) const
+{
+  CORE_ADDR retval = 0;
+
+  if (signed_addr_p)
+    {
+      switch (addr_size)
+       {
+       case 2:
+         retval = bfd_get_signed_16 (abfd, buf);
+         break;
+       case 4:
+         retval = bfd_get_signed_32 (abfd, buf);
+         break;
+       case 8:
+         retval = bfd_get_signed_64 (abfd, buf);
+         break;
+       default:
+         internal_error (__FILE__, __LINE__,
+                         _("read_address: bad switch, signed [in module %s]"),
+                         bfd_get_filename (abfd));
+       }
+    }
+  else
+    {
+      switch (addr_size)
+       {
+       case 2:
+         retval = bfd_get_16 (abfd, buf);
+         break;
+       case 4:
+         retval = bfd_get_32 (abfd, buf);
+         break;
+       case 8:
+         retval = bfd_get_64 (abfd, buf);
+         break;
+       default:
+         internal_error (__FILE__, __LINE__,
+                         _("read_address: bad switch, "
+                           "unsigned [in module %s]"),
+                         bfd_get_filename (abfd));
+       }
+    }
+
+  *bytes_read = addr_size;
+  return retval;
+}
diff --git a/gdb/dwarf2/comp-unit-head.h b/gdb/dwarf2/comp-unit-head.h
new file mode 100644 (file)
index 0000000..2d3ff4d
--- /dev/null
@@ -0,0 +1,121 @@
+/* Low-level DWARF 2 reading code
+
+   Copyright (C) 1994-2021 Free Software Foundation, Inc.
+
+   Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology,
+   Inc.  with support from Florida State University (under contract
+   with the Ada Joint Program Office), and Silicon Graphics, Inc.
+   Initial contribution by Brent Benson, Harris Computer Systems, Inc.,
+   based on Fred Fish's (Cygnus Support) implementation of DWARF 1
+   support.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#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
+   translation, looks like this.  */
+struct comp_unit_head
+{
+  unsigned int length;
+  unsigned char version;
+  unsigned char addr_size;
+  unsigned char signed_addr_p;
+  sect_offset abbrev_sect_off;
+
+  /* Size of file offsets; either 4 or 8.  */
+  unsigned int offset_size;
+
+  /* Size of the length field; either 4 or 12.  */
+  unsigned int initial_length_size;
+
+  enum dwarf_unit_type unit_type;
+
+  /* Offset to first die in this cu from the start of the cu.
+     This will be the first byte following the compilation unit header.  */
+  cu_offset first_die_cu_offset;
+
+  /* Offset to the first byte of this compilation unit header in the
+     .debug_info section, for resolving relative reference dies.  */
+  sect_offset sect_off;
+
+  /* For types, offset in the type's DIE of the type defined by this TU.  */
+  cu_offset type_cu_offset_in_tu;
+
+  /* 64-bit signature of this unit. For type units, it denotes the signature of
+     the type (DW_UT_type in DWARF 4, additionally DW_UT_split_type in DWARF 5).
+     Also used in DWARF 5, to denote the dwo id when the unit type is
+     DW_UT_skeleton or DW_UT_split_compile.  */
+  ULONGEST signature;
+
+  /* Return the total length of the CU described by this header.  */
+  unsigned int get_length () const
+  {
+    return initial_length_size + length;
+  }
+
+  /* Return TRUE if OFF is within this CU.  */
+  bool offset_in_cu_p (sect_offset off) const
+  {
+    sect_offset bottom = sect_off;
+    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;
+  }
+
+  /* Read an address from BUF.  BYTES_READ is updated.  */
+  CORE_ADDR read_address (bfd *abfd, const gdb_byte *buf,
+                         unsigned int *bytes_read) const;
+};
+
+/* Expected enum dwarf_unit_type for read_comp_unit_head.  */
+enum class rcuh_kind { COMPILE, TYPE };
+
+/* Read in the comp unit header information from the debug_info at info_ptr.
+   Use rcuh_kind::COMPILE as the default type if not known by the caller.
+   NOTE: This leaves members offset, first_die_offset to be filled in
+   by the caller.  */
+extern const gdb_byte *read_comp_unit_head
+  (struct comp_unit_head *cu_header,
+   const gdb_byte *info_ptr,
+   struct dwarf2_section_info *section,
+   rcuh_kind section_kind);
+
+/* Read in a CU/TU header and perform some basic error checking.
+   The contents of the header are stored in HEADER.
+   The result is a pointer to the start of the first DIE.  */
+extern const gdb_byte *read_and_check_comp_unit_head
+  (dwarf2_per_objfile *per_objfile,
+   struct comp_unit_head *header,
+   struct dwarf2_section_info *section,
+   struct dwarf2_section_info *abbrev_section,
+   const gdb_byte *info_ptr,
+   rcuh_kind section_kind);
+
+#endif /* GDB_DWARF2_COMP_UNIT_H */
diff --git a/gdb/dwarf2/comp-unit.c b/gdb/dwarf2/comp-unit.c
deleted file mode 100644 (file)
index e22f2e9..0000000
+++ /dev/null
@@ -1,246 +0,0 @@
-/* DWARF 2 debugging format support for GDB.
-
-   Copyright (C) 1994-2021 Free Software Foundation, Inc.
-
-   Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology,
-   Inc.  with support from Florida State University (under contract
-   with the Ada Joint Program Office), and Silicon Graphics, Inc.
-   Initial contribution by Brent Benson, Harris Computer Systems, Inc.,
-   based on Fred Fish's (Cygnus Support) implementation of DWARF 1
-   support.
-
-   This file is part of GDB.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#include "defs.h"
-#include "dwarf2/comp-unit.h"
-#include "dwarf2/leb.h"
-#include "dwarf2/read.h"
-#include "dwarf2/section.h"
-#include "dwarf2/stringify.h"
-
-/* See comp-unit.h.  */
-
-const gdb_byte *
-read_comp_unit_head (struct comp_unit_head *cu_header,
-                    const gdb_byte *info_ptr,
-                    struct dwarf2_section_info *section,
-                    rcuh_kind section_kind)
-{
-  int signed_addr;
-  unsigned int bytes_read;
-  const char *filename = section->get_file_name ();
-  bfd *abfd = section->get_bfd_owner ();
-
-  cu_header->length = read_initial_length (abfd, info_ptr, &bytes_read);
-  cu_header->initial_length_size = bytes_read;
-  cu_header->offset_size = (bytes_read == 4) ? 4 : 8;
-  info_ptr += bytes_read;
-  unsigned version = read_2_bytes (abfd, info_ptr);
-  if (version < 2 || version > 5)
-    error (_("Dwarf Error: wrong version in compilation unit header "
-          "(is %d, should be 2, 3, 4 or 5) [in module %s]"),
-          version, filename);
-  cu_header->version = version;
-  info_ptr += 2;
-  if (cu_header->version < 5)
-    switch (section_kind)
-      {
-      case rcuh_kind::COMPILE:
-       cu_header->unit_type = DW_UT_compile;
-       break;
-      case rcuh_kind::TYPE:
-       cu_header->unit_type = DW_UT_type;
-       break;
-      default:
-       internal_error (__FILE__, __LINE__,
-                       _("read_comp_unit_head: invalid section_kind"));
-      }
-  else
-    {
-      cu_header->unit_type = static_cast<enum dwarf_unit_type>
-                                                (read_1_byte (abfd, info_ptr));
-      info_ptr += 1;
-      switch (cu_header->unit_type)
-       {
-       case DW_UT_compile:
-       case DW_UT_partial:
-       case DW_UT_skeleton:
-       case DW_UT_split_compile:
-         if (section_kind != rcuh_kind::COMPILE)
-           error (_("Dwarf Error: wrong unit_type in compilation unit header "
-                  "(is %s, should be %s) [in module %s]"),
-                  dwarf_unit_type_name (cu_header->unit_type),
-                  dwarf_unit_type_name (DW_UT_type), filename);
-         break;
-       case DW_UT_type:
-       case DW_UT_split_type:
-         section_kind = rcuh_kind::TYPE;
-         break;
-       default:
-         error (_("Dwarf Error: wrong unit_type in compilation unit header "
-                "(is %#04x, should be one of: %s, %s, %s, %s or %s) "
-                "[in module %s]"), cu_header->unit_type,
-                dwarf_unit_type_name (DW_UT_compile),
-                dwarf_unit_type_name (DW_UT_skeleton),
-                dwarf_unit_type_name (DW_UT_split_compile),
-                dwarf_unit_type_name (DW_UT_type),
-                dwarf_unit_type_name (DW_UT_split_type), filename);
-       }
-
-      cu_header->addr_size = read_1_byte (abfd, info_ptr);
-      info_ptr += 1;
-    }
-  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)
-    {
-      cu_header->addr_size = read_1_byte (abfd, info_ptr);
-      info_ptr += 1;
-    }
-  signed_addr = bfd_get_sign_extend_vma (abfd);
-  if (signed_addr < 0)
-    internal_error (__FILE__, __LINE__,
-                   _("read_comp_unit_head: dwarf from non elf file"));
-  cu_header->signed_addr_p = signed_addr;
-
-  bool header_has_signature = section_kind == rcuh_kind::TYPE
-    || cu_header->unit_type == DW_UT_skeleton
-    || cu_header->unit_type == DW_UT_split_compile;
-
-  if (header_has_signature)
-    {
-      cu_header->signature = read_8_bytes (abfd, info_ptr);
-      info_ptr += 8;
-    }
-
-  if (section_kind == rcuh_kind::TYPE)
-    {
-      LONGEST type_offset;
-      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)
-       error (_("Dwarf Error: Too big type_offset in compilation unit "
-              "header (is %s) [in module %s]"), plongest (type_offset),
-              filename);
-    }
-
-  return info_ptr;
-}
-
-/* Subroutine of read_and_check_comp_unit_head and
-   read_and_check_type_unit_head to simplify them.
-   Perform various error checking on the header.  */
-
-static void
-error_check_comp_unit_head (dwarf2_per_objfile *per_objfile,
-                           struct comp_unit_head *header,
-                           struct dwarf2_section_info *section,
-                           struct dwarf2_section_info *abbrev_section)
-{
-  const char *filename = section->get_file_name ();
-
-  if (to_underlying (header->abbrev_sect_off)
-      >= abbrev_section->get_size (per_objfile->objfile))
-    error (_("Dwarf Error: bad offset (%s) in compilation unit header "
-          "(offset %s + 6) [in module %s]"),
-          sect_offset_str (header->abbrev_sect_off),
-          sect_offset_str (header->sect_off),
-          filename);
-
-  /* Cast to ULONGEST to use 64-bit arithmetic when possible to
-     avoid potential 32-bit overflow.  */
-  if (((ULONGEST) header->sect_off + header->get_length ())
-      > section->size)
-    error (_("Dwarf Error: bad length (0x%x) in compilation unit header "
-          "(offset %s + 0) [in module %s]"),
-          header->length, sect_offset_str (header->sect_off),
-          filename);
-}
-
-/* See comp-unit.h.  */
-
-const gdb_byte *
-read_and_check_comp_unit_head (dwarf2_per_objfile *per_objfile,
-                              struct comp_unit_head *header,
-                              struct dwarf2_section_info *section,
-                              struct dwarf2_section_info *abbrev_section,
-                              const gdb_byte *info_ptr,
-                              rcuh_kind section_kind)
-{
-  const gdb_byte *beg_of_comp_unit = info_ptr;
-
-  header->sect_off = (sect_offset) (beg_of_comp_unit - section->buffer);
-
-  info_ptr = read_comp_unit_head (header, info_ptr, section, section_kind);
-
-  header->first_die_cu_offset = (cu_offset) (info_ptr - beg_of_comp_unit);
-
-  error_check_comp_unit_head (per_objfile, header, section, abbrev_section);
-
-  return info_ptr;
-}
-
-CORE_ADDR
-comp_unit_head::read_address (bfd *abfd, const gdb_byte *buf,
-                             unsigned int *bytes_read) const
-{
-  CORE_ADDR retval = 0;
-
-  if (signed_addr_p)
-    {
-      switch (addr_size)
-       {
-       case 2:
-         retval = bfd_get_signed_16 (abfd, buf);
-         break;
-       case 4:
-         retval = bfd_get_signed_32 (abfd, buf);
-         break;
-       case 8:
-         retval = bfd_get_signed_64 (abfd, buf);
-         break;
-       default:
-         internal_error (__FILE__, __LINE__,
-                         _("read_address: bad switch, signed [in module %s]"),
-                         bfd_get_filename (abfd));
-       }
-    }
-  else
-    {
-      switch (addr_size)
-       {
-       case 2:
-         retval = bfd_get_16 (abfd, buf);
-         break;
-       case 4:
-         retval = bfd_get_32 (abfd, buf);
-         break;
-       case 8:
-         retval = bfd_get_64 (abfd, buf);
-         break;
-       default:
-         internal_error (__FILE__, __LINE__,
-                         _("read_address: bad switch, "
-                           "unsigned [in module %s]"),
-                         bfd_get_filename (abfd));
-       }
-    }
-
-  *bytes_read = addr_size;
-  return retval;
-}
diff --git a/gdb/dwarf2/comp-unit.h b/gdb/dwarf2/comp-unit.h
deleted file mode 100644 (file)
index 2d3ff4d..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/* Low-level DWARF 2 reading code
-
-   Copyright (C) 1994-2021 Free Software Foundation, Inc.
-
-   Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology,
-   Inc.  with support from Florida State University (under contract
-   with the Ada Joint Program Office), and Silicon Graphics, Inc.
-   Initial contribution by Brent Benson, Harris Computer Systems, Inc.,
-   based on Fred Fish's (Cygnus Support) implementation of DWARF 1
-   support.
-
-   This file is part of GDB.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#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
-   translation, looks like this.  */
-struct comp_unit_head
-{
-  unsigned int length;
-  unsigned char version;
-  unsigned char addr_size;
-  unsigned char signed_addr_p;
-  sect_offset abbrev_sect_off;
-
-  /* Size of file offsets; either 4 or 8.  */
-  unsigned int offset_size;
-
-  /* Size of the length field; either 4 or 12.  */
-  unsigned int initial_length_size;
-
-  enum dwarf_unit_type unit_type;
-
-  /* Offset to first die in this cu from the start of the cu.
-     This will be the first byte following the compilation unit header.  */
-  cu_offset first_die_cu_offset;
-
-  /* Offset to the first byte of this compilation unit header in the
-     .debug_info section, for resolving relative reference dies.  */
-  sect_offset sect_off;
-
-  /* For types, offset in the type's DIE of the type defined by this TU.  */
-  cu_offset type_cu_offset_in_tu;
-
-  /* 64-bit signature of this unit. For type units, it denotes the signature of
-     the type (DW_UT_type in DWARF 4, additionally DW_UT_split_type in DWARF 5).
-     Also used in DWARF 5, to denote the dwo id when the unit type is
-     DW_UT_skeleton or DW_UT_split_compile.  */
-  ULONGEST signature;
-
-  /* Return the total length of the CU described by this header.  */
-  unsigned int get_length () const
-  {
-    return initial_length_size + length;
-  }
-
-  /* Return TRUE if OFF is within this CU.  */
-  bool offset_in_cu_p (sect_offset off) const
-  {
-    sect_offset bottom = sect_off;
-    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;
-  }
-
-  /* Read an address from BUF.  BYTES_READ is updated.  */
-  CORE_ADDR read_address (bfd *abfd, const gdb_byte *buf,
-                         unsigned int *bytes_read) const;
-};
-
-/* Expected enum dwarf_unit_type for read_comp_unit_head.  */
-enum class rcuh_kind { COMPILE, TYPE };
-
-/* Read in the comp unit header information from the debug_info at info_ptr.
-   Use rcuh_kind::COMPILE as the default type if not known by the caller.
-   NOTE: This leaves members offset, first_die_offset to be filled in
-   by the caller.  */
-extern const gdb_byte *read_comp_unit_head
-  (struct comp_unit_head *cu_header,
-   const gdb_byte *info_ptr,
-   struct dwarf2_section_info *section,
-   rcuh_kind section_kind);
-
-/* Read in a CU/TU header and perform some basic error checking.
-   The contents of the header are stored in HEADER.
-   The result is a pointer to the start of the first DIE.  */
-extern const gdb_byte *read_and_check_comp_unit_head
-  (dwarf2_per_objfile *per_objfile,
-   struct comp_unit_head *header,
-   struct dwarf2_section_info *section,
-   struct dwarf2_section_info *abbrev_section,
-   const gdb_byte *info_ptr,
-   rcuh_kind section_kind);
-
-#endif /* GDB_DWARF2_COMP_UNIT_H */
index 83a4aac3f08fd46e17adc91518d3728df346609a..ff56ec5527b456659466c4781cbf24289c793b7f 100644 (file)
@@ -21,7 +21,7 @@
 #define GDB_DWARF2_CU_H
 
 #include "buildsym.h"
-#include "dwarf2/comp-unit.h"
+#include "dwarf2/comp-unit-head.h"
 #include "gdbsupport/gdb_optional.h"
 
 /* Type used for delaying computation of method physnames.
index 7575297f9667ff6c5885f57ec50482b73509825f..07a8f5aa109acaa506fda2bdc343b1e124a2f027 100644 (file)
@@ -18,7 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "dwarf2/comp-unit.h"
+#include "dwarf2/comp-unit-head.h"
 #include "dwarf2/leb.h"
 #include "dwarf2/line-header.h"
 #include "dwarf2/read.h"
index 7a321c14d4519d049c185817dda1a066f7051f16..8a57aeee61cabdb1686bd8d229ea3b860668e7b7 100644 (file)
@@ -32,7 +32,7 @@
 #include "dwarf2/read.h"
 #include "dwarf2/abbrev.h"
 #include "dwarf2/attribute.h"
-#include "dwarf2/comp-unit.h"
+#include "dwarf2/comp-unit-head.h"
 #include "dwarf2/cu.h"
 #include "dwarf2/index-cache.h"
 #include "dwarf2/index-common.h"
index 756d1934ca0c2fced81d88b91090a7614159f90f..6af1f44bd47c74f57d28c7dd04edb124bd1c9d91 100644 (file)
@@ -22,7 +22,7 @@
 
 #include <queue>
 #include <unordered_map>
-#include "dwarf2/comp-unit.h"
+#include "dwarf2/comp-unit-head.h"
 #include "dwarf2/index-cache.h"
 #include "dwarf2/section.h"
 #include "filename-seen-cache.h"
This page took 0.040388 seconds and 4 git commands to generate.