]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Move some dwarf2_cu methods to new file
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:06 +0000 (14:16 -0600)
This moves some of the dwarf2_cu methods to a new file, dwarf2/cu.c.

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

* dwarf2/read.c (dwarf2_cu::addr_sized_int_type)
(dwarf2_cu::start_symtab, dwarf2_cu::addr_type)
(dwarf2_cu::dwarf2_cu): Move to cu.c.
* dwarf2/cu.c: New file.
* Makefile.in (COMMON_SFILES): Add dwarf2/cu.c.

gdb/ChangeLog
gdb/Makefile.in
gdb/dwarf2/cu.c [new file with mode: 0644]
gdb/dwarf2/read.c

index 3f44f2150f2ae58ed7bad27dffe3ab3f4ca1a717..9ff54451340e5cb788ad3ffffc8f63a39ee005c8 100644 (file)
@@ -1,3 +1,11 @@
+2021-05-17  Tom Tromey  <tom@tromey.com>
+
+       * dwarf2/read.c (dwarf2_cu::addr_sized_int_type)
+       (dwarf2_cu::start_symtab, dwarf2_cu::addr_type)
+       (dwarf2_cu::dwarf2_cu): Move to cu.c.
+       * dwarf2/cu.c: New file.
+       * Makefile.in (COMMON_SFILES): Add dwarf2/cu.c.
+
 2021-05-17  Tom Tromey  <tom@tromey.com>
 
        * Makefile.in (HFILES_NO_SRCDIR): Add dwarf2/cu.h.
index 4737cc9eecfc9d9e0050c3f51e82a485e60ca04c..1f37fe43024b3327351355fbd4401b2af3504420 100644 (file)
@@ -1026,6 +1026,7 @@ COMMON_SFILES = \
        dwarf2/abbrev.c \
        dwarf2/attribute.c \
        dwarf2/comp-unit.c \
+       dwarf2/cu.c \
        dwarf2/dwz.c \
        dwarf2/expr.c \
        dwarf2/frame-tailcall.c \
diff --git a/gdb/dwarf2/cu.c b/gdb/dwarf2/cu.c
new file mode 100644 (file)
index 0000000..4f13f4f
--- /dev/null
@@ -0,0 +1,89 @@
+/* DWARF CU data structure
+
+   Copyright (C) 2021 Free Software Foundation, Inc.
+
+   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/cu.h"
+#include "dwarf2/read.h"
+
+/* Initialize dwarf2_cu to read PER_CU, in the context of PER_OBJFILE.  */
+
+dwarf2_cu::dwarf2_cu (dwarf2_per_cu_data *per_cu,
+                     dwarf2_per_objfile *per_objfile)
+  : per_cu (per_cu),
+    per_objfile (per_objfile),
+    mark (false),
+    has_loclist (false),
+    checked_producer (false),
+    producer_is_gxx_lt_4_6 (false),
+    producer_is_gcc_lt_4_3 (false),
+    producer_is_icc (false),
+    producer_is_icc_lt_14 (false),
+    producer_is_codewarrior (false),
+    processing_has_namespace_info (false)
+{
+}
+
+/* See cu.h.  */
+
+struct type *
+dwarf2_cu::addr_sized_int_type (bool unsigned_p) const
+{
+  int addr_size = this->per_cu->addr_size ();
+  return this->per_objfile->int_type (addr_size, unsigned_p);
+}
+
+/* Start a symtab for DWARF.  NAME, COMP_DIR, LOW_PC are passed to the
+   buildsym_compunit constructor.  */
+
+struct compunit_symtab *
+dwarf2_cu::start_symtab (const char *name, const char *comp_dir,
+                        CORE_ADDR low_pc)
+{
+  gdb_assert (m_builder == nullptr);
+
+  m_builder.reset (new struct buildsym_compunit
+                  (this->per_objfile->objfile,
+                   name, comp_dir, language, low_pc));
+
+  list_in_scope = get_builder ()->get_file_symbols ();
+
+  get_builder ()->record_debugformat ("DWARF 2");
+  get_builder ()->record_producer (producer);
+
+  processing_has_namespace_info = false;
+
+  return get_builder ()->get_compunit_symtab ();
+}
+
+/* See read.h.  */
+
+struct type *
+dwarf2_cu::addr_type () const
+{
+  struct objfile *objfile = this->per_objfile->objfile;
+  struct type *void_type = objfile_type (objfile)->builtin_void;
+  struct type *addr_type = lookup_pointer_type (void_type);
+  int addr_size = this->per_cu->addr_size ();
+
+  if (TYPE_LENGTH (addr_type) == addr_size)
+    return addr_type;
+
+  addr_type = addr_sized_int_type (addr_type->is_unsigned ());
+  return addr_type;
+}
index d0c6bc3f3558424a77edbbfa0eb224d90ef62d2f..0faa682f7385a16c0a4bfda4bc7c758e638ee8d0 100644 (file)
@@ -18341,15 +18341,6 @@ dwarf2_per_objfile::int_type (int size_in_bytes, bool unsigned_p) const
   gdb_assert_not_reached ("unable to find suitable integer type");
 }
 
-/* See read.h.  */
-
-struct type *
-dwarf2_cu::addr_sized_int_type (bool unsigned_p) const
-{
-  int addr_size = this->per_cu->addr_size ();
-  return this->per_objfile->int_type (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.  */
@@ -21446,29 +21437,6 @@ dwarf2_start_subfile (struct dwarf2_cu *cu, const char *filename,
   cu->get_builder ()->start_subfile (filename);
 }
 
-/* Start a symtab for DWARF.  NAME, COMP_DIR, LOW_PC are passed to the
-   buildsym_compunit constructor.  */
-
-struct compunit_symtab *
-dwarf2_cu::start_symtab (const char *name, const char *comp_dir,
-                        CORE_ADDR low_pc)
-{
-  gdb_assert (m_builder == nullptr);
-
-  m_builder.reset (new struct buildsym_compunit
-                  (this->per_objfile->objfile,
-                   name, comp_dir, language, low_pc));
-
-  list_in_scope = get_builder ()->get_file_symbols ();
-
-  get_builder ()->record_debugformat ("DWARF 2");
-  get_builder ()->record_producer (producer);
-
-  processing_has_namespace_info = false;
-
-  return get_builder ()->get_compunit_symtab ();
-}
-
 static void
 var_decode_location (struct attribute *attr, struct symbol *sym,
                     struct dwarf2_cu *cu)
@@ -24319,23 +24287,6 @@ dwarf2_per_cu_data::ref_addr_size () const
     return header->offset_size;
 }
 
-/* See read.h.  */
-
-struct type *
-dwarf2_cu::addr_type () const
-{
-  struct objfile *objfile = this->per_objfile->objfile;
-  struct type *void_type = objfile_type (objfile)->builtin_void;
-  struct type *addr_type = lookup_pointer_type (void_type);
-  int addr_size = this->per_cu->addr_size ();
-
-  if (TYPE_LENGTH (addr_type) == addr_size)
-    return addr_type;
-
-  addr_type = addr_sized_int_type (addr_type->is_unsigned ());
-  return addr_type;
-}
-
 /* A helper function for dwarf2_find_containing_comp_unit that returns
    the index of the result, and that searches a vector.  It will
    return a result even if the offset in question does not actually
@@ -24459,24 +24410,6 @@ run_test ()
 
 #endif /* GDB_SELF_TEST */
 
-/* Initialize dwarf2_cu to read PER_CU, in the context of PER_OBJFILE.  */
-
-dwarf2_cu::dwarf2_cu (dwarf2_per_cu_data *per_cu,
-                     dwarf2_per_objfile *per_objfile)
-  : per_cu (per_cu),
-    per_objfile (per_objfile),
-    mark (false),
-    has_loclist (false),
-    checked_producer (false),
-    producer_is_gxx_lt_4_6 (false),
-    producer_is_gcc_lt_4_3 (false),
-    producer_is_icc (false),
-    producer_is_icc_lt_14 (false),
-    producer_is_codewarrior (false),
-    processing_has_namespace_info (false)
-{
-}
-
 /* Initialize basic fields of dwarf_cu CU according to DIE COMP_UNIT_DIE.  */
 
 static void