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/xcoff.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/xcoff.c')
-rw-r--r-- | libbacktrace/xcoff.c | 60 |
1 files changed, 25 insertions, 35 deletions
diff --git a/libbacktrace/xcoff.c b/libbacktrace/xcoff.c index bc60962..468b24c 100644 --- a/libbacktrace/xcoff.c +++ b/libbacktrace/xcoff.c @@ -387,18 +387,6 @@ struct xcoff_fileline_data uintptr_t base_address; }; -/* An index of DWARF sections we care about. */ - -enum dwarf_section -{ - DWSECT_INFO, - DWSECT_LINE, - DWSECT_ABBREV, - DWSECT_RANGES, - DWSECT_STR, - DWSECT_MAX -}; - /* Information we gather for the DWARF sections we care about. */ struct dwsect_info @@ -1100,7 +1088,7 @@ xcoff_add (struct backtrace_state *state, int descriptor, off_t offset, off_t str_off; off_t min_offset; off_t max_offset; - struct dwsect_info dwsect[DWSECT_MAX]; + struct dwsect_info dwsect[DEBUG_MAX]; size_t sects_size; size_t syms_size; int32_t str_size; @@ -1111,6 +1099,7 @@ xcoff_add (struct backtrace_state *state, int descriptor, off_t offset, int dwarf_view_valid; int magic_ok; int i; + struct dwarf_sections dwarf_sections; *found_sym = 0; @@ -1255,19 +1244,19 @@ xcoff_add (struct backtrace_state *state, int descriptor, off_t offset, switch (sects[i].s_flags & 0xffff0000) { case SSUBTYP_DWINFO: - idx = DWSECT_INFO; + idx = DEBUG_INFO; break; case SSUBTYP_DWLINE: - idx = DWSECT_LINE; + idx = DEBUG_LINE; break; case SSUBTYP_DWABREV: - idx = DWSECT_ABBREV; + idx = DEBUG_ABBREV; break; case SSUBTYP_DWARNGE: - idx = DWSECT_RANGES; + idx = DEBUG_RANGES; break; case SSUBTYP_DWSTR: - idx = DWSECT_STR; + idx = DEBUG_STR; break; default: continue; @@ -1288,7 +1277,7 @@ xcoff_add (struct backtrace_state *state, int descriptor, off_t offset, goto fail; dwarf_view_valid = 1; - for (i = 0; i < (int) DWSECT_MAX; ++i) + for (i = 0; i < (int) DEBUG_MAX; ++i) { if (dwsect[i].offset == 0) dwsect[i].data = NULL; @@ -1297,27 +1286,28 @@ xcoff_add (struct backtrace_state *state, int descriptor, off_t offset, + (dwsect[i].offset - min_offset)); } - if (!backtrace_dwarf_add (state, 0, - dwsect[DWSECT_INFO].data, - dwsect[DWSECT_INFO].size, + dwarf_sections.data[DEBUG_INFO] = dwsect[DEBUG_INFO].data; + dwarf_sections.size[DEBUG_INFO] = dwsect[DEBUG_INFO].size; #if BACKTRACE_XCOFF_SIZE == 32 - /* XXX workaround for broken lineoff */ - dwsect[DWSECT_LINE].data - 4, + /* XXX workaround for broken lineoff */ + dwarf_sections.data[DEBUG_LINE] = dwsect[DEBUG_LINE].data - 4; #else - /* XXX workaround for broken lineoff */ - dwsect[DWSECT_LINE].data - 12, + /* XXX workaround for broken lineoff */ + dwarf_sections.data[DEBUG_LINE] = dwsect[DEBUG_LINE].data - 12; #endif - dwsect[DWSECT_LINE].size, - dwsect[DWSECT_ABBREV].data, - dwsect[DWSECT_ABBREV].size, - dwsect[DWSECT_RANGES].data, - dwsect[DWSECT_RANGES].size, - dwsect[DWSECT_STR].data, - dwsect[DWSECT_STR].size, + dwarf_sections.size[DEBUG_LINE] = dwsect[DEBUG_LINE].size; + dwarf_sections.data[DEBUG_ABBREV] = dwsect[DEBUG_ABBREV].data; + dwarf_sections.size[DEBUG_ABBREV] = dwsect[DEBUG_ABBREV].size; + dwarf_sections.data[DEBUG_RANGES] = dwsect[DEBUG_RANGES].data; + dwarf_sections.size[DEBUG_RANGES] = dwsect[DEBUG_RANGES].size; + dwarf_sections.data[DEBUG_STR] = dwsect[DEBUG_STR].data; + dwarf_sections.size[DEBUG_STR] = dwsect[DEBUG_STR].size; + + if (!backtrace_dwarf_add (state, 0, &dwarf_sections, 1, /* big endian */ - NULL, + NULL, /* altlink */ error_callback, data, fileline_fn, - NULL)) + NULL /* returned fileline_entry */)) goto fail; } |