diff options
author | Ian Lance Taylor <iant@golang.org> | 2019-12-05 02:20:11 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-12-05 02:20:11 +0000 |
commit | 66ab583969c8fe833723703870a061b362de77fa (patch) | |
tree | b56c972c897f04194bf100b70bf0a40a31e53468 /libbacktrace/pecoff.c | |
parent | 268209f3a0dc07fcf13534610447ab732742eb2f (diff) | |
download | gcc-66ab583969c8fe833723703870a061b362de77fa.zip gcc-66ab583969c8fe833723703870a061b362de77fa.tar.gz gcc-66ab583969c8fe833723703870a061b362de77fa.tar.bz2 |
libbacktrace: simplify DWARF section handling
This is in preparation for adding DWARF 5 support.
* internal.h (enum dwarf_section): Define.
(struct dwarf_sections): Define.
(backtrace_dwarf_add): Update declaration to replace specific
section parameters with dwarf_sections parameter.
* dwarf.c (struct dwarf_data): Replace specific section fields
with dwarf_sections field.
(read_attribute): Use dwarf_sections with altlink.
(build_address_map): Replace specific section parameters with
dwarf_sections parameter. Change all callers.
(read_line_info): Use dwarf_sections with ddata.
(read_referenced_name): Likewise.
(add_function_ranges): Likewise.
(read_function_entry): Likewise.
(read_function_info): Likewise.
(build_dwarf_data): Replace specific section parameters with
dwarf_sections parameter. Change all callers.
(backtrace_dwarf_add): Likewise.
* elf.c (enum debug_section): Remove.
(dwarf_section_names): Remove .zdebug names.
(elf_add): Track zsections separately. Build dwarf_sections.
* pecoff.c (enum debug_section): Remove.
(struct debug_section_info): Remove data field.
(coff_add): Build dwarf_sections.
* xcoff.c (enum dwarf_section): Remove. Replace DWSECT_xxx
references with DEBUG_xxx references.
(xcoff_add): Build dwarf_sections.
From-SVN: r278984
Diffstat (limited to 'libbacktrace/pecoff.c')
-rw-r--r-- | libbacktrace/pecoff.c | 45 |
1 files changed, 12 insertions, 33 deletions
diff --git a/libbacktrace/pecoff.c b/libbacktrace/pecoff.c index fcf9508..fe64a7e 100644 --- a/libbacktrace/pecoff.c +++ b/libbacktrace/pecoff.c @@ -133,19 +133,7 @@ typedef struct { uint16_t sc; } b_coff_internal_symbol; -/* An index of sections we care about. */ - -enum debug_section -{ - DEBUG_INFO, - DEBUG_LINE, - DEBUG_ABBREV, - DEBUG_RANGES, - DEBUG_STR, - DEBUG_MAX -}; - -/* Names of sections, indexed by enum debug_section. */ +/* Names of sections, indexed by enum dwarf_section in internal.h. */ static const char * const debug_section_names[DEBUG_MAX] = { @@ -164,8 +152,6 @@ struct debug_section_info off_t offset; /* Section size. */ size_t size; - /* Section contents, after read from file. */ - const unsigned char *data; }; /* Information we keep for an coff symbol. */ @@ -616,6 +602,7 @@ coff_add (struct backtrace_state *state, int descriptor, struct backtrace_view debug_view; int debug_view_valid; uintptr_t image_base; + struct dwarf_sections dwarf_sections; *found_sym = 0; *found_dwarf = 0; @@ -848,28 +835,20 @@ coff_add (struct backtrace_state *state, int descriptor, for (i = 0; i < (int) DEBUG_MAX; ++i) { - if (sections[i].size == 0) - sections[i].data = NULL; + size_t size = sections[i].size; + dwarf_sections.size[i] = size; + if (size == 0) + dwarf_sections.data[i] = NULL; else - sections[i].data = ((const unsigned char *) debug_view.data - + (sections[i].offset - min_offset)); + dwarf_sections.data[i] = ((const unsigned char *) debug_view.data + + (sections[i].offset - min_offset)); } - if (!backtrace_dwarf_add (state, /* base_address */ 0, - sections[DEBUG_INFO].data, - sections[DEBUG_INFO].size, - sections[DEBUG_LINE].data, - sections[DEBUG_LINE].size, - sections[DEBUG_ABBREV].data, - sections[DEBUG_ABBREV].size, - sections[DEBUG_RANGES].data, - sections[DEBUG_RANGES].size, - sections[DEBUG_STR].data, - sections[DEBUG_STR].size, - 0, /* FIXME */ - NULL, + if (!backtrace_dwarf_add (state, /* base_address */ 0, &dwarf_sections, + 0, /* FIXME: is_bigendian */ + NULL, /* altlink */ error_callback, data, fileline_fn, - NULL)) + NULL /* returned fileline_entry */)) goto fail; *found_dwarf = 1; |