aboutsummaryrefslogtreecommitdiff
path: root/lib/std/debug
AgeCommit message (Collapse)Author
2025-02-06adjust runtime page size APIsAndrew Kelley
* fix merge conflicts * rename the declarations * reword documentation * extract FixedBufferAllocator to separate file * take advantage of locals * remove the assertion about max alignment in Allocator API, leaving it Allocator implementation defined * fix non-inline function call in start logic The GeneralPurposeAllocator implementation is totally broken because it uses global state but I didn't address that in this commit.
2025-02-06runtime page size detectionArchbirdplus
heap.zig: define new default page sizes heap.zig: add min/max_page_size and their options lib/std/c: add miscellaneous declarations heap.zig: add pageSize() and its options switch to new page sizes, especially in GPA/stdlib mem.zig: remove page_size
2025-02-01debug: fix MemoryAccessor file leakMichael Dusan
- patch authored by Jacob Young - tested on alpine-aarch64, 3.21.0, qemu-system 9.2.0 - issue manifested on Alpine Linux aarch64 under qemu-system where zig2 fails during bootstrap: error.ProcessFdQuotaExceeded
2025-01-24std: remove old declarations now a zig1 update has happenedmlugg
2025-01-24all: update for `panic.unwrapError` and `panic.call` signature changesmlugg
2025-01-24compiler: yet more panic handler changesmlugg
* `std.builtin.Panic` -> `std.builtin.panic`, because it is a namespace. * `root.Panic` -> `root.panic` for the same reason. There are type checks so that we still allow the legacy `pub fn panic` strategy in the 0.14.0 release. * `std.debug.SimplePanic` -> `std.debug.simple_panic`, same reason. * `std.debug.NoPanic` -> `std.debug.no_panic`, same reason. * `std.debug.FormattedPanic` is now a function `std.debug.FullPanic` which takes as input a `panicFn` and returns a namespace with all the panic functions. This handles the incredibly common case of just wanting to override how the message is printed, whilst keeping nice formatted panics. * Remove `std.builtin.panic.messages`; now, every safety panic has its own function. This reduces binary bloat, as calls to these functions no longer need to prepare any arguments (aside from the error return trace). * Remove some legacy declarations, since a zig1.wasm update has happened. Most of these were related to the panic handler, but a quick grep for "zig1" brought up a couple more results too. Also, add some missing type checks to Sema. Resolves: #22584 formatted -> full
2025-01-23std.debug: Fall back to .eh_frame/.debug_frame if .eh_frame_hdr is incomplete.Alex Rønne Petersen
When using the self-hosted backends, especially in incremental mode, the .eh_frame_hdr section may be incomplete, so we can't treat it as authoritative. Instead, if we started out intending to use .eh_frame_hdr but find that it's incomplete, load .eh_frame/.debug_frame on demand and use that info going forward.
2025-01-18debug: fix `std.debug.NoPanic` compile errorsJacob Young
2025-01-16x86_64: implement union accessJacob Young
2025-01-16x86_64: implement switch jump tablesJacob Young
2024-11-29defaultPanic: @trap on 'other' targetPat Tullmann
The freestanding and other OS targets by default need to just @trap in the default Panic implementation. And `isValidMemory` won't work with freestanding or other targets. Update the unwind_freestanding.zig test case to also run on the 'other' OS target, too. This should keep the Zig's stacktrace generation from regressing on the standalone targets.
2024-11-20std.debug: Gracefully handle process_vm_readv() EPERM in MemoryAccessor.read().Alex Rønne Petersen
Closes #21815.
2024-11-04std.debug: Add handling for armeb, thumb, thumbeb, and aarch64_be.Alex Rønne Petersen
2024-10-29std.debug: watchOS: fixes for ilp32 ABI (#21765)Mario Nachbaur
Xcode requires target arm64_32 (aarch64-watchos-ilp32) in order to build code for Apple Watches. This commit fixes compilation errors that appear when compiling with that target.
2024-10-21watchOS: add os to aarch64 architectureMario Nachbaur
Needed for creating libraries that run both on physical Apple Watches and the watchOS simulator.
2024-09-26update safety test cases to new panic APIAndrew Kelley
although they would also pass simply reverted to master branch because I made the deprecated API still work for now (to be removed after 0.14.0 is tagged)
2024-09-26embrace panic helpersAndrew Kelley
Introduces `std.builtin.Panic` which is a complete interface for panicking. Provide `std.debug.FormattedPanic` and `std.debug.SimplePanic` and let the user choose, or make their own.
2024-09-16std: Restore conventional `compareFn` behavior for `binarySearch`Jay Petacat
PR #20927 made some improvements to the `binarySearch` API, but one change I found surprising was the relationship between the left-hand and right-hand parameters of `compareFn` was inverted. This is different from how comparison functions typically behave, both in other parts of Zig (e.g. `std.math.order`) and in other languages (e.g. C's `bsearch`). Unless a strong reason can be identified and documented for doing otherwise, I think it'll be better to stick with convention. While writing this patch and changing things back to the way they were, the predicates of `lowerBound` and `upperBound` seemed to be the only areas that benefited from the inversion. I don't think that benefit is worth the cost, personally. Calling `Order.invert()` in the predicates accomplishes the same goal.
2024-09-12Replace deprecated default initializations with decl literalsLinus Groh
2024-08-29std.pdb: obey naming conventionsmlugg
These names aren't matching any formal specification; they're mostly just ripped from LLVM code. Therefore, we should definitely follow Zig naming conventions here.
2024-08-29std: avoid field/decl name conflictsmlugg
Most of these changes seem like improvements. The PDB thing had a TODO saying it used to crash; I anticipate it works now, we'll see what CI does. The `std.os.uefi` field renames are a notable breaking change.
2024-08-28Merge pull request #21230 from jacobly0/stack-traceJacob Young
Dwarf: fix self-hosted stack traces
2024-08-28Dwarf: fix parsing self-hosted debug info for stack tracesJacob Young
2024-08-28std: update `std.builtin.Type` fields to follow naming conventionsmlugg
The compiler actually doesn't need any functional changes for this: Sema does reification based on the tag indices of `std.builtin.Type` already! So, no zig1.wasm update is necessary. This change is necessary to disallow name clashes between fields and decls on a type, which is a prerequisite of #9938.
2024-08-19Fix handling of empty XDG environment variablesIan Johnson
Closes #21132 According to the XDG Base Directory specification (https://specifications.freedesktop.org/basedir-spec/latest/#variables), empty values for these environment variables should be treated the same as if they are unset. Specifically, for the instances changed in this commit, > $XDG_DATA_HOME defines the base directory relative to which > user-specific data files should be stored. If $XDG_DATA_HOME is either > not set **or empty**, a default equal to $HOME/.local/share should be > used. and > $XDG_CACHE_HOME defines the base directory relative to which > user-specific non-essential data files should be stored. If > $XDG_CACHE_HOME is either not set **or empty**, a default equal to > $HOME/.cache should be used. (emphasis mine) In addition to the case mentioned in the linked issue, all other uses of XDG environment variables were corrected.
2024-08-13std.debug.Coverage.resolveAddressesDwarf: assert sortedAndrew Kelley
2024-08-13std.debug.Dwarf: better source location informationAndrew Kelley
Two fixes here: Sort by addresses after generating the line table. Debug information in the wild is not sorted and the rest of the implementation requires this data to be sorted. Handle DW.LNE.end_sequence correctly. When I originally wrote this code, I misunderstood what this opcode was supposed to do. Now I understand that it marks the *end* of an address range, meaning the current address does *not* map to the current line information. This fixes source location information for a big chunk of ReleaseSafe code.
2024-08-13avoid a branch in resolveAddressesDwarfAndrew Kelley
2024-08-13std.debug.Coverage.resolveAddressesDwarf: fix broken logicAndrew Kelley
The implementation assumed that compilation units did not overlap, which is not the case. The new implementation uses .debug_ranges to iterate over the requested PCs. This partially resolves #20990. The dump-cov tool is fixed but the same fix needs to be applied to `std.Build.Fuzz.WebServer` (sorting the PC list before passing it to be resolved by debug info). I am observing LLVM emit multiple 8-bit counters for the same PC addresses when enabling `-fsanitize-coverage=inline-8bit-counters`. This seems like a bug in LLVM. I can't fathom why that would be desireable.
2024-08-08std.debug.Dwarf: try to load the debuginfo from the debuginfod cache.Xavier Bouchoux
The previous mecanism for linux distributions to delivers debug info into `/usr/lib/debug` no longer seems in use. the current mecanism often is using `debuginfod` (https://sourceware.org/elfutils/Debuginfod.html) This commit only tries to load already available debuginfo but does not try to make any download requests. the user can manually run `debuginfod-find debuginfo PATH` to populate the cache.
2024-08-08std.debug.Dwarf: fix loading external debuginfo in the ".debuglink" case.Xavier Bouchoux
- look up the debuglink file in the directory of the executable file (instead of the cwd) - fix parsing of debuglink section (the 4-byte alignement is within the file, unrelated to the in-memory address)
2024-08-07std.debug: fix compile errors on windows and macosAndrew Kelley
2024-08-07update branch for latest std.sort changesAndrew Kelley
2024-08-07std.debug.Coverage: use extern structsAndrew Kelley
helps the serialization use case
2024-08-07fuzzing: progress towards web UIAndrew Kelley
* libfuzzer: close file after mmap * fuzzer/main.js: connect with EventSource and debug dump the messages. currently this prints how many fuzzer runs have been attempted to console.log. * extract some `std.debug.Info` logic into `std.debug.Coverage`. Prepares for consolidation across multiple different executables which share source files, and makes it possible to send all the PC/SourceLocation mapping data with 4 memcpy'd arrays. * std.Build.Fuzz: - spawn a thread to watch the message queue and signal event subscribers. - track coverage map data - respond to /events URL with EventSource messages on a timer
2024-08-07std.debug.Info.resolveSourceLocations: O(N) implementationAndrew Kelley
2024-08-07std.Debug.Info: remove std.Progress integrationAndrew Kelley
it's too fast to need it now
2024-08-07std.debug.Dwarf: precompute .debug_line tableAndrew Kelley
yields a 60x speedup for resolveSourceLocations in debug builds
2024-08-07std.debug.FixedBufferReader is fineAndrew Kelley
it does not need to be deprecated
2024-08-07code coverage dumping tool basic implementationAndrew Kelley
* std.debug.Dwarf: add `sortCompileUnits` along with a field to track the state for the purpose of assertions and correct API usage. This makes batch lookups faster. - in the future, findCompileUnit should be enhanced to rely on sorted compile units as well. * implement `std.debug.Dwarf.resolveSourceLocations` as well as `std.debug.Info.resolveSourceLocations`. It's still pretty slow, since it calls getLineNumberInfo for each array element, repeating a lot of work unnecessarily. * integrate these APIs with `std.Progress` to understand what is taking so long. The output I'm seeing from this tool shows a lot of missing source locations. In particular, the main area of interest is missing for my tokenizer fuzzing example.
2024-08-07introduce tool for dumping coverage fileAndrew Kelley
with debug info resolved. begin efforts of providing `std.debug.Info`, a cross-platform abstraction for loading debug information into an in-memory format that supports queries such as "what is the source location of this virtual memory address?" Unlike `std.debug.SelfInfo`, this API does not assume the debug information in question happens to match the host CPU architecture, OS, or other target properties.
2024-08-04std.sort: Remove key argument from binary-search-like functions (#20927)Fri3dNstuff
closes #20110
2024-08-02reintroduce std.Dwarf.abi.supportsUnwindingAndrew Kelley
There are two concepts here: one for whether dwarf supports unwinding on that target, and another for whether the Zig standard library implements it yet.
2024-08-02fix compilation on powerpc GNU systemsAndrew Kelley
...which have a ucontext_t but not a PC register. The current stack unwinding implementation does not yet support this architecture. Also fix name of `std.debug.SelfInfo.openSelf` to remove redundancy. Also removed this hook into root providing an "openSelfDebugInfo" function. Sorry, this debugging code is not of sufficient quality to offer a plugin API right now.
2024-08-01std.debug: reorg and clarify API goalsAndrew Kelley
After this commit: `std.debug.SelfInfo` is a cross-platform abstraction for the current executable's own debug information, with a goal of minimal code bloat and compilation speed penalty. `std.debug.Dwarf` does not assume the current executable is itself the thing being debugged, however, it does assume the debug info has the same CPU architecture and OS as the current executable. It is planned to remove this limitation.
2024-08-01std.debug: rename Info to SelfInfoAndrew Kelley
This code has the hard-coded goal of supporting the executable's own debug information and makes design choices along that goal, such as memory-mapping the inputs, using dl_iterate_phdr, and doing conditional compilation on the host target. A more general-purpose implementation of debug information may be able to share code with this, but there are some fundamental incompatibilities. For example, the "SelfInfo" implementation wants to avoid bloating the binary with PDB on POSIX systems, and likewise DWARF on Windows systems, while a general-purpose implementation needs to support both PDB and DWARF from the same binary. It might, for example, inspect the debug information from a cross-compiled binary. `SourceLocation` now lives at `std.debug.SourceLocation` and is documented. Deprecate `std.debug.runtime_safety` because it returns the optimization mode of the standard library, when the caller probably wants to use the optimization mode of their own module. `std.pdb.Pdb` is moved to `std.debug.Pdb`, mirroring the recent extraction of `std.debug.Dwarf` from `std.dwarf`. I have no idea why we have both Module (with a Windows-specific definition) and WindowsModule. I left some passive aggressive doc comments to express my frustration.
2024-08-01std.debug.Info: rename ModuleDebugInfo to ModuleAndrew Kelley
2024-08-01std.debug.Info: extract to separate fileAndrew Kelley
2024-08-01std: dwarf namespace reorgAndrew Kelley
std.debug.Dwarf is the parsing/decoding logic. std.dwarf remains the unopinionated types and bits alone. If you look at this diff you can see a lot less redundancy in namespaces.
2020-11-16Move leb128 and remove trivial *mem functions as discussed in #5588 (#6876)tgschultz
* Move leb128 out of debug and remove trivial *mem functions as discussed in #5588 * Turns out one of the *Mem functions was used by MachO. Replaced with trivial use of FixedBufferStream.