2020-02-09 04:40:54 +08:00
|
|
|
/* DWARF 2 low-level section code
|
|
|
|
|
2021-01-01 16:03:39 +08:00
|
|
|
Copyright (C) 1994-2021 Free Software Foundation, Inc.
|
2020-02-09 04:40:54 +08:00
|
|
|
|
|
|
|
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_SECTION_H
|
|
|
|
#define GDB_DWARF2_SECTION_H
|
|
|
|
|
|
|
|
/* A descriptor for dwarf sections.
|
|
|
|
|
|
|
|
S.ASECTION, SIZE are typically initialized when the objfile is first
|
|
|
|
scanned. BUFFER, READIN are filled in later when the section is read.
|
|
|
|
If the section contained compressed data then SIZE is updated to record
|
|
|
|
the uncompressed size of the section.
|
|
|
|
|
|
|
|
DWP file format V2 introduces a wrinkle that is easiest to handle by
|
|
|
|
creating the concept of virtual sections contained within a real section.
|
|
|
|
In DWP V2 the sections of the input DWO files are concatenated together
|
|
|
|
into one section, but section offsets are kept relative to the original
|
|
|
|
input section.
|
|
|
|
If this is a virtual dwp-v2 section, S.CONTAINING_SECTION is a backlink to
|
|
|
|
the real section this "virtual" section is contained in, and BUFFER,SIZE
|
|
|
|
describe the virtual section. */
|
|
|
|
|
|
|
|
struct dwarf2_section_info
|
|
|
|
{
|
Change section functions to be methods of dwarf2_section_info
This changes various section-related functions to be methods on
dwarf2_section_info. I think this clarifies the role of these
functions. This also changes one such function to return bool.
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (dwarf2_section_buffer_overflow_complaint)
(dwarf2_section_size, dwarf2_get_section_info)
(create_signatured_type_table_from_debug_names)
(create_addrmap_from_aranges, read_debug_names_from_section)
(get_gdb_index_contents_from_section, read_comp_unit_head)
(error_check_comp_unit_head, read_abbrev_offset)
(create_debug_type_hash_table, init_cu_die_reader)
(read_cutu_die_from_dwo, dwarf2_build_psymtabs_hard)
(read_comp_units_from_section, create_cus_hash_table)
(create_dwp_hash_table, create_dwo_unit_in_dwp_v1)
(create_dwp_v2_section, dwarf2_rnglists_process)
(dwarf2_ranges_process, read_die_and_siblings, read_full_die)
(abbrev_table_read_table, read_indirect_string_at_offset_from)
(read_indirect_string_from_dwz, read_addr_index_1)
(read_str_index, dwarf_decode_line_header, skip_form_bytes)
(dwarf_decode_macro_bytes, dwarf_decode_macros)
(fill_in_loclist_baton): Update.
* dwarf2/section.h (struct dwarf2_section_info) <get_name,
get_containing_section, get_bfd_owner, get_bfd_section,
get_file_name, get_id, get_flags, empty, read>: Declare methods.
(dwarf2_read_section, get_section_name, get_section_file_name)
(get_containing_section, get_section_bfd_owner)
(get_section_bfd_section, get_section_name, get_section_file_name)
(get_section_id, get_section_flags, dwarf2_section_empty_p): Don't
declare.
* dwarf2/section.c (dwarf2_section_info::get_containing_section)
(dwarf2_section_info::get_bfd_owner)
(dwarf2_section_info::get_bfd_section)
(dwarf2_section_info::get_name)
(dwarf2_section_info::get_file_name, dwarf2_section_info::get_id)
(dwarf2_section_info::get_flags, dwarf2_section_info::empty)
(dwarf2_section_info::read): Now methods.
* dwarf-index-write.c (class debug_names): Update.
Change-Id: Ic849f182f57a18bad6b1c7c3b9368005d307758a
2020-02-09 04:40:54 +08:00
|
|
|
/* Return the name of this section. */
|
|
|
|
const char *get_name () const;
|
|
|
|
|
|
|
|
/* Return the containing section of this section, which must be a
|
|
|
|
virtual section. */
|
|
|
|
struct dwarf2_section_info *get_containing_section () const;
|
|
|
|
|
|
|
|
/* Return the bfd owner of this section. */
|
|
|
|
struct bfd *get_bfd_owner () const;
|
|
|
|
|
|
|
|
/* Return the bfd section of this section.
|
|
|
|
Returns NULL if the section is not present. */
|
|
|
|
asection *get_bfd_section () const;
|
|
|
|
|
|
|
|
/* Return the name of the file this section is in. */
|
|
|
|
const char *get_file_name () const;
|
|
|
|
|
|
|
|
/* Return the id of this section.
|
|
|
|
Returns 0 if this section doesn't exist. */
|
|
|
|
int get_id () const;
|
|
|
|
|
|
|
|
/* Return the flags of this section. This section (or containing
|
|
|
|
section if this is a virtual section) must exist. */
|
|
|
|
int get_flags () const;
|
|
|
|
|
|
|
|
/* Return true if this section does not exist or if it has no
|
|
|
|
contents. */
|
|
|
|
bool empty () const;
|
|
|
|
|
|
|
|
/* Read the contents of this section.
|
|
|
|
OBJFILE is the main object file, but not necessarily the file where
|
|
|
|
the section comes from. E.g., for DWO files the bfd of INFO is the bfd
|
|
|
|
of the DWO file.
|
|
|
|
If the section is compressed, uncompress it before returning. */
|
|
|
|
void read (struct objfile *objfile);
|
|
|
|
|
2020-02-09 04:40:54 +08:00
|
|
|
/* A helper function that returns the size of a section in a safe way.
|
|
|
|
If you are positive that the section has been read before using the
|
|
|
|
size, then it is safe to refer to the dwarf2_section_info object's
|
|
|
|
"size" field directly. In other cases, you must call this
|
|
|
|
function, because for compressed sections the size field is not set
|
|
|
|
correctly until the section has been read. */
|
|
|
|
bfd_size_type get_size (struct objfile *objfile)
|
|
|
|
{
|
|
|
|
if (!readin)
|
|
|
|
read (objfile);
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2020-03-26 23:28:08 +08:00
|
|
|
/* Issue a complaint that something was outside the bounds of this
|
|
|
|
buffer. */
|
|
|
|
void overflow_complaint () const;
|
|
|
|
|
2020-03-26 23:28:08 +08:00
|
|
|
/* Return pointer to string in this section at offset STR_OFFSET
|
|
|
|
with error reporting string FORM_NAME. */
|
|
|
|
const char *read_string (struct objfile *objfile, LONGEST str_offset,
|
|
|
|
const char *form_name);
|
|
|
|
|
2020-02-09 04:40:54 +08:00
|
|
|
union
|
|
|
|
{
|
|
|
|
/* If this is a real section, the bfd section. */
|
|
|
|
asection *section;
|
|
|
|
/* If this is a virtual section, pointer to the containing ("real")
|
|
|
|
section. */
|
|
|
|
struct dwarf2_section_info *containing_section;
|
|
|
|
} s;
|
|
|
|
/* Pointer to section data, only valid if readin. */
|
|
|
|
const gdb_byte *buffer;
|
|
|
|
/* The size of the section, real or virtual. */
|
|
|
|
bfd_size_type size;
|
|
|
|
/* If this is a virtual section, the offset in the real section.
|
|
|
|
Only valid if is_virtual. */
|
|
|
|
bfd_size_type virtual_offset;
|
|
|
|
/* True if we have tried to read this section. */
|
|
|
|
bool readin;
|
|
|
|
/* True if this is a virtual section, False otherwise.
|
|
|
|
This specifies which of s.section and s.containing_section to use. */
|
|
|
|
bool is_virtual;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* GDB_DWARF2_SECTION_H */
|