diff options
author | Tom Tromey <tom@tromey.com> | 2020-02-08 13:40:54 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2020-02-08 13:43:24 -0700 |
commit | 4057dfde49d7867ad41906ed11705e450a08b4cf (patch) | |
tree | dadd9020aab5e5e543faf9873cbaf6bc8bb6ab0c /gdb/dwarf2/comp-unit.h | |
parent | 24aa364d607c1f5845b1ff200f385d11ebba7e02 (diff) | |
download | binutils-4057dfde49d7867ad41906ed11705e450a08b4cf.zip binutils-4057dfde49d7867ad41906ed11705e450a08b4cf.tar.gz binutils-4057dfde49d7867ad41906ed11705e450a08b4cf.tar.bz2 |
Create dwarf2/comp-unit.[ch]
This creates the new files dwarf2/comp-unit.[ch], moving
comp_unit_head and helpers to those files. A couple of functions are
turned into methods, because it was convenient to do so now.
2020-02-08 Tom Tromey <tom@tromey.com>
* Makefile.in (COMMON_SFILES): Add dwarf2/comp-unit.c.
* dwarf2/read.c (struct comp_unit_head): Move to
dwarf2/comp-unit.h.
(enum class rcuh_kind): Move to comp-unit.h.
(get_cu_length, offset_in_cu_p): Now methods on comp_unit_head.
(read_comp_unit_head, error_check_comp_unit_head)
(read_and_check_comp_unit_head): Move to comp-unit.c.
(read_offset, dwarf_unit_type_name): Likewise.
(create_debug_type_hash_table, read_cutu_die_from_dwo)
(cutu_reader::cutu_reader, read_call_site_scope)
(find_partial_die, follow_die_offset): Update.
* dwarf2/comp-unit.h: New file, from dwarf2read.c.
Change-Id: Id961b9674c0081ed061083c8152c38b27b27388a
Diffstat (limited to 'gdb/dwarf2/comp-unit.h')
-rw-r--r-- | gdb/dwarf2/comp-unit.h | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/gdb/dwarf2/comp-unit.h b/gdb/dwarf2/comp-unit.h new file mode 100644 index 0000000..b4483ac --- /dev/null +++ b/gdb/dwarf2/comp-unit.h @@ -0,0 +1,114 @@ +/* Low-level DWARF 2 reading code + + Copyright (C) 1994-2020 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 "gdbtypes.h" + +/* The data in a compilation unit header, after target2host + translation, looks like this. */ +struct comp_unit_head +{ + unsigned int length; + short 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 the first byte of this compilation unit header in the + .debug_info section, for resolving relative reference dies. */ + sect_offset sect_off; + + /* 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; + + + /* 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; + + /* For types, offset in the type's DIE of the type defined by this TU. */ + cu_offset type_cu_offset_in_tu; + + /* 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; + } +}; + +/* 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 + (struct dwarf2_per_objfile *dwarf2_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); + +/* 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 */ |