aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog8
-rw-r--r--gdb/dwarf2/leb.c24
-rw-r--r--gdb/dwarf2/leb.h4
-rw-r--r--gdb/dwarf2/read.c36
4 files changed, 41 insertions, 31 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 10c8bf5..519225f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
2020-02-08 Tom Tromey <tom@tromey.com>
+ * dwarf2/read.c (read_offset_1): Move to leb.c.
+ (read_abbrev_offset, read_offset, dwarf_decode_line_header)
+ (dwarf_decode_macro_bytes): Update.
+ * dwarf2/leb.c (read_offset): Rename; move from read.c.
+ * dwarf2/leb.h (read_offset): Declare.
+
+2020-02-08 Tom Tromey <tom@tromey.com>
+
* dwarf2/read.c (dwarf2_section_size): Remove.
(error_check_comp_unit_head, dwarf2_symbol_mark_computed):
Update.
diff --git a/gdb/dwarf2/leb.c b/gdb/dwarf2/leb.c
index ef7314e..02faaa9 100644
--- a/gdb/dwarf2/leb.c
+++ b/gdb/dwarf2/leb.c
@@ -110,3 +110,27 @@ read_initial_length (bfd *abfd, const gdb_byte *buf, unsigned int *bytes_read,
return length;
}
+
+/* See leb.h. */
+
+LONGEST
+read_offset (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;
+}
diff --git a/gdb/dwarf2/leb.h b/gdb/dwarf2/leb.h
index 29fdffe..9c30cbe 100644
--- a/gdb/dwarf2/leb.h
+++ b/gdb/dwarf2/leb.h
@@ -130,4 +130,8 @@ extern LONGEST read_initial_length (bfd *abfd, const gdb_byte *buf,
unsigned int *bytes_read,
bool handle_nonstd = true);
+/* Read an offset from the data stream. */
+extern LONGEST read_offset (bfd *abfd, const gdb_byte *buf,
+ unsigned int offset_size);
+
#endif /* GDB_DWARF2_LEB_H */
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 2ba53a1..f291d8f 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1285,8 +1285,6 @@ 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);
@@ -6145,7 +6143,7 @@ read_abbrev_offset (struct dwarf2_per_objfile *dwarf2_per_objfile,
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
@@ -19033,36 +19031,12 @@ 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);
+ LONGEST offset = read_offset (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)
{
@@ -19847,7 +19821,7 @@ dwarf_decode_line_header (sect_offset sect_off, struct dwarf2_cu *cu)
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);
@@ -23922,7 +23896,7 @@ dwarf_decode_macro_bytes (struct dwarf2_cu *cu,
{
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
@@ -24062,7 +24036,7 @@ dwarf_decode_macro_bytes (struct dwarf2_cu *cu,
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)