Commit Graph

63 Commits

Author SHA1 Message Date
Ian Lance Taylor
509f74a2fb libbacktrace: initialize DWARF 5 fields of unit
When I added the fields in 2019-12-13 I forgot to initialize them.

	* dwarf.c (build_address_map): Initialize DWARF 5 fields of unit.
2022-02-16 11:42:40 -08:00
Ian Lance Taylor
c062afc28c configury: support --disable-werror 2022-02-16 11:41:40 -08:00
Ian Lance Taylor
332522e199 configury: update to recent versions
Copied from GCC tip.

Fixes #84
2022-01-18 20:10:43 -08:00
Ian Lance Taylor
d0f5e95a87 config/override.m4: don't require exactly autoconf 2.69
Fixes #71
Fixes #74
2021-05-29 14:17:08 -07:00
Ian Lance Taylor
4f57c99971 libbacktrace: don't special case file 0
It's no longer necessary as file 0 is now set up in all cases.

	* dwarf.c (read_line_program): Don't special case file 0.
	(read_function_entry): Likewise.

Fixes #69
2021-03-02 18:17:36 -08:00
Ian Lance Taylor
59473f7906 libbacktrace: pass -1 to error callback for unrecognized DWARF
PR libbacktrace/98818
	* dwarf.c (dwarf_buf_error): Add errnum parameter.  Change all
	callers.
	* backtrace.h: Update backtrace_error_callback comment.
2021-03-02 13:49:18 -08:00
Ian Lance Taylor
7854b0bc25 libbacktrace: check for objcopy --add-gnu-debuglink using --help
* configure.ac: Check for objcopy --add-gnu-debuglink by using
	objcopy --help.
	* configure: Regenerate
2021-02-11 18:11:18 -08:00
Ian Lance Taylor
dedbe13fda libbacktrace: don't fail tests if dwz fails
* Makefile.am (%_dwz): If dwz fails, use uncompressed debug info.
	* Makefile.in: Regenerate.
2021-01-18 14:58:41 -08:00
Ian Lance Taylor
096650403a libbacktrace: use correct directory/filename for DWARF 5
PR debug/98716
	* dwarf.c (read_v2_paths): Allocate zero entry for dirs and
	filenames.
	(read_line_program): Remove parameter u, change caller.  Don't
	subtract one from dirs and filenames index.
	(read_function_entry): Don't subtract one from filenames index.
2021-01-18 14:57:11 -08:00
Jakub Jelinek
5496ee0a1a Update copyright years. 2021-01-18 14:56:19 -08:00
Ian Lance Taylor
1da441c1b0 libbacktrace: correct buffer overflow tests
* dwarf.c (resolve_string): Use > rather than >= to check whether
	string index extends past buffer.
	(resolve_addr_index): Similarly for address index.
2020-12-04 11:19:55 -08:00
Ian Lance Taylor
f24e9f401f libbacktrace: update README 2020-10-26 13:45:23 -07:00
Ian Lance Taylor
73eb1803b1 libbacktrace: use __attribute__((__fallthrough__))
Use an attribute rather than a comment when falling through a switch case.

	* internal.h (ATTRIBUTE_FALLTHROUGH): Define.
	* elf.c (elf_zlib_inflate): Use ATTRIBUTE_FALLTHROUGH.
2020-10-20 11:50:23 -07:00
Ian Lance Taylor
5009c11398 libbacktrace: replace Tom Sawyer with Opticks
The main source uses Opticks now.
2020-09-30 20:08:56 -07:00
Ian Lance Taylor
3bd25ab355 libbacktrace/ChangeLog:
PR libbacktrace/97082
        * Makefile.am (check_DATA): Add mtest.dSYM if USE_DSYMUTIL.
        * Makefile.in: Regenerate.
2020-09-28 13:57:18 -07:00
Ian Lance Taylor
1286f69fde libbacktrace: only run dsymutil with Mach-O
libbacktrace/ChangeLog:
	PR libbacktrace/97227
	* configure.ac (USE_DSYMUTIL): Define instead of HAVE_DSYMUTIL.
	* Makefile.am: Change all uses of HAVE_DSYMUTIL to USE_DSYMUTIL.
	* configure: Regenerate.
	* Makefile.in: Regenerate.
2020-09-28 13:50:34 -07:00
Ian Lance Taylor
95e8e96c86 libbacktrace: handle pc == low correctly
* dwarf.c (report_inlined_functions): Handle PC == -1 and PC ==
	p->low.
	(dwarf_lookup_pc): Likewise.
2020-09-27 17:30:21 -07:00
Ian Lance Taylor
c8a81d4e3a libbacktrace: use ELF symbol table if no debug info available
PR libbacktrace/97080
	* fileline.c (backtrace_syminfo_to_full_callback): New function.
	(backtrace_syminfo_to_full_error_callback): New function.
	* elf.c (elf_nodebug): Call syminfo_fn if possible.
	* internal.h (struct backtrace_call_full): Define.
	(backtrace_syminfo_to_full_callback): Declare.
	(backtrace_syminfo_to_full_error_callback): Declare.
	* mtest.c (f3): Only check all[i] if data.index permits.
2020-09-27 17:29:53 -07:00
Iain Sandoe
753968c2e8 libbacktrace, Mach-O : Support PowerPC archs.
This adds the PPC architecture variants for Mach-O libbacktrace.

With this (as for X86 and Arm) when dsymutil is run on the binary
we get a basic usable backtrace.

Testsuite results on powerpc-apple-darwin9 are the same as for X86:
 * btest fails (TBC why)
 * dwarf5 tests fail because dsymutil does not handle that so far.

libbacktrace/ChangeLog:

	* macho.c (MACH_O_CPU_TYPE_PPC): New.
	(MACH_O_CPU_TYPE_PPC64): New.
	Add compile-tests for powerpc to the Mach-O variants.

Close #55
2020-09-27 17:29:21 -07:00
Ian Lance Taylor
77bcaa99f5 libbacktrace: support MiniDebugInfo
libbacktrace/ChangeLog:
	PR libbacktrace/93608
	Add support for MiniDebugInfo.
	* elf.c (struct elf_view): Define.  Replace most uses of
	backtrace_view with elf_view.
	(elf_get_view): New static functions.  Replace most calls of
	backtrace_get_view with elf_get_view.
	(elf_release_view): New static functions.  Replace most calls of
	backtrace_release_view with elf_release_view.
	(elf_uncompress_failed): Rename from elf_zlib_failed.  Change all
	callers.
	(LZMA_STATES, LZMA_POS_STATES, LZMA_DIST_STATES): Define.
	(LZMA_DIST_SLOTS, LZMA_DIST_MODEL_START): Define.
	(LZMA_DIST_MODEL_END, LZMA_FULL_DISTANCES): Define.
	(LZMA_ALIGN_SIZE, LZMA_LEN_LOW_SYMBOLS): Define.
	(LZMA_LEN_MID_SYMBOLS, LZMA_LEN_HIGH_SYMBOLS): Define.
	(LZMA_LITERAL_CODERS_MAX, LZMA_LITERAL_CODER_SIZE): Define.
	(LZMA_PROB_IS_MATCH_LEN, LZMA_PROB_IS_REP_LEN): Define.
	(LZMA_PROB_IS_REP0_LEN, LZMA_PROB_IS_REP1_LEN): Define.
	(LZMA_PROB_IS_REP2_LEN, LZMA_PROB_IS_REP0_LONG_LEN): Define.
	(LZMA_PROB_DIST_SLOT_LEN, LZMA_PROB_DIST_SPECIAL_LEN): Define.
	(LZMA_PROB_DIST_ALIGN_LEN): Define.
	(LZMA_PROB_MATCH_LEN_CHOICE_LEN): Define.
	(LZMA_PROB_MATCH_LEN_CHOICE2_LEN): Define.
	(LZMA_PROB_MATCH_LEN_LOW_LEN): Define.
	(LZMA_PROB_MATCH_LEN_MID_LEN): Define.
	(LZMA_PROB_MATCH_LEN_HIGH_LEN): Define.
	(LZMA_PROB_REP_LEN_CHOICE_LEN): Define.
	(LZMA_PROB_REP_LEN_CHOICE2_LEN): Define.
	(LZMA_PROB_REP_LEN_LOW_LEN): Define.
	(LZMA_PROB_REP_LEN_MID_LEN): Define.
	(LZMA_PROB_REP_LEN_HIGH_LEN): Define.
	(LZMA_PROB_LITERAL_LEN): Define.
	(LZMA_PROB_IS_MATCH_OFFSET, LZMA_PROB_IS_REP_OFFSET): Define.
	(LZMA_PROB_IS_REP0_OFFSET, LZMA_PROB_IS_REP1_OFFSET): Define.
	(LZMA_PROB_IS_REP2_OFFSET): Define.
	(LZMA_PROB_IS_REP0_LONG_OFFSET): Define.
	(LZMA_PROB_DIST_SLOT_OFFSET): Define.
	(LZMA_PROB_DIST_SPECIAL_OFFSET): Define.
	(LZMA_PROB_DIST_ALIGN_OFFSET): Define.
	(LZMA_PROB_MATCH_LEN_CHOICE_OFFSET): Define.
	(LZMA_PROB_MATCH_LEN_CHOICE2_OFFSET): Define.
	(LZMA_PROB_MATCH_LEN_LOW_OFFSET): Define.
	(LZMA_PROB_MATCH_LEN_MID_OFFSET): Define.
	(LZMA_PROB_MATCH_LEN_HIGH_OFFSET): Define.
	(LZMA_PROB_REP_LEN_CHOICE_OFFSET): Define.
	(LZMA_PROB_REP_LEN_CHOICE2_OFFSET): Define.
	(LZMA_PROB_REP_LEN_LOW_OFFSET): Define.
	(LZMA_PROB_REP_LEN_MID_OFFSET): Define.
	(LZMA_PROB_REP_LEN_HIGH_OFFSET): Define.
	(LZMA_PROB_LITERAL_OFFSET): Define.
	(LZMA_PROB_TOTAL_COUNT): Define.
	(LZMA_IS_MATCH, LZMA_IS_REP, LZMA_IS_REP0): Define.
	(LZMA_IS_REP1, LZMA_IS_REP2, LZMA_IS_REP0_LONG): Define.
	(LZMA_DIST_SLOT, LZMA_DIST_SPECIAL, LZMA_DIST_ALIGN): Define.
	(LZMA_MATCH_LEN_CHOICE, LZMA_MATCH_LEN_CHOICE2): Define.
	(LZMA_MATCH_LEN_LOW, LZMA_MATCH_LEN_MID): Define.
	(LZMA_MATCH_LEN_HIGH, LZMA_REP_LEN_CHOICE): Define.
	(LZMA_REP_LEN_CHOICE2, LZMA_REP_LEN_LOW): Define.
	(LZMA_REP_LEN_MID, LZMA_REP_LEN_HIGH, LZMA_LITERAL): Define.
	(elf_lzma_varint): New static function.
	(elf_lzma_range_normalize): New static function.
	(elf_lzma_bit, elf_lzma_integer): New static functions.
	(elf_lzma_reverse_integer): New static function.
	(elf_lzma_len, elf_uncompress_lzma_block): New static functions.
	(elf_uncompress_lzma): New static function.
	(backtrace_uncompress_lzma): New function.
	(elf_add): Add memory and memory_size parameters.  Change all
	callers.  Look for .gnu_debugdata section, and, if found,
	decompress it and use it for symbols and debug info.  Permit the
	descriptor parameter to be -1.
	* internal.h (backtrace_uncompress_lzma): Declare.
	* mtest.c: New file.
	* xztest.c: New file.
	* configure.ac: Check for nm, xz, and comm programs.  Check for
	liblzma library.
	(HAVE_MINIDEBUG): Define.
	* Makefile.am (mtest_SOURCES): Define.
	(mtest_CFLAGS, mtest_LDADD): Define.
	(TESTS): Add mtest_minidebug if HAVE_MINIDEBUG.
	(%_minidebug): New pattern rule, if HAVE_MINIDEBUG.
	(xztest_SOURCES, xztest_CFLAGS, xztest_LDADD): Define.
	(xztest_alloc_SOURCES, xztest_alloc_CFLAGS): Define
	(xztest_alloc_LDADD): Define.
	(BUILDTESTS): Add mtest, xztest, xztest_alloc.
	(CLEANFILES): Add files created by minidebug pattern.
	(btest.lo): Correct INCDIR reference.
	(mtest.lo, xztest.lo, ztest.lo): New targets.
	* configure: Regenerate.
	* config.h.in: Regenerate.
	* Makefile.in: Regenerate.

Close #38
2020-09-27 17:28:39 -07:00
Ian Lance Taylor
2f5efbfa32 libbacktrace: don't strip leading underscore on 64-bit PE
* pecoff.c (coff_initialize_syminfo): Add is_64 parameter.
	(coff_add): Determine and pass is_64.

Closes #28
2020-09-27 17:19:28 -07:00
Ian Lance Taylor
4ae8d988a7 libbacktrace: fetch executable path on macOS
PR libbacktrace/96973
	* fileline.c (macho_get_executable_path): New static function.
	(fileline_initialize): Call macho_get_executable_path.
2020-09-27 17:18:38 -07:00
Ian Lance Taylor
430dc8b6fe libbacktrace: avoid ambiguous binary search
Searching for a range match can cause the search order to not match
the sort order, which can cause libbacktrace to miss matching entries.
Allocate an extra entry at the end of function_addrs and unit_addrs vectors,
so that we can safely compare to the next entry when searching.
Adjust the matching code accordingly.

Fixes #44

	* dwarf.c (function_addrs_search): Compare against the next entry
	low address, not the high address.
	(unit_addrs_search): Likewise.
	(build_address_map): Add a trailing unit_addrs.
	(read_function_entry): Add a trailing function_addrs.
	(read_function_info): Likewise.
	(report_inlined_functions): Search backward for function_addrs
	match.
	(dwarf_lookup_pc): Search backward for unit_addrs and
	function_addrs matches.
2020-09-27 17:17:59 -07:00
Ian Lance Taylor
5dec0fae31 libbacktrace: fix tipo in comment
* simple.c (simple_unwind): Correct comment spelling.

Close #47
2020-09-27 17:17:10 -07:00
Ian Lance Taylor
030bd0a709 libbacktrace: correct memory lengths in Mach-O dsym support
* macho.c (macho_add_dsym): Make space for '/' in dsym.  Use
	correct length when freeing diralc.

Close #40
2020-09-27 17:16:15 -07:00
Ian Lance Taylor
b3b57f9ee0 libbacktrace: correctly swap Mach-O 32-bit file offset
libbacktrace/ChangeLog:
	PR libbacktrace/96973
	* macho.c (macho_add_fat): Correctly swap 32-bit file offset.
2020-09-27 17:15:03 -07:00
Ian Lance Taylor
886aef3783 libbacktrace: only match magic number at start of line
libbacktrace/ChangeLog:
	PR libbacktrace/96971
	* filetype.awk: Only match magic number at start of line.
2020-09-27 17:14:27 -07:00
Ian Lance Taylor
89b2b5066b libbacktrace: add Mach-O 64-bit FAT support
libbacktrace/:
	* macho.c (MACH_O_MH_MAGIC_FAT_64): Define.
	(MACH_O_MH_CIGAM_FAT_64): Define.
	(struct macho_fat_arch_64): Define.
	(macho_add_fat): Add and use is_64 parameter.
	(macho_add): Recognize 64-bit fat files.
2020-09-27 17:13:21 -07:00
Ian Lance Taylor
aaa51b6dbe libbacktrace: test linker support for DWARF 5
On AIX, the compiler supports DWARF 5 but the linker does not.

2020-07-07 Clement Chigot <clement.chigot@atos.net>

	* configure.ac: Test linker support for DWARF5
	* configure: Regenerate
2020-09-27 17:12:15 -07:00
Ian Lance Taylor
9b7f216e86 libbacktrace: mark test_large parameter unused in ztest.c 2020-05-13 11:11:13 -07:00
Ian Lance Taylor
d68a7ac6dd libbacktrace: treat EACCESS like ENOENT
For https://gcc.gnu.org/PR95061
2020-05-13 10:29:45 -07:00
Ian Lance Taylor
14465a9574 libbacktrace: declare getpagesize if necessary
Fixes https://gcc.gnu.org/PR95012.
2020-05-11 10:54:46 -07:00
Ian Lance Taylor
7206f5bd06 libbacktrace: don't crash if ELF file has no sections
Patch from Roland McGrath.

Fixes #41
2020-05-09 20:36:19 -07:00
Ian Lance Taylor
ca0de0517f libbacktrace: don't free ELF strtab if error occurs after saving syminfo
Fixes #29
2020-02-19 10:32:09 -08:00
Ian Lance Taylor
4e548e735f libbacktrace: add preliminary Mach-O support 2020-02-18 18:57:14 -08:00
Ian Lance Taylor
929d6205cf libbacktrace: always pass -g when compiling test code
This approach required adding a few casts to ztest.c, as it is now
compiled with -Wall.

Fixes GCC PR libbacktrace/90636
2020-02-18 18:49:42 -08:00
Ian Lance Taylor
bd02146d90 Update copyright years. 2020-02-18 18:46:13 -08:00
Ian Lance Taylor
75cac302a5 libbacktrace: update to current libgo test file 2020-02-15 18:26:32 -08:00
Ian Lance Taylor
4e14a008cd libbacktrace: support short read
Fixes #32
2020-02-15 18:14:20 -08:00
Ian Lance Taylor
aced4e1f2a libbacktrace: if debug info large or split, read sections individually
Fixes #29
2020-02-15 17:58:09 -08:00
Ian Lance Taylor
0f06cda953 libbacktrace: support fetching executable name using sysctl
This supports FreeBSD and NetBSD when /proc is not mounted.
2020-02-15 15:33:11 -08:00
Ian Lance Taylor
559ab7cab4 libbacktrace: update to current version from GCC trunk
This adds DWARF 5 support as well as an enhanced testsuite.

Patch assembled by Than McIntosh.
2019-12-23 18:55:51 -08:00
Ian Lance Taylor
5a99ff7fed config.guess, config.sub: update to latest versions
Update to config.guess 2018-05-19 and config.sub 2018-05-24 from
git://git.savannah.gnu.org/config.git revision
3a2a927f547ee478147008c3fda2adb8a2b2ebc4.

This brings in musl support.
2018-06-05 08:00:51 -07:00
Ian Lance Taylor
22508c46b3 config.guess, config.sub: update to current GCC versions
Copied from GCC revision 256122.
2018-06-05 07:37:14 -07:00
Ian Lance Taylor
1b8128cf56 * backtrace.c: Revert last change. Don't call mmap
directly.

Updates #13
2018-04-17 10:59:18 -07:00
Ian Lance Taylor
012b950b37 Copy changes from GCC:
2018-04-17  Ian Lance Taylor  <iant@golang.org>

	* backtrace.c (backtrace_full): When testing whether we can
	allocate memory, call mmap directly, and munmap the memory.

2018-04-04  Jakub Jelinek  <jakub@redhat.com>

	PR other/85161
	* elf.c (elf_zlib_fetch): Fix up predefined macro names in test for
	big endian, only use 32-bit loads if endianity macros are predefined
	and indicate big or little endian.

2018-02-15  Jakub Jelinek  <jakub@redhat.com>

	PR other/82368
	* elf.c (SHT_PROGBITS): Undefine and define.

2018-02-14  Jakub Jelinek  <jakub@redhat.com>

	PR other/82368
	* elf.c (EM_PPC64, EF_PPC64_ABI): Undefine and define.
	(struct elf_ppc64_opd_data): New type.
	(elf_initialize_syminfo): Add opd argument, handle symbols
	pointing into the PowerPC64 ELFv1 .opd section.
	(elf_add): Read .opd section on PowerPC64 ELFv1, pass pointer
	to structure with .opd data to elf_initialize_syminfo.

2018-01-19  Tony Reix  <tony.reix@atos.net>

	* xcoff.c (xcoff_incl_compare): New function.
	(xcoff_incl_search): New function.
	(xcoff_process_linenos): Use bsearch to find include file.
	(xcoff_initialize_fileline): Sort include file information.

Fixes #13
2018-04-17 07:04:02 -07:00
Ian Lance Taylor
177940370e * elf.c (elf_add): Close descriptor if we use a debugfile.
* btest.c (check_open_files): New static function.
	(main): Call check_open_files.
2018-01-31 15:24:01 -08:00
Ian Lance Taylor
811741b03b * elf.c (elf_open_debugfile_by_debuglink): Don't check CRC if the
desired CRC is zero.
	(elf_add): Don't clear *found_sym and *found_dwarf if debuginfo.
2018-01-25 10:14:34 -08:00
Ian Lance Taylor
8a4e4ea552 * pecoff.c (coff_add): Only release syms_view if it is valid. 2018-01-25 07:38:52 -08:00
Ian Lance Taylor
97dd0dfa9e * pecoff.c (coff_add): Another memcpy -> coff_read4 fix.
Updates #11
2018-01-25 07:34:02 -08:00