Commit Graph
16 Commits
Author SHA1 Message Date
Ian Lance Taylor 6f8310e238 libbacktrace: support returning discriminator field
Based on patch from Andi Kleen.

	* backtrace.h (backtrace_create_state): Rewrite comment to change
	threaded parameter to flags.
	(backtrace_full_callback, backtrace_syminfo_callback): Document
	behavior change if moredata flag is set.
	(struct backtrace_moredata): Define.
	* backtrace-supported.h.in (BACKTRACE_SUPPORTS_MOREDATA): Define.
	* internal.h (struct backtrace_state): Add moredata field.
	(BACKTRACE_MOREDATA_VERSION): Define.
	* state.c (backtrace_create_state): Change threaded parameter to
	flags.  Set state moredata field based on flags.
	* dwarf.c (struct line): Add disc field.
	(struct function): Add caller_disc field.
	(call_callback): New static function.
	(add_line): Add disc parameter.  Change all callers.  Store disc
	in new line value.
	(read_line_program): Track discriminator value.
	(read_line_info): Initialize disc field in final line entry.
	(read_function_entry): Handle DW_AT_GNU_discriminator.
	(report_inlined_functions): Add disc parameter. Change all
	callers. Call call_callback rather than calling callback
	directly.
	(dwarf_lookup_pc): Handle inlined discriminators. Call
	call_callback rather than calling callback directly.
	(dwarf_fileline): Call call_callback rather than calling callback
	directly.
	* elf.c (elf_syminfo): Pass moredata if requested.
	* macho.c (macho_syminfo): Likewise.
	* pecoff.c (coff_syminfo): Likewise.
	* xcoff.c (xcoff_syminfo): Likewise.
	(xcoff_lookup_pc): Likewise.
	* backtrace.c: #include <string.h>.
	(unwind): Pass moredata if requested.
	* unknown.c: #include <string.h>.
	(unknown_fileline): Pass moredata if requested.
	* fileline.c (backtrace_syminfo_to_full_callback): Add comment
	about moredata.
	* mdtest.c: New test file.
	* Makefile.am (mdtest_SOURCES): Define.
	(mdtest_CFLAGS, mdtest_LDFLAGS, mdtest_LDADD): Define.
	(BUILDTESTS): Add mdtest.
	* Makefile.in: Regenerate.
2026-07-06 12:42:21 -07:00
Jakub Jelinek 42962d2cfb Update copyright years. 2026-05-03 18:21:13 -07:00
Jakub Jelinek bdd324c192 Update copyright years. 2026-05-03 18:20:27 -07:00
Ian Lance Taylor d48f84034c libbacktrace: recognize new Mach-O DWARF sections
Patch from Pavel Safonov.

These sections are used on macOS Sequoia.

Fixes #136

	* macho.c (dwarf_section_names): Add __debug_addr and
	__debug_line_str.
2024-10-25 15:21:34 -07:00
Ian Lance Taylor 1dd5c408fe libbacktrace: support FDPIC
Based on patch by Max Filippov.

	* internal.h: If FDPIC, #include <link.h> and/or <sys/link.h>.
	(libbacktrace_using_fdpic): Define.
	(struct libbacktrace_base_address): Define.
	(libbacktrace_add_base): Define.
	(backtrace_dwarf_add): Change base_address to struct
	libbacktrace_base_address.
	* dwarf.c (struct dwarf_data): Change base_address to struct
	libbacktrace_base_address.
	(add_ranges, find_address_ranges, build_ddress_map): Likewise.
	(build_dwarf_data, build_dwarf_add): Likewise.
	(add_low_high_range): Change base_address to struct
	libbacktrace_base_address.  Use libbacktrace_add_base.
	(add_ranges_from_ranges, add_ranges_from_rnglists): Likewise.
	(add_line): Use libbacktrace_add_base.
	* elf.c (elf_initialize_syminfo): Change base_address to struct
	libbacktrace_base_address.  Use libbacktrace_add_base.
	(elf_add): Change base_address to struct
	libbacktrace_base_address.
	(phdr_callback): Likewise.  Initialize base_address.m.
	(backtrace_initialize): If using FDPIC, don't call elf_add with
	main executable; always use dl_iterate_phdr.
	* macho.c (macho_add_symtab): Change base_address to struct
	libbacktrace_base_address.  Use libbacktrace_add_base.
	(macho_syminfo): Change base_address to struct
	libbacktrace_base_address.
	(macho_add_fat, macho_add_dsym, macho_add): Likewise.
	(backtrace_initialize): Likewise.  Initialize base_address.m.
	* pecoff.c (coff_initialize_syminfo): Change base_address to
	struct libbacktrace_base_address.  Use libbacktrace_add_base.
	(coff_add): Change base_address to struct
	libbacktrace_base_address.  Initialize base_address.m.
2024-07-15 17:29:35 -07:00
Ian Lance Taylor 8c05bcb94f libbacktrace: update copyright years 2024-07-11 18:14:01 -07:00
Ian Lance Taylor 3fda5a8759 libbacktrace: correctly gather Mach-O symbol table
For PR libbacktrace/97082.
	* macho.c (MACH_O_N_EXT): Don't define.
	(MACH_O_N_UNDF): Define.
	(macho_defined_symbol): Don't discard N_EXT symbols.  Do
	discard N_UNDF symbols.
2024-07-11 17:57:40 -07:00
Ian Lance Taylor e3e64ddd18 libbacktrace: suggest how to fix missing debug info
* elf.c (elf_nodebug): Suggest -g.
	* macho.c (macho_nodebug): Suggest -g and dsymutil.
	* pecoff.c (coff_nodebug): Suggest -g.

Fixes #122
2024-07-11 15:42:10 -07:00
Ian Lance Taylor f69acdfbd6 libbacktrace: remove trailing whitespace
* dwarf.c: Remove trailing whitespace.
	* macho.c: Likewise.

Fixes #124
2024-07-11 15:30:09 -07:00
Ian Lance Taylor 7409767403 libbacktrace: don't exit Mach-O dyld library loop on one failure
* macho.c (backtrace_initialize) [HAVE_MACH_O_DYLD_H]: Don't exit
	loop if we can't find debug info for one shared library.

For #85
2022-07-07 16:55:51 -07:00
Jakub Jelinek 5496ee0a1a Update copyright years. 2021-01-18 14:56:19 -08: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 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 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 4e548e735f libbacktrace: add preliminary Mach-O support 2020-02-18 18:57:14 -08:00