#include "dwarf2/read.h"
#include "dwarf2/abbrev.h"
#include "dwarf2/attribute.h"
+#include "dwarf2/comp-unit.h"
#include "dwarf2/index-cache.h"
#include "dwarf2/index-common.h"
#include "dwarf2/leb.h"
/* local data types */
-/* 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;
-};
-
/* Type used for delaying computation of method physnames.
See comments for compute_delayed_physnames. */
struct delayed_method_info
static CORE_ADDR read_addr_index (struct dwarf2_cu *cu, unsigned int addr_index);
-static CORE_ADDR read_address (bfd *, const gdb_byte *ptr, struct dwarf2_cu *,
- unsigned int *);
-
-static LONGEST read_initial_length (bfd *, const gdb_byte *, unsigned int *);
-
static LONGEST read_checked_initial_length_and_offset
(bfd *, const gdb_byte *, const struct comp_unit_head *,
unsigned int *, unsigned int *);
-static LONGEST read_offset (bfd *, const gdb_byte *,
- const struct comp_unit_head *,
- unsigned int *);
-
-static LONGEST read_offset_1 (bfd *, const gdb_byte *, unsigned int);
-
static sect_offset read_abbrev_offset
(struct dwarf2_per_objfile *dwarf2_per_objfile,
struct dwarf2_section_info *, sect_offset);
-static const gdb_byte *read_n_bytes (bfd *, const gdb_byte *, unsigned int);
-
-static const char *read_direct_string (bfd *, const gdb_byte *, unsigned int *);
-
static const char *read_indirect_string
(struct dwarf2_per_objfile *dwarf2_per_objfile, bfd *, const gdb_byte *,
const struct comp_unit_head *, unsigned int *);
static const char *dwarf_attr_name (unsigned int);
-static const char *dwarf_unit_type_name (int unit_type);
-
static const char *dwarf_form_name (unsigned int);
static const char *dwarf_bool_name (unsigned int);
static file_and_directory find_file_and_directory (struct die_info *die,
struct dwarf2_cu *cu);
-/* Expected enum dwarf_unit_type for read_comp_unit_head. */
-enum class rcuh_kind { COMPILE, TYPE };
-
-static 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);
-
static htab_up allocate_signatured_type_table (struct objfile *objfile);
static htab_up allocate_dwo_unit_table (struct objfile *objfile);
this->has_section_at_zero = true;
}
-/* 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. */
-
-static bfd_size_type
-dwarf2_section_size (struct objfile *objfile,
- struct dwarf2_section_info *info)
-{
- if (!info->readin)
- info->read (objfile);
- return info->size;
-}
-
/* Fill in SECTP, BUFP and SIZEP with section info, given OBJFILE and
SECTION_NAME. */
}
}
-/* Return the total length of the CU described by HEADER. */
-
-static unsigned int
-get_cu_length (const struct comp_unit_head *header)
-{
- return header->initial_length_size + header->length;
-}
-
-/* Return TRUE if SECT_OFF is within CU_HEADER. */
-
-static inline bool
-offset_in_cu_p (const comp_unit_head *cu_header, sect_offset sect_off)
-{
- sect_offset bottom = cu_header->sect_off;
- sect_offset top = cu_header->sect_off + get_cu_length (cu_header);
-
- return sect_off >= bottom && sect_off < top;
-}
-
/* Find the base address of the compilation unit for range lists and
location lists. It will normally be specified by DW_AT_low_pc.
In DWARF-3 draft 4, the base address could be overridden by
}
}
-/* 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. */
-
-static 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)
-{
- int signed_addr;
- unsigned int bytes_read;
- const char *filename = section->get_file_name ();
- bfd *abfd = section->get_bfd_owner ();
-
- cu_header->length = read_initial_length (abfd, info_ptr, &bytes_read);
- cu_header->initial_length_size = bytes_read;
- cu_header->offset_size = (bytes_read == 4) ? 4 : 8;
- info_ptr += bytes_read;
- cu_header->version = read_2_bytes (abfd, info_ptr);
- if (cu_header->version < 2 || cu_header->version > 5)
- error (_("Dwarf Error: wrong version in compilation unit header "
- "(is %d, should be 2, 3, 4 or 5) [in module %s]"),
- cu_header->version, filename);
- info_ptr += 2;
- if (cu_header->version < 5)
- switch (section_kind)
- {
- case rcuh_kind::COMPILE:
- cu_header->unit_type = DW_UT_compile;
- break;
- case rcuh_kind::TYPE:
- cu_header->unit_type = DW_UT_type;
- break;
- default:
- internal_error (__FILE__, __LINE__,
- _("read_comp_unit_head: invalid section_kind"));
- }
- else
- {
- cu_header->unit_type = static_cast<enum dwarf_unit_type>
- (read_1_byte (abfd, info_ptr));
- info_ptr += 1;
- switch (cu_header->unit_type)
- {
- case DW_UT_compile:
- case DW_UT_partial:
- case DW_UT_skeleton:
- case DW_UT_split_compile:
- if (section_kind != rcuh_kind::COMPILE)
- error (_("Dwarf Error: wrong unit_type in compilation unit header "
- "(is %s, should be %s) [in module %s]"),
- dwarf_unit_type_name (cu_header->unit_type),
- dwarf_unit_type_name (DW_UT_type), filename);
- break;
- case DW_UT_type:
- case DW_UT_split_type:
- section_kind = rcuh_kind::TYPE;
- break;
- default:
- error (_("Dwarf Error: wrong unit_type in compilation unit header "
- "(is %#04x, should be one of: %s, %s, %s, %s or %s) "
- "[in module %s]"), cu_header->unit_type,
- dwarf_unit_type_name (DW_UT_compile),
- dwarf_unit_type_name (DW_UT_skeleton),
- dwarf_unit_type_name (DW_UT_split_compile),
- dwarf_unit_type_name (DW_UT_type),
- dwarf_unit_type_name (DW_UT_split_type), filename);
- }
-
- cu_header->addr_size = read_1_byte (abfd, info_ptr);
- info_ptr += 1;
- }
- cu_header->abbrev_sect_off = (sect_offset) read_offset (abfd, info_ptr,
- cu_header,
- &bytes_read);
- info_ptr += bytes_read;
- if (cu_header->version < 5)
- {
- cu_header->addr_size = read_1_byte (abfd, info_ptr);
- info_ptr += 1;
- }
- signed_addr = bfd_get_sign_extend_vma (abfd);
- if (signed_addr < 0)
- internal_error (__FILE__, __LINE__,
- _("read_comp_unit_head: dwarf from non elf file"));
- cu_header->signed_addr_p = signed_addr;
-
- bool header_has_signature = section_kind == rcuh_kind::TYPE
- || cu_header->unit_type == DW_UT_skeleton
- || cu_header->unit_type == DW_UT_split_compile;
-
- if (header_has_signature)
- {
- cu_header->signature = read_8_bytes (abfd, info_ptr);
- info_ptr += 8;
- }
-
- if (section_kind == rcuh_kind::TYPE)
- {
- LONGEST type_offset;
- type_offset = read_offset (abfd, info_ptr, cu_header, &bytes_read);
- info_ptr += bytes_read;
- cu_header->type_cu_offset_in_tu = (cu_offset) type_offset;
- if (to_underlying (cu_header->type_cu_offset_in_tu) != type_offset)
- error (_("Dwarf Error: Too big type_offset in compilation unit "
- "header (is %s) [in module %s]"), plongest (type_offset),
- filename);
- }
-
- return info_ptr;
-}
-
/* Helper function that returns the proper abbrev section for
THIS_CU. */
return abbrev;
}
-/* Subroutine of read_and_check_comp_unit_head and
- read_and_check_type_unit_head to simplify them.
- Perform various error checking on the header. */
-
-static void
-error_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 char *filename = section->get_file_name ();
-
- if (to_underlying (header->abbrev_sect_off)
- >= dwarf2_section_size (dwarf2_per_objfile->objfile, abbrev_section))
- error (_("Dwarf Error: bad offset (%s) in compilation unit header "
- "(offset %s + 6) [in module %s]"),
- sect_offset_str (header->abbrev_sect_off),
- sect_offset_str (header->sect_off),
- filename);
-
- /* Cast to ULONGEST to use 64-bit arithmetic when possible to
- avoid potential 32-bit overflow. */
- if (((ULONGEST) header->sect_off + get_cu_length (header))
- > section->size)
- error (_("Dwarf Error: bad length (0x%x) in compilation unit header "
- "(offset %s + 0) [in module %s]"),
- header->length, sect_offset_str (header->sect_off),
- filename);
-}
-
-/* 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. */
-
-static 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)
-{
- const gdb_byte *beg_of_comp_unit = info_ptr;
-
- header->sect_off = (sect_offset) (beg_of_comp_unit - section->buffer);
-
- info_ptr = read_comp_unit_head (header, info_ptr, section, section_kind);
-
- header->first_die_cu_offset = (cu_offset) (info_ptr - beg_of_comp_unit);
-
- error_check_comp_unit_head (dwarf2_per_objfile, header, section,
- abbrev_section);
-
- return info_ptr;
-}
-
/* Fetch the abbreviation table offset from a comp or type unit header. */
static sect_offset
info_ptr += 2;
}
- return (sect_offset) read_offset_1 (abfd, info_ptr, offset_size);
+ return (sect_offset) read_offset (abfd, info_ptr, offset_size);
}
/* Allocate a new partial symtab for file named NAME and mark this new
ptr = read_and_check_comp_unit_head (dwarf2_per_objfile, &header, section,
abbrev_section, ptr, section_kind);
- length = get_cu_length (&header);
+ length = header.get_length ();
/* Skip dummy type units. */
if (ptr >= info_ptr + length
gdb_assert (dwo_unit->sect_off == cu->header.sect_off);
/* For DWOs coming from DWP files, we don't know the CU length
nor the type's offset in the TU until now. */
- dwo_unit->length = get_cu_length (&cu->header);
+ dwo_unit->length = cu->header.get_length ();
dwo_unit->type_offset_in_tu = cu->header.type_cu_offset_in_tu;
/* Establish the type offset that can be used to lookup the type.
gdb_assert (dwo_unit->sect_off == cu->header.sect_off);
/* For DWOs coming from DWP files, we don't know the CU length
until now. */
- dwo_unit->length = get_cu_length (&cu->header);
+ dwo_unit->length = cu->header.get_length ();
}
*result_dwo_abbrev_table
/* LENGTH has not been set yet for type units if we're
using .gdb_index. */
- this_cu->length = get_cu_length (&cu->header);
+ this_cu->length = cu->header.get_length ();
/* Establish the type offset that can be used to lookup the type. */
sig_type->type_offset_in_section =
rcuh_kind::COMPILE);
gdb_assert (this_cu->sect_off == cu->header.sect_off);
- gdb_assert (this_cu->length == get_cu_length (&cu->header));
+ gdb_assert (this_cu->length == cu->header.get_length ());
this_cu->dwarf_version = cu->header.version;
}
}
m_new_cu->str_offsets_base = parent_cu->str_offsets_base;
m_new_cu->addr_base = parent_cu->addr_base;
}
- this_cu->length = get_cu_length (&m_new_cu->header);
+ this_cu->length = m_new_cu->header.get_length ();
/* Skip dummy compilation units. */
if (info_ptr >= begin_info_ptr + this_cu->length
sect_offset sect_off
= (sect_offset) dwarf2_get_ref_die_offset (origin);
- if (!offset_in_cu_p (&cu->header, sect_off))
+ if (!cu->header.offset_in_cu_p (sect_off))
{
/* As DW_OP_GNU_parameter_ref uses CU-relative offset this
binding can be done only inside one CU. Such referenced DIE
overflow = true;
break;
}
- base = read_address (obfd, buffer, cu, &bytes_read);
+ base = cu->header.read_address (obfd, buffer, &bytes_read);
found_base = 1;
buffer += bytes_read;
break;
overflow = true;
break;
}
- range_beginning = read_address (obfd, buffer, cu, &bytes_read);
+ range_beginning = cu->header.read_address (obfd, buffer,
+ &bytes_read);
buffer += bytes_read;
range_end = (range_beginning
+ read_unsigned_leb128 (obfd, buffer, &bytes_read));
overflow = true;
break;
}
- range_beginning = read_address (obfd, buffer, cu, &bytes_read);
+ range_beginning = cu->header.read_address (obfd, buffer,
+ &bytes_read);
buffer += bytes_read;
- range_end = read_address (obfd, buffer, cu, &bytes_read);
+ range_end = cu->header.read_address (obfd, buffer, &bytes_read);
buffer += bytes_read;
break;
default:
{
CORE_ADDR range_beginning, range_end;
- range_beginning = read_address (obfd, buffer, cu, &dummy);
+ range_beginning = cu->header.read_address (obfd, buffer, &dummy);
buffer += addr_size;
- range_end = read_address (obfd, buffer, cu, &dummy);
+ range_end = cu->header.read_address (obfd, buffer, &dummy);
buffer += addr_size;
offset += 2 * addr_size;
struct partial_die_info *pd = NULL;
if (offset_in_dwz == cu->per_cu->is_dwz
- && offset_in_cu_p (&cu->header, sect_off))
+ && cu->header.offset_in_cu_p (sect_off))
{
pd = cu->find_partial_die (sect_off);
if (pd != NULL)
{
case DW_FORM_ref_addr:
if (cu->header.version == 2)
- DW_UNSND (attr) = read_address (abfd, info_ptr, cu, &bytes_read);
+ DW_UNSND (attr) = cu->header.read_address (abfd, info_ptr,
+ &bytes_read);
else
- DW_UNSND (attr) = read_offset (abfd, info_ptr,
- &cu->header, &bytes_read);
+ DW_UNSND (attr) = cu->header.read_offset (abfd, info_ptr,
+ &bytes_read);
info_ptr += bytes_read;
break;
case DW_FORM_GNU_ref_alt:
- DW_UNSND (attr) = read_offset (abfd, info_ptr, &cu->header, &bytes_read);
+ DW_UNSND (attr) = cu->header.read_offset (abfd, info_ptr, &bytes_read);
info_ptr += bytes_read;
break;
case DW_FORM_addr:
- DW_ADDR (attr) = read_address (abfd, info_ptr, cu, &bytes_read);
+ DW_ADDR (attr) = cu->header.read_address (abfd, info_ptr, &bytes_read);
DW_ADDR (attr) = gdbarch_adjust_dwarf2_addr (gdbarch, DW_ADDR (attr));
info_ptr += bytes_read;
break;
DW_BLOCK (attr) = blk;
break;
case DW_FORM_sec_offset:
- DW_UNSND (attr) = read_offset (abfd, info_ptr, &cu->header, &bytes_read);
+ DW_UNSND (attr) = cu->header.read_offset (abfd, info_ptr, &bytes_read);
info_ptr += bytes_read;
break;
case DW_FORM_string:
case DW_FORM_GNU_strp_alt:
{
struct dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile);
- LONGEST str_offset = read_offset (abfd, info_ptr, cu_header,
- &bytes_read);
+ LONGEST str_offset = cu_header->read_offset (abfd, info_ptr,
+ &bytes_read);
DW_STRING (attr) = read_indirect_string_from_dwz (objfile,
dwz, str_offset);
need_reprocess);
}
-static CORE_ADDR
-read_address (bfd *abfd, const gdb_byte *buf, struct dwarf2_cu *cu,
- unsigned int *bytes_read)
-{
- struct comp_unit_head *cu_header = &cu->header;
- CORE_ADDR retval = 0;
-
- if (cu_header->signed_addr_p)
- {
- switch (cu_header->addr_size)
- {
- case 2:
- retval = bfd_get_signed_16 (abfd, buf);
- break;
- case 4:
- retval = bfd_get_signed_32 (abfd, buf);
- break;
- case 8:
- retval = bfd_get_signed_64 (abfd, buf);
- break;
- default:
- internal_error (__FILE__, __LINE__,
- _("read_address: bad switch, signed [in module %s]"),
- bfd_get_filename (abfd));
- }
- }
- else
- {
- switch (cu_header->addr_size)
- {
- case 2:
- retval = bfd_get_16 (abfd, buf);
- break;
- case 4:
- retval = bfd_get_32 (abfd, buf);
- break;
- case 8:
- retval = bfd_get_64 (abfd, buf);
- break;
- default:
- internal_error (__FILE__, __LINE__,
- _("read_address: bad switch, "
- "unsigned [in module %s]"),
- bfd_get_filename (abfd));
- }
- }
-
- *bytes_read = cu_header->addr_size;
- return retval;
-}
-
-/* Read the initial length from a section. The (draft) DWARF 3
- specification allows the initial length to take up either 4 bytes
- or 12 bytes. If the first 4 bytes are 0xffffffff, then the next 8
- bytes describe the length and all offsets will be 8 bytes in length
- instead of 4.
-
- An older, non-standard 64-bit format is also handled by this
- function. The older format in question stores the initial length
- as an 8-byte quantity without an escape value. Lengths greater
- than 2^32 aren't very common which means that the initial 4 bytes
- is almost always zero. Since a length value of zero doesn't make
- sense for the 32-bit format, this initial zero can be considered to
- be an escape value which indicates the presence of the older 64-bit
- format. As written, the code can't detect (old format) lengths
- greater than 4GB. If it becomes necessary to handle lengths
- somewhat larger than 4GB, we could allow other small values (such
- as the non-sensical values of 1, 2, and 3) to also be used as
- escape values indicating the presence of the old format.
-
- The value returned via bytes_read should be used to increment the
- relevant pointer after calling read_initial_length().
-
- [ Note: read_initial_length() and read_offset() are based on the
- document entitled "DWARF Debugging Information Format", revision
- 3, draft 8, dated November 19, 2001. This document was obtained
- from:
-
- http://reality.sgiweb.org/davea/dwarf3-draft8-011125.pdf
-
- This document is only a draft and is subject to change. (So beware.)
-
- Details regarding the older, non-standard 64-bit format were
- determined empirically by examining 64-bit ELF files produced by
- the SGI toolchain on an IRIX 6.5 machine.
-
- - Kevin, July 16, 2002
- ] */
-
-static LONGEST
-read_initial_length (bfd *abfd, const gdb_byte *buf, unsigned int *bytes_read)
-{
- LONGEST length = bfd_get_32 (abfd, buf);
-
- if (length == 0xffffffff)
- {
- length = bfd_get_64 (abfd, buf + 4);
- *bytes_read = 12;
- }
- else if (length == 0)
- {
- /* Handle the (non-standard) 64-bit DWARF2 format used by IRIX. */
- length = bfd_get_64 (abfd, buf);
- *bytes_read = 8;
- }
- else
- {
- *bytes_read = 4;
- }
-
- return length;
-}
-
/* Cover function for read_initial_length.
Returns the length of the object at BUF, and stores the size of the
initial length in *BYTES_READ and stores the size that offsets will be in
return length;
}
-/* Read an offset from the data stream. The size of the offset is
- given by cu_header->offset_size. */
-
-static LONGEST
-read_offset (bfd *abfd, const gdb_byte *buf,
- const struct comp_unit_head *cu_header,
- unsigned int *bytes_read)
-{
- LONGEST offset = read_offset_1 (abfd, buf, cu_header->offset_size);
-
- *bytes_read = cu_header->offset_size;
- return offset;
-}
-
-/* Read an offset from the data stream. */
-
-static LONGEST
-read_offset_1 (bfd *abfd, const gdb_byte *buf, unsigned int offset_size)
-{
- LONGEST retval = 0;
-
- switch (offset_size)
- {
- case 4:
- retval = bfd_get_32 (abfd, buf);
- break;
- case 8:
- retval = bfd_get_64 (abfd, buf);
- break;
- default:
- internal_error (__FILE__, __LINE__,
- _("read_offset_1: bad switch [in module %s]"),
- bfd_get_filename (abfd));
- }
-
- return retval;
-}
-
-static const gdb_byte *
-read_n_bytes (bfd *abfd, const gdb_byte *buf, unsigned int size)
-{
- /* If the size of a host char is 8 bits, we can return a pointer
- to the buffer, otherwise we have to copy the data to a buffer
- allocated on the temporary obstack. */
- gdb_assert (HOST_CHAR_BIT == 8);
- return buf;
-}
-
-static const char *
-read_direct_string (bfd *abfd, const gdb_byte *buf,
- unsigned int *bytes_read_ptr)
-{
- /* If the size of a host char is 8 bits, we can return a pointer
- to the string, otherwise we have to copy the string to a buffer
- allocated on the temporary obstack. */
- gdb_assert (HOST_CHAR_BIT == 8);
- if (*buf == '\0')
- {
- *bytes_read_ptr = 1;
- return NULL;
- }
- *bytes_read_ptr = strlen ((const char *) buf) + 1;
- return (const char *) buf;
-}
-
/* Return pointer to string at section SECT offset STR_OFFSET with error
reporting strings FORM_NAME and SECT_NAME. */
const struct comp_unit_head *cu_header,
unsigned int *bytes_read_ptr)
{
- LONGEST str_offset = read_offset (abfd, buf, cu_header, bytes_read_ptr);
+ LONGEST str_offset = cu_header->read_offset (abfd, buf, bytes_read_ptr);
return read_indirect_string_at_offset (dwarf2_per_objfile, abfd, str_offset);
}
const struct comp_unit_head *cu_header,
unsigned int *bytes_read_ptr)
{
- LONGEST str_offset = read_offset (abfd, buf, cu_header, bytes_read_ptr);
+ LONGEST str_offset = cu_header->read_offset (abfd, buf, bytes_read_ptr);
return read_indirect_line_string_at_offset (dwarf2_per_objfile, abfd,
str_offset);
return NULL;
}
}
- lh->header_length = read_offset_1 (abfd, line_ptr, offset_size);
+ lh->header_length = read_offset (abfd, line_ptr, offset_size);
line_ptr += offset_size;
lh->statement_program_start = line_ptr + lh->header_length;
lh->minimum_instruction_length = read_1_byte (abfd, line_ptr);
case DW_LNE_set_address:
{
CORE_ADDR address
- = read_address (abfd, line_ptr, cu, &bytes_read);
+ = cu->header.read_address (abfd, line_ptr, &bytes_read);
line_ptr += bytes_read;
state_machine.check_line_address (cu, line_ptr,
unsigned int dummy;
if (DW_BLOCK (attr)->data[0] == DW_OP_addr)
- SET_SYMBOL_VALUE_ADDRESS (sym,
- read_address (objfile->obfd,
- DW_BLOCK (attr)->data + 1,
- cu, &dummy));
+ SET_SYMBOL_VALUE_ADDRESS
+ (sym, cu->header.read_address (objfile->obfd,
+ DW_BLOCK (attr)->data + 1,
+ &dummy));
else
SET_SYMBOL_VALUE_ADDRESS
(sym, read_addr_index_from_leb128 (cu, DW_BLOCK (attr)->data + 1,
return name;
}
-/* Convert a unit type to corresponding DW_UT name. */
-
-static const char *
-dwarf_unit_type_name (int unit_type) {
- switch (unit_type)
- {
- case 0x01:
- return "DW_UT_compile (0x01)";
- case 0x02:
- return "DW_UT_type (0x02)";
- case 0x03:
- return "DW_UT_partial (0x03)";
- case 0x04:
- return "DW_UT_skeleton (0x04)";
- case 0x05:
- return "DW_UT_split_compile (0x05)";
- case 0x06:
- return "DW_UT_split_type (0x06)";
- case 0x80:
- return "DW_UT_lo_user (0x80)";
- case 0xff:
- return "DW_UT_hi_user (0xff)";
- default:
- return nullptr;
- }
-}
-
/* Convert a DWARF value form code into its string name. */
static const char *
/* .debug_types CUs cannot reference anything outside their CU.
If they need to, they have to reference a signatured type via
DW_FORM_ref_sig8. */
- if (!offset_in_cu_p (&cu->header, sect_off))
+ if (!cu->header.offset_in_cu_p (sect_off))
return NULL;
}
else if (offset_in_dwz != cu->per_cu->is_dwz
- || !offset_in_cu_p (&cu->header, sect_off))
+ || !cu->header.offset_in_cu_p (sect_off))
{
struct dwarf2_per_cu_data *per_cu;
break;
case DW_OP_addr:
- stack[++stacki] = read_address (objfile->obfd, &data[i],
- cu, &bytes_read);
+ stack[++stacki] = cu->header.read_address (objfile->obfd, &data[i],
+ &bytes_read);
i += bytes_read;
break;
{
LONGEST str_offset;
- str_offset = read_offset_1 (abfd, mac_ptr, offset_size);
+ str_offset = read_offset (abfd, mac_ptr, offset_size);
mac_ptr += offset_size;
if (macinfo_type == DW_MACRO_define_sup
int is_dwz = section_is_dwz;
const gdb_byte *new_mac_ptr;
- offset = read_offset_1 (abfd, mac_ptr, offset_size);
+ offset = read_offset (abfd, mac_ptr, offset_size);
mac_ptr += offset_size;
if (macinfo_type == DW_MACRO_import_sup)
/* .debug_loc{,.dwo} may not exist at all, or the offset may be outside
the section. If so, fall through to the complaint in the
other branch. */
- && DW_UNSND (attr) < dwarf2_section_size (objfile, section))
+ && DW_UNSND (attr) < section->get_size (objfile))
{
struct dwarf2_loclist_baton *baton;