1 /* DWARF CU data structure
3 Copyright (C) 2021 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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/>. */
21 #include "dwarf2/cu.h"
22 #include "dwarf2/read.h"
24 /* Initialize dwarf2_cu to read PER_CU, in the context of PER_OBJFILE. */
26 dwarf2_cu::dwarf2_cu (dwarf2_per_cu_data
*per_cu
,
27 dwarf2_per_objfile
*per_objfile
)
29 per_objfile (per_objfile
),
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)
45 dwarf2_cu::addr_sized_int_type (bool unsigned_p
) const
47 int addr_size
= this->per_cu
->addr_size ();
48 return this->per_objfile
->int_type (addr_size
, unsigned_p
);
51 /* Start a symtab for DWARF. NAME, COMP_DIR, LOW_PC are passed to the
52 buildsym_compunit constructor. */
54 struct compunit_symtab
*
55 dwarf2_cu::start_symtab (const char *name
, const char *comp_dir
,
58 gdb_assert (m_builder
== nullptr);
60 m_builder
.reset (new struct buildsym_compunit
61 (this->per_objfile
->objfile
,
62 name
, comp_dir
, language
, low_pc
));
64 list_in_scope
= get_builder ()->get_file_symbols ();
66 get_builder ()->record_debugformat ("DWARF 2");
67 get_builder ()->record_producer (producer
);
69 processing_has_namespace_info
= false;
71 return get_builder ()->get_compunit_symtab ();
77 dwarf2_cu::addr_type () const
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 ();
84 if (TYPE_LENGTH (addr_type
) == addr_size
)
87 addr_type
= addr_sized_int_type (addr_type
->is_unsigned ());