aboutsummaryrefslogtreecommitdiff
path: root/lib/std/debug.zig
AgeCommit message (Collapse)Author
2025-04-30posix: remove empty_sigsetPat Tullmann
When linking a libc, Zig should defer to the C library for sigset operations. The pre-filled constants signal sets (empty_sigset, filled_sigset) are not compatible with C library initialization, so remove them and use the runtime `sigemptyset` and `sigfillset` methods to initialize any sigset.
2025-04-27make `@memcpy` and `@memmove` share panic handlersAndrew Kelley
2025-04-26compiler: add @memmove builtindweiller
2025-04-01std.os.uefi.protocol: ziggify function signatures (#23214)Carmen
2025-03-25Fix std.debug.dumpHex address offsetsArnau Camprubí
2025-03-23Lower `@returnAddress` to a constant 0 in Emscripten release buildsCarl Åstholm
Emscripten currently implements `emscripten_return_address()` by calling out into JavaScript and parsing a stack trace, which introduces significant overhead that we would prefer to avoid in release builds. This is especially problematic for allocators because the generic parts of `std.mem.Allocator` make frequent use of `@returnAddress`, even though very few allocator implementations even observe the return address, which makes allocators nigh unusable for performance-critical applications like games if the compiler is unable to devirtualize the allocator calls.
2025-02-23Sema: allow `@ptrCast` of slices changing the lengthmlugg
Also, refactor `Sema.ptrCastFull` to not be a horrifying hellscape.
2025-02-17std.Target: Remove functions that just wrap component functions.Alex Rønne Petersen
Functions like isMinGW() and isGnuLibC() have a good reason to exist: They look at multiple components of the target. But functions like isWasm(), isDarwin(), isGnu(), etc only exist to save 4-8 characters. I don't think this is a good enough reason to keep them, especially given that: * It's not immediately obvious to a reader whether target.isDarwin() means the same thing as target.os.tag.isDarwin() precisely because isMinGW() and similar functions *do* look at multiple components. * It's not clear where we would draw the line. The logical conclusion before this commit would be to also wrap Arch.isX86(), Os.Tag.isSolarish(), Abi.isOpenHarmony(), etc... this obviously quickly gets out of hand. * It's nice to just have a single correct way of doing something.
2025-02-09std.os.uefi: Adjust casing of remaining enum fieldsLinus Groh
Work towards #2101.
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-22std.debug: remove `errorReturnTraceHelper`mlugg
This function doesn't do what it says; it's a nop.
2025-01-21std.debug: fix format on ConfigurableTraceandrewkraevskii
2025-01-16x86_64: implement union accessJacob Young
2025-01-16x86_64: implement switch jump tablesJacob Young
2025-01-16all: update to `std.builtin.Type.Pointer.Size` field renamesmlugg
This was done by regex substitution with `sed`. I then manually went over the entire diff and fixed any incorrect changes. This diff also changes a lot of `callconv(.C)` to `callconv(.c)`, since my regex happened to also trigger here. I opted to leave these changes in, since they *are* a correct migration, even if they're not the one I was trying to do!
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-22add assertLocked to std.debug.SafetyLockScott Redig
2024-11-04std.debug: Add handling for armeb, thumb, thumbeb, and aarch64_be.Alex Rønne Petersen
2024-11-02std.os.windows: Deprecate WINAPI in favor of CallingConvention.winapi.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-07std.debug: Fix defaultPanic() uefi buildLinus Groh
lib/std/debug.zig:491:38: error: slice of non-array type 'u16' utf16_buffer[len_minus_3][0..3].* = .{ '\r', '\n', 0 }; ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ lib/std/debug.zig:510:70: error: expected type '?*const anyopaque', found '[]u16' _ = bs.exit(uefi.handle, .Aborted, exit_msg.len + 1, exit_data); ^~~~~~~~~ Regressed in #21520.
2024-10-03std.debug: Disable stack traces on s390x.Alex Rønne Petersen
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-26work around riscv64 backend deficienciesAndrew Kelley
2024-09-26reintroduce the std.builtin safety panic helpersAndrew Kelley
motivated by performance
2024-09-26fixes for this branchAndrew Kelley
I had to bring back some of the old API so that I could compile the new compiler with an old compiler.
2024-09-26remove formatted panicsAndrew Kelley
implements #17969
2024-09-01std: make debug.dumpStackPointerAddr compileNico Elbers
Very simply add the format specifier to the print statement. Since debug.print is hard coded I couldn't come up with a reasonalble way to add a test, and since this function is simple enough I doubt it's useful. fixes one part of #21094
2024-08-31Merge pull request #21173 from mrjbq7/writeStackTraceAndrew Kelley
std.debug: remove allocator from std.debug.writeStackTrace()
2024-08-30Merge pull request #21174 from alexrp/win-armAndrew Kelley
Change `arm-windows-gnu` to `thumb-windows-gnu`, plus some initial port work
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-28std.debug: Fix a bitness portability issue in walkStackWindows().Alex Rønne Petersen
2024-08-27compiler,lib,test,langref: migrate `@setCold` to `@branchHint`mlugg
2024-08-22std.debug: remove allocator from std.debug.writeStackTrace()John Benediktsson
2024-08-18std.debug: Also disable stack traces on mips64.Alex Rønne Petersen
2024-08-16std: disable failing debug info test for self-hostedJacob Young
2024-08-13std.debug: Support sparc32 in StackIterator.init().Alex Rønne Petersen
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.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-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.