This changes one of the read_offset overloads to be a method on
comp_unit_head.
2020-02-08 Tom Tromey <
[email protected]>
* dwarf2/read.c (read_attribute_value, read_indirect_string)
(read_indirect_line_string): Update.
* dwarf2/comp-unit.c (read_offset): Remove.
(read_comp_unit_head): Update.
* dwarf2/comp-unit.h (struct comp_unit_head) <read_offset>: New
method.
(read_offset): Don't declare.
Change-Id: Ia595702a5748337b7c031352bc437956baab9990
+
+ * dwarf2/read.c (read_attribute_value, read_indirect_string)
+ (read_indirect_line_string): Update.
+ * dwarf2/comp-unit.c (read_offset): Remove.
+ (read_comp_unit_head): Update.
+ * dwarf2/comp-unit.h (struct comp_unit_head) <read_offset>: New
+ method.
+ (read_offset): Don't declare.
+
* Makefile.in (COMMON_SFILES): Add dwarf2/comp-unit.c.
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);
+ cu_header->abbrev_sect_off
+ = (sect_offset) cu_header->read_offset (abfd, info_ptr, &bytes_read);
info_ptr += bytes_read;
if (cu_header->version < 5)
{
if (section_kind == rcuh_kind::TYPE)
{
LONGEST type_offset;
- type_offset = read_offset (abfd, info_ptr, cu_header, &bytes_read);
+ type_offset = cu_header->read_offset (abfd, info_ptr, &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)
return info_ptr;
}
-
-/* See comp-unit.h. */
-
-LONGEST
-read_offset (bfd *abfd, const gdb_byte *buf,
- const struct comp_unit_head *cu_header,
- unsigned int *bytes_read)
-{
- LONGEST offset = read_offset (abfd, buf, cu_header->offset_size);
-
- *bytes_read = cu_header->offset_size;
- return offset;
-}
#ifndef GDB_DWARF2_COMP_UNIT_H
#define GDB_DWARF2_COMP_UNIT_H
+#include "dwarf2/leb.h"
#include "gdbtypes.h"
/* The data in a compilation unit header, after target2host
sect_offset top = sect_off + get_length ();
return off >= bottom && off < top;
}
+
+ /* Read an offset from the data stream. The size of the offset is
+ given by cu_header->offset_size. */
+ LONGEST read_offset (bfd *abfd, const gdb_byte *buf,
+ unsigned int *bytes_read) const
+ {
+ LONGEST offset = ::read_offset (abfd, buf, offset_size);
+ *bytes_read = offset_size;
+ return offset;
+ }
};
/* Expected enum dwarf_unit_type for read_comp_unit_head. */
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 */
if (cu->header.version == 2)
DW_UNSND (attr) = read_address (abfd, info_ptr, cu, &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_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);
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);