aboutsummaryrefslogtreecommitdiff
path: root/lib/std/debug.zig
AgeCommit message (Collapse)Author
2023-10-02Add illumos OS tagStephen Gregoratto
- Adds `illumos` to the `Target.Os.Tag` enum. A new function, `isSolarish` has been added that returns true if the tag is either Solaris or Illumos. This matches the naming convention found in Rust's `libc` crate[1]. - Add the tag wherever `.solaris` is being checked against. - Check for the C pre-processor macro `__illumos__` in CMake to set the proper target tuple. Illumos distros patch their compilers to have this in the "built-in" set (verified with `echo | cc -dM -E -`). Alternatively you could check the output of `uname -o`. Right now, both Solaris and Illumos import from `c/solaris.zig`. In the future it may be worth putting the shared ABI bits in a base file, and mixing that in with specific `c/solaris.zig`/`c/illumos.zig` files. [1]: https://github.com/rust-lang/libc/tree/6e02a329a2a27f6887ea86952f389ca11e06448c/src/unix/solarish
2023-09-23compiler: preserve result type information through address-of operatormlugg
This commit introduces the new `ref_coerced_ty` result type into AstGen. This represents a expression which we want to treat as an lvalue, and the pointer will be coerced to a given type. This change gives known result types to many expressions, in particular struct and array initializations. This allows certain casts to work which previously required explicitly specifying types via `@as`. It also eliminates our dependence on anonymous struct types for expressions of the form `&.{ ... }` - this paves the way for #16865, and also results in less Sema magic happening for such initializations, also leading to potentially better runtime code. As part of these changes, this commit also implements #17194 by disallowing RLS on explicitly-typed struct and array initializations. Apologies for linking these changes - it seemed rather pointless to try and separate them, since they both make big changes to struct and array initializations in AstGen. The rationale for this change can be found in the proposal - in essence, performing RLS whilst maintaining the semantics of the intermediary type is a very difficult problem to solve. This allowed the problematic `coerce_result_ptr` ZIR instruction to be completely eliminated, which in turn also simplified the logic for inferred allocations in Sema - thanks to this, we almost break even on line count! In doing this, the ZIR instructions surrounding these initializations have been restructured - some have been added and removed, and others renamed for clarity (and their semantics changed slightly). In order to optimize ZIR tag count, the `struct_init_anon_ref` and `array_init_anon_ref` instructions have been removed in favour of using `ref` on a standard anonymous value initialization, since these instructions are now virtually never used. Lastly, it's worth noting that this commit introduces a slightly strange source of generic poison types: in the expression `@as(*anyopaque, &x)`, the sub-expression `x` has a generic poison result type, despite no generic code being involved. This turns out to be a logical choice, because we don't know the result type for `x`, and the generic poison type represents precisely this case, providing the semantics we need. Resolves: #16512 Resolves: #17194
2023-08-17Merge pull request #16824 from mikdusan/bsdAndrew Kelley
de-bitrot the BSDs
2023-08-17std.debug: openbsd does not have getcontextMichael Dusan
2023-08-15std.debug: avoid os.getFdPathMichael Dusan
Commit ea9917d9bd921f9fc14028a8dbf9e3f0f2579120 introduced usage of fs.Dir.realpath which eventually calls os.getFdpath which is forbidden to be used by the compiler. It causes building zig to fail on OpenBsd, NetBSD and older versions of FreeBSD and DragonFly. This patch substitutes with os.realpath on libc targets and eventually calls c.realpath and allows zig to build. Any use of realpath is not desired but this is the lesser evil.
2023-08-15coff: handle the case of there being no PDB pathkcbanner
2023-08-15debug: support looking up debug symbols in both PDB and DWARF debug info, ↵kcbanner
instead of only using DWARF if `.debug_info` is present coff: support reading from memory loaded by the loader, or a mapped file
2023-08-06std: remove some unused imports (#16710)Zachary Raineri
2023-08-04debug: expose module debug info deinitializationDavid Gonzalez Martin
Before this commit, you could use readElfDebugInfo independently with one catch: the data is not freed since the deinitialization functions for ModuleDebugInfo are private. This change makes them public so the users of such function and similar can free the memory after the debug symbols have been used.
2023-07-26debug: skip unwind error printing on platforms that don't have_ucontextkcbanner
2023-07-26debug: print unwind errors if they occur on the first iteration, and ↵kcbanner
differentiate between missing info and an actual unwind error in the message
2023-07-20dwarf: move macho unwind code from macho -> dwarfkcbanner
dwarf: fixup unchecked .eh_frame CIE offset subtraction
2023-07-20test: disable omit_frame_pointer unwinding tests on aarch64-macoskcbanner
dwarf: handle signal frame CIE flag
2023-07-20debug: disable the new unwinder on aarch64-macoskcbanner
2023-07-20macho: don't scan all eh_frame entries, instead follow the offset from the ↵kcbanner
__unwind_info directly
2023-07-20dwarf: add explicit_fde_offset to support more optimal __unwind_info dwarf ↵kcbanner
lookups
2023-07-20debug: load the macho unwind sections from the already-mapped imagekcbanner
2023-07-20dwarf: fixup integer overflow in readEhPointerkcbanner
debug: handle the possibility of eh_frame / debug_frame being mapped in memory or loaded from disk
2023-07-20use eh_frame from the mapped binary if availablekcbanner
2023-07-20debug: fixup an inconsistency in the getcontext implementation on aarch64-macoskcbanner
2023-07-20dwarf: use cie.return_address_register instead of assuming it's in the IP ↵kcbanner
register
2023-07-20debug: fixup have_getcontextkcbanner
2023-07-20debug: fixup last_error being printed too many timeskcbanner
2023-07-20debug: fix initialization of the optional fields on StackIteratorkcbanner
dwarf: documentation fixups target: enable unwind tables on macho
2023-07-20macho: add aarch64 implementation to unwindFramekcbanner
dwarf: map the V registers in abi.regBytes test: add test case that exercises the stack-indirect __unwind_info mode in x86_64
2023-07-20debug: add relocateContextkcbanner
dwarf: fixup tests that used a ThreadContext
2023-07-20macho: add unwindFrame which can unwind stack frames using the __unwind_info ↵kcbanner
section dwarf: fixup missing error
2023-07-20dwarf: add ExpressionError to work around the compiler not being able to ↵kcbanner
infer it dwarf: implement OP.entry_value, add tests
2023-07-20dwarf: skip register tests on unimplemented arch / os, add tests for type ↵kcbanner
convesions debug: dupeContext -> copyContext
2023-07-20dwarf: fixup regBytes for the case where there is no context supportkcbanner
expressions: add more tests, fix tests for mipsel debug: add lookupModuleName implementation for macos
2023-07-20debug: add dupeContext, store a pointer to a copy of ThreadContext on ↵kcbanner
UnwindContext
2023-07-20debug: rename StackTraceContext to ThreadContextkcbanner
dwarf: use ThreadContext instead of os.ucontext_t dwarf: add regBytes impl for windows dwarf: fixup expression types for non-native
2023-07-20dwarf: introduce ExpressionContext, add more expression opcodeskcbanner
2023-07-20darwin: update mcontext_t definition for aarch64 to add neon statekcbanner
2023-07-20debug: fixup base address calculations for machokcbanner
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-20dwarf: don't dupe function names, as they are backed by the memory mapped ↵kcbanner
sections dwarf: const-correctness fixups dwarf: implement the remaining register rules dwarf: start implmenting the DWARF expression stack machine
2023-07-20debug: rework how unwind errors are printed, and add module name lookup for ↵kcbanner
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-20debug: de-duplicate some code in macos ModuleDebugInfokcbanner
2023-07-20c: fixup getcontextkcbanner
debug: supports_context -> have_ucontext, supports_getcontext -> have_getcontext test: rework dwarf_unwind test case to also test the non-libc path
2023-07-20c: add getcontextkcbanner
debug: make getContext public
2023-07-20debug: fix reading -gdwarf generated debug sections in COFF fileskcbanner
I had accidentally regressed support for -gdwarf in 461fb499f3cff9038a427eae120fb34defc9ab38 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-20linux: rework getcontext to closer match the specification (saved IP/SP ↵kcbanner
match the state after it would return) debug: fixup ucontext_t check
2023-07-20debug: x86 unwinding support, more unwinding fixeskcbanner
- 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-20debug: enhance writeCurrentStackTrace to use context-based unwinding when ↵kcbanner
available
2023-07-20update to new builtin syntaxkcbanner
2023-07-20- rebase and update to lastest masterkcbanner
2023-07-20dwarf: add support for .eh_frame_hdr when unwindingkcbanner
- .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-20debug: fix memory leak when an error occurs opening a pdb filekcbanner
2023-07-20debug: more fixups for mips linux not having ucontext_tkcbanner
- increase test-std max_rss to 1.1 above the CI observed amount
2023-07-20debug: fixing more compile errors on arches that I hadn't tested on yetkcbanner