Commit Graph

111 Commits

Author SHA1 Message Date
David Rubin
63bbf66553 riscv: remove an allocation from dwarf.zig 2024-05-11 02:17:11 -07:00
Andrew Kelley
cd62005f19 extract std.posix from std.os
closes #5019
2024-03-19 11:45:09 -07:00
Luuk de Gram
0103c4bf78 std: make std.dwarf.FixedBufferReader public
Also fixes a compile-error as the field `is_64` no longer exists.
2024-03-14 02:57:46 -07:00
Andrew Kelley
aa852f737b improve documentation in std
A lot of these "shorthand" doc comments were redundant, low quality
filler content. Better to let the actual modules speak for themselves
with top level doc comments rather than trying to document their
aliases.
2024-03-10 18:13:30 -07:00
Jacob Young
247e4ac3cc dwarf: optimize dwarf parsing for speed
This code is run when printing a stack trace in a debug executable, so
it has to be fast even without compiler optimizations.

Adding a `@panic` to the top of `main` and running an x86_64 backend
compiled compiler goes from `1m32.773s` to `0m3.232s`.
2024-02-18 14:11:06 +01:00
mlugg
51595d6b75
lib: correct unnecessary uses of 'var' 2023-11-19 09:55:07 +00:00
Jacob Young
d890e81761 mem: fix ub in writeInt
Use inline to vastly simplify the exposed API.  This allows a
comptime-known endian parameter to be propogated, making extra functions
for a specific endianness completely unnecessary.
2023-10-31 21:37:35 -04:00
Zachary Raineri
49244dc0ca
std: remove some unused imports (#16710) 2023-08-06 15:18:50 -04:00
kcbanner
661028a907 target: emit unwind tables if the platform supports unwinding 2023-07-26 20:58:29 -04:00
kcbanner
49fa3a987f reduce the number of duplicate instantiations due to differing stream parameters 2023-07-25 00:45:47 -04:00
kcbanner
ab2e0b927d switch to sortUnstable when sorting FDEs (~16ms improvement) 2023-07-24 23:27:05 -04:00
kcbanner
b1d86db7b4 dwarf: move macho unwind code from macho -> dwarf
dwarf: fixup unchecked .eh_frame CIE offset subtraction
2023-07-20 22:58:16 -04:00
kcbanner
8e6a62ba10 test: disable omit_frame_pointer unwinding tests on aarch64-macos
dwarf: handle signal frame CIE flag
2023-07-20 22:58:16 -04:00
kcbanner
6d87bb370a debug: disable the new unwinder on aarch64-macos 2023-07-20 22:58:16 -04:00
kcbanner
253e6971ad dwarf: implement aarch64 default register rules 2023-07-20 22:58:16 -04:00
kcbanner
4421b14878 dwarf: fixup rules for setting ip 2023-07-20 22:58:16 -04:00
kcbanner
2bc2b01dbc dwarf: update the pc register 2023-07-20 22:58:16 -04:00
kcbanner
d99b40d38b dwarf: fix the unwinder using the incorrect row from the FDE in certain cases 2023-07-20 22:58:16 -04:00
kcbanner
1a2bb70956 dwarf: write the CFA as SP before the register update, in case the SP itself is updated by a column rule 2023-07-20 22:58:16 -04:00
kcbanner
97bda56306 macho: don't scan all eh_frame entries, instead follow the offset from the __unwind_info directly 2023-07-20 22:58:16 -04:00
kcbanner
774dc2fdb7 dwarf: add explicit_fde_offset to support more optimal __unwind_info dwarf lookups 2023-07-20 22:58:16 -04:00
kcbanner
618b0eb3d3 dwarf: fixup integer overflow in readEhPointer
debug: handle the possibility of eh_frame / debug_frame being mapped in memory or loaded from disk
2023-07-20 22:58:16 -04:00
kcbanner
ba813d00f5 dwarf: add abi.stripInstructionPtrAuthCode 2023-07-20 22:58:16 -04:00
kcbanner
b18031335a dwarf: use cie.return_address_register instead of assuming it's in the IP register 2023-07-20 22:58:16 -04:00
kcbanner
891fa3b8b5 debug: fix initialization of the optional fields on StackIterator
dwarf: documentation fixups
target: enable unwind tables on macho
2023-07-20 22:58:15 -04:00
kcbanner
94354aa6aa macho: add unwindFrame which can unwind stack frames using the __unwind_info section
dwarf: fixup missing error
2023-07-20 22:58:15 -04:00
kcbanner
d226b74ae8 dwarf: add ExpressionError to work around the compiler not being able to infer it
dwarf: implement OP.entry_value, add tests
2023-07-20 22:58:15 -04:00
kcbanner
21d0154139 dwarf: skip register tests on unimplemented arch / os, add tests for type convesions
debug: dupeContext -> copyContext
2023-07-20 22:58:15 -04:00
kcbanner
54ca62fef4 dwarf: fixup regBytes for the case where there is no context support
expressions: add more tests, fix tests for mipsel
debug: add lookupModuleName implementation for macos
2023-07-20 22:58:15 -04:00
kcbanner
5c0d4cef1a debug: add dupeContext, store a pointer to a copy of ThreadContext on UnwindContext 2023-07-20 22:58:15 -04:00
kcbanner
5f72c6508d debug: rename StackTraceContext to ThreadContext
dwarf: use ThreadContext instead of os.ucontext_t
dwarf: add regBytes impl for windows
dwarf: fixup expression types for non-native
2023-07-20 22:58:15 -04:00
kcbanner
8547c42ba5 dwarf: expression fixups for non-64bit arches, check call_frame_context when writing expressions 2023-07-20 22:58:15 -04:00
kcbanner
ad5f74c0b1 dwarf: introduce ExpressionContext, add more expression opcodes 2023-07-20 22:58:14 -04:00
kcbanner
412cd789bf debug: fixup base address calculations for macho
dwarf: fixup x86 register mapping logic
dwarf: change the register context update to update in-place instead of copying
debug: always print the unwind error type
2023-07-20 22:58:14 -04:00
kcbanner
b85f84061a dwarf: don't dupe function names, as they are backed by the memory mapped sections
dwarf: const-correctness fixups
dwarf: implement the remaining register rules
dwarf: start implmenting the DWARF expression stack machine
2023-07-20 22:58:14 -04:00
kcbanner
62598c2187 debug: rework how unwind errors are printed, and add module name lookup for linux
This change enhances stack trace output to include a note that debug info was missing,
and therefore the stack trace may not be accurate. For example, if the user is using a libc
compiled with -fomit-frame-pointer and doesn't have debug symbols installed, any traces
that begin in a libc function may not unwind correctly. This allows the user to notice this and
potentially install debug symbols to improve the output.
2023-07-20 22:58:14 -04:00
kcbanner
f04f9705cc dwarf: add support for DWARF5 DW_AT_ranges in subprograms, add DebugRangeIterator
Some DWARF5 subprograms have non-contiguous instruction ranges. An example of such
a function is `puts` in Ubuntu's libc. This change fixes name lookups for functions that use
DW_AT_range in their DIE.
2023-07-20 22:58:14 -04:00
kcbanner
395ab474eb dwarf: fix logic error in eh_frame_hdry binary search 2023-07-20 22:58:14 -04:00
kcbanner
89ef004646 debug: x86 unwinding support, more unwinding fixes
- Fix unwindFrame using the previous FDE row instead of the current one
- Handle unwinding through noreturn functions
- Add x86-linux getcontext
- Fixup x86_64-linux getcontext not restoring the fp env
- Fix start_addr filtering on x86-windows
2023-07-20 22:58:14 -04:00
kcbanner
a9b6f2d929 dwarf: add support for .debug_frame and CIE version 4 2023-07-20 22:58:14 -04:00
kcbanner
6abf1fbfe6 update to new builtin syntax 2023-07-20 22:58:14 -04:00
kcbanner
84a1244b6c dwarf: use eh_frame length if it's available 2023-07-20 22:58:14 -04:00
kcbanner
521988299d add more safety checks when searching for eh_frame entries using findEntry 2023-07-20 22:58:13 -04:00
kcbanner
a47212c72e - rebase and update to lastest master 2023-07-20 22:58:13 -04:00
kcbanner
adbc5bbdb3 dwarf: fixup pointer cast 2023-07-20 22:58:13 -04:00
kcbanner
5781016c35 dwarf: add support for .eh_frame_hdr when unwinding
- .eh_frame_hdr contains a binary-searchable data structure for finding an FDE. If present, we can use this
section to avoid having to parse the entire FDE/CIE list in the binary, instead only entries that are actually
required for unwinding are read.
- rework the inputs pc-relative pointer decoding to support both already-mapped sections as well as sections
mapped from a file
- store the VirtualMachine on UnwindContext so the allocations can be reused
2023-07-20 22:58:13 -04:00
kcbanner
5ebca4392e debug: fixing more compile errors on arches that I hadn't tested on yet 2023-07-20 22:58:13 -04:00
kcbanner
551f153718 dwarf: fixes for non-64 bit systems 2023-07-20 22:58:13 -04:00
kcbanner
d74c8acdfb dwarf: fixup for sort changes 2023-07-20 22:58:13 -04:00
kcbanner
a325d7f6d1 fmt and cleanup 2023-07-20 22:58:13 -04:00