diff options
author | Tom Tromey <tom@tromey.com> | 2020-03-26 09:28:08 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2020-03-26 09:28:14 -0600 |
commit | 4f44ae6c69b839712a33a46aaa62d58d2b16b4ca (patch) | |
tree | 1f72cc9e602841300aa6cd37cc234dda8602b1cb /gdb/dwarf2/section.c | |
parent | a0194fa8f23c64bef0f4b4bb4a76e9c64f003169 (diff) | |
download | binutils-4f44ae6c69b839712a33a46aaa62d58d2b16b4ca.zip binutils-4f44ae6c69b839712a33a46aaa62d58d2b16b4ca.tar.gz binutils-4f44ae6c69b839712a33a46aaa62d58d2b16b4ca.tar.bz2 |
Add dwarf2_section_info::read_string method
This moves a string-reading function to be a method on
dwarf2_section_info, and then updates the users.
gdb/ChangeLog
2020-03-26 Tom Tromey <tom@tromey.com>
* dwarf2/section.h (struct dwarf2_section_info) <read_string>: New
method.
* dwarf2/section.c: New method. From
read_indirect_string_at_offset_from.
* dwarf2/read.c (mapped_debug_names::namei_to_name): Update.
(read_indirect_string_at_offset_from): Move to section.c.
(read_indirect_string_at_offset): Rewrite.
(read_indirect_line_string_at_offset): Remove.
(read_indirect_string, read_indirect_line_string)
(dwarf_decode_macro_bytes): Update.
Diffstat (limited to 'gdb/dwarf2/section.c')
-rw-r--r-- | gdb/dwarf2/section.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gdb/dwarf2/section.c b/gdb/dwarf2/section.c index 9714368..7766179 100644 --- a/gdb/dwarf2/section.c +++ b/gdb/dwarf2/section.c @@ -187,3 +187,20 @@ dwarf2_section_info::read (struct objfile *objfile) bfd_section_name (sectp), bfd_get_filename (abfd)); } } + +const char * +dwarf2_section_info::read_string (struct objfile *objfile, LONGEST str_offset, + const char *form_name) +{ + read (objfile); + if (buffer == NULL) + error (_("%s used without %s section [in module %s]"), + form_name, get_name (), get_file_name ()); + if (str_offset >= size) + error (_("%s pointing outside of %s section [in module %s]"), + form_name, get_name (), get_file_name ()); + gdb_assert (HOST_CHAR_BIT == 8); + if (buffer[str_offset] == '\0') + return NULL; + return (const char *) (buffer + str_offset); +} |