]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/dwarf2/cu.c
Move some dwarf2_cu methods to new file
[thirdparty/binutils-gdb.git] / gdb / dwarf2 / cu.c
1 /* DWARF CU data structure
2
3 Copyright (C) 2021 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 #include "defs.h"
21 #include "dwarf2/cu.h"
22 #include "dwarf2/read.h"
23
24 /* Initialize dwarf2_cu to read PER_CU, in the context of PER_OBJFILE. */
25
26 dwarf2_cu::dwarf2_cu (dwarf2_per_cu_data *per_cu,
27 dwarf2_per_objfile *per_objfile)
28 : per_cu (per_cu),
29 per_objfile (per_objfile),
30 mark (false),
31 has_loclist (false),
32 checked_producer (false),
33 producer_is_gxx_lt_4_6 (false),
34 producer_is_gcc_lt_4_3 (false),
35 producer_is_icc (false),
36 producer_is_icc_lt_14 (false),
37 producer_is_codewarrior (false),
38 processing_has_namespace_info (false)
39 {
40 }
41
42 /* See cu.h. */
43
44 struct type *
45 dwarf2_cu::addr_sized_int_type (bool unsigned_p) const
46 {
47 int addr_size = this->per_cu->addr_size ();
48 return this->per_objfile->int_type (addr_size, unsigned_p);
49 }
50
51 /* Start a symtab for DWARF. NAME, COMP_DIR, LOW_PC are passed to the
52 buildsym_compunit constructor. */
53
54 struct compunit_symtab *
55 dwarf2_cu::start_symtab (const char *name, const char *comp_dir,
56 CORE_ADDR low_pc)
57 {
58 gdb_assert (m_builder == nullptr);
59
60 m_builder.reset (new struct buildsym_compunit
61 (this->per_objfile->objfile,
62 name, comp_dir, language, low_pc));
63
64 list_in_scope = get_builder ()->get_file_symbols ();
65
66 get_builder ()->record_debugformat ("DWARF 2");
67 get_builder ()->record_producer (producer);
68
69 processing_has_namespace_info = false;
70
71 return get_builder ()->get_compunit_symtab ();
72 }
73
74 /* See read.h. */
75
76 struct type *
77 dwarf2_cu::addr_type () const
78 {
79 struct objfile *objfile = this->per_objfile->objfile;
80 struct type *void_type = objfile_type (objfile)->builtin_void;
81 struct type *addr_type = lookup_pointer_type (void_type);
82 int addr_size = this->per_cu->addr_size ();
83
84 if (TYPE_LENGTH (addr_type) == addr_size)
85 return addr_type;
86
87 addr_type = addr_sized_int_type (addr_type->is_unsigned ());
88 return addr_type;
89 }