Ian Lance Taylor
6d913c4521
libbacktrace: report decl_lineno with MOREDATA
...
Based on patch by Andi Kleen.
* backtrace.h (struct backtrace_moredata): Add
backtrace_decl_lineno field.
* internal.h (BACKTRACE_MOREDATA_VERSION): Change to 4.
* dwarf.c (struct function): Add decl_lineno field.
(call_callback): Add decl_lineno parameter. Change all callers.
(read_referenced_name_from_attr): Likewise.
(read_referenced_name): Likewise.
(report_inlined_functions): Likewise.
(read_function_entry): Set decl_lineno field.
(dwarf_lookup_pc): Handle decl_lineno across inlines.
* mdtest.c (struct mdinfo): Define.
(struct mddata): Define.
(md_callback_one): Adjust for mddata.
(md_callback_three): Likewise.
(test1, f2): Reformat for simpler line number testing.
(f3): Test that decl_lineno is correct.
(f13): Adjust for mddata.
2026-08-31 12:42:36 -07:00
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
3d0be55844
libbacktrace: don't get confused by overlapping address ranges
...
Fixes https://github.com/ianlancetaylor/libbacktrace/issues/137 .
* dwarf.c (resolve_unit_addrs_overlap_walk): New static function.
(resolve_unit_addrs_overlap): New static function.
(build_dwarf_data): Call resolve_unit_addrs_overlap.
2024-10-18 13:04:47 -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
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
afe2967c77
libbacktrace: change PC variables from uint64_t to uintptr_t
...
Change variables holding PC values from uint64_t to uintptr_t.
Patch by Björn Schäpers.
* dwarf.c (struct function_addrs): Change low and high fields to
uintptr_t.
(struct unit_addrs): Likewise.
(resolve_addr_index): Change address parameter to uintptr_t*.
(add_unit_addr): Change lowpc and highpc parameters to uintptr_t.
(add_function_range): Likewise.
(struct pcrange): Change lowpc and highpc fields to uintptr_t.
(add_low_high_range): Change add_range lowpc and highpc parameters
to uintptr_t.
(add_ranges_from_ranges): Likewise.
(add_ranges_from_rnglists): Likewise.
(add_low_high_range): Chnage lowpc and highpc variables to
uintpr_t.
(add_ranges_from_rnglists): Change some local variables to
uintptr_t.
(add_ranges_from_ranges): Change base parameter to uintptr_t.
(add_ranges_from_rnglists): Likewise.
(read_function_entry): Likewise.
(resolve_addr_index): Add explicit casts to uintptr_t.
(update_pcrange): Likewise.
(add_ranges_from_ranges): Likewise.
(add_ranges_from_rnglists): Likewise.
(read_function_entry): Likewise.
2023-01-20 14:25:38 -08:00
Ian Lance Taylor
2446c66076
libbacktrace: gather address ranges from skeleton units
...
* dwarf.c (find_address_ranges): Handle skeleton units.
(read_function_entry): Likewise.
2022-02-17 08:27:13 -08:00
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
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
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
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
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
bd02146d90
Update copyright years.
2020-02-18 18:46:13 -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
Than McIntosh
17f687d2b9
Update from gcc trunk version of libbacktrace at svn rev 256427. ( #8 )
...
Includes (among other things) support for compressed debug sections,
a variety of bugfixes, and expanded test coverage.
2018-01-12 10:26:02 -08:00
Ian Lance Taylor
ba79a27ee9
all: remove meaningless trailing whitespace
2016-09-11 06:45:37 -07:00
Ian Lance Taylor
84241313f2
libbacktrace: initial commit
...
This is a standalone version of the libbacktrace library that I
originally wrote for GCC. This is a copy of libbacktrace from GCC
trunk, with all dependencies incorporated here.
2016-09-10 07:59:09 -07:00