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
021f537863
dwarf: fixup default endianness in ExpressionOptions, add control flow tests
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
463bbe7807
dwarf: implement constx,addrx, begin adding DWARF expression tests
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
424b1299a8
dwarf: add expression writer
2023-07-20 22:58:14 -04:00
kcbanner
ad5f74c0b1
dwarf: introduce ExpressionContext, add more expression opcodes
2023-07-20 22:58:14 -04:00
kcbanner
576ffaa329
darwin: update mcontext_t definition for aarch64 to add neon state
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
6a5e2b713f
debug: de-duplicate some code in macos ModuleDebugInfo
2023-07-20 22:58:14 -04:00
kcbanner
ccc9f82068
c: fixup getcontext
...
debug: supports_context -> have_ucontext, supports_getcontext -> have_getcontext
test: rework dwarf_unwind test case to also test the non-libc path
2023-07-20 22:58:14 -04:00
kcbanner
7bc1695f15
c: musl doesn't implement getcontext, so defer to our implementation in that case
2023-07-20 22:58:14 -04:00
kcbanner
9c908ea814
test: add standalone test for DWARF unwinding with -fomit-frame-pointer
2023-07-20 22:58:14 -04:00
kcbanner
23d9b59b86
c: add getcontext
...
debug: make getContext public
2023-07-20 22:58:14 -04:00
kcbanner
f991b9dc05
debug: fix reading -gdwarf generated debug sections in COFF files
...
I had accidentally regressed support for -gdwarf in 461fb499f3
when I changed the logic to
use the already-mapped exe/dll image instead of loading it from disk. The string table is mapped as all zeroes by the loader,
so if a section header's name is longer than 8 bytes (like the ones generated by -gdwarf), then the name can't be read.
Now, if any section headers require the string table, the file is mapped from disk.
windows: Add NtCreateSection/NtMapViewOfSection/NtUnmapViewOfSection
2023-07-20 22:58:14 -04:00
kcbanner
caa334712f
linux: rework getcontext to closer match the specification (saved IP/SP match the state after it would return)
...
debug: fixup ucontext_t check
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
5cd8ab2473
debug: enhance writeCurrentStackTrace to use context-based unwinding when available
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
41832aa1e6
linux: add getcontext for x86_64
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
dd2035735f
debug: fix memory leak when an error occurs opening a pdb file
2023-07-20 22:58:13 -04:00
kcbanner
865d4d2d8c
debug: more fixups for mips linux not having ucontext_t
...
- increase test-std max_rss to 1.1 above the CI observed amount
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
2f75d20d87
debug: use an explicit context type instead of anytype for dumpStackTraceFromBase, update crash_report to use this for exceptions
2023-07-20 22:58:13 -04:00
kcbanner
d74c8acdfb
dwarf: fixup for sort changes
2023-07-20 22:58:13 -04:00
kcbanner
d1a9bb1fea
debug: fixup context detection for wasi
2023-07-20 22:58:13 -04:00
kcbanner
a325d7f6d1
fmt and cleanup
2023-07-20 22:58:13 -04:00
kcbanner
c98e03fc7e
- rework CFI instruction parsing to not use std.meta
...
- move register formatting code to zig-dwardump
2023-07-20 22:58:13 -04:00
kcbanner
e72e762d1e
dwarf: implement more register mappings, fix up macos compile
2023-07-20 22:58:13 -04:00
kcbanner
9145ff7da0
dwarf: implement more register number mappings
...
- add dwarf.abi.RegisterContext to handle register numbers changing based on DWARF format
2023-07-20 22:58:13 -04:00
kcbanner
b449d98a93
- rework StackIterator to optionally use debug_info to unwind the stack
...
- add abi routines for getting register values
- unwding is working!
2023-07-20 22:58:13 -04:00
kcbanner
69399fbb82
- add default register rule
...
- fixup eh pointer decoding
2023-07-20 22:58:13 -04:00
kcbanner
a0a40c2e7e
- implement more opcodes
2023-07-20 22:58:13 -04:00
kcbanner
7b4611cfb3
- move writing code to zig-dwarfdump
...
- implement restore_state, restore_extended, offset_extended
2023-07-20 22:58:13 -04:00
kcbanner
338df862d1
- fix remember_state
...
- implement def_cfa_register
2023-07-20 22:58:13 -04:00
kcbanner
f3f3c877e0
- add DWARF expression parser
...
- change read apis to use a stream
- add register formatters
2023-07-20 22:58:13 -04:00