aboutsummaryrefslogtreecommitdiff
path: root/lib/std/debug.zig
AgeCommit message (Collapse)Author
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.
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: 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.
2024-08-01std.debug.DebugInfo: rename to std.debug.InfoAndrew Kelley
avoiding redundancy in the fully qualified namespace
2024-07-29std: Stop supporting Linux/glibc versions older than declared in std.Target.Alex Rønne Petersen
2024-07-24Replace some dynamic functions with static ones.Lucas Santos
PR [19271](https://github.com/ziglang/zig/pull/19271) added some static function implementations from kernel32, but some parts of the library still used the dynamically loaded versions.
2024-07-23Merge pull request #20706 from alexrp/sigaction-nosysAndrew Kelley
`std.posix`: Make `sigaction()` infallible
2024-07-22debug: correct dump_hex and dump_hex_fallible casing (#19296)Wooster
#1097 is closed.
2024-07-21std.posix: Consider invalid signal numbers to sigaction() to be programmer ↵Alex Rønne Petersen
error. The set of signals that cannot have their action changed is documented in POSIX, and any additional, non-standard signals are documented by the specific OS. I see no valid reason why EINVAL should be considered an unpredictable error here.
2024-07-21Revert "Merge pull request #20380 from tau-dev/master"Andrew Kelley
This reverts commit 397be0c9cc8156d38d1487a4c80210007033cbd0, reversing changes made to 18d412ab2fb7bda92f7bfbdf732849bbcd066c33. Caused test failures in master branch.
2024-07-21Merge pull request #20380 from tau-dev/masterAndrew Kelley
llvm: Nest debug info correctly
2024-07-19ModuleDebugInfo: Discard C++ namespaces appearing in PDBsTau
2024-07-19std.c reorganizationAndrew Kelley
It is now composed of these main sections: * Declarations that are shared among all operating systems. * Declarations that have the same name, but different type signatures depending on the operating system. Often multiple operating systems share the same type signatures however. * Declarations that are specific to a single operating system. - These are imported one per line so you can see where they come from, protected by a comptime block to prevent accessing the wrong one. Closes #19352 by changing the convention to making types `void` and functions `{}`, so that it becomes possible to update `@hasDecl` sites to use `@TypeOf(f) != void` or `T != void`. Happily, this ended up removing some duplicate logic and update some bitrotted feature detection checks. A handful of types have been modified to gain namespacing and type safety. This is a breaking change. Oh, and the last usage of `usingnamespace` site is eliminated.
2024-07-17Windows: Rework kernel32 apisStephen Gregoratto
To facilitate #1840, this commit slims `std.windows.kernel32` to only have the functions needed by the standard library. Since this will break projects that relied on these, I offer two solutions: - Make an argument as to why certain functions should be added back in. Note that they may just be wrappers around `ntdll` APIs, which would go against #1840. If necessary I'll add them back in *and* make wrappers in `std.windows` for it. - Maintain your own list of APIs. This is the option taken by bun[1], where they wrap functions with tracing. - Use `zigwin32`. I've also added TODO comments that specify which functions can be reimplemented using `ntdll` APIs in the future. Other changes: - Group functions into groups (I/O, process management etc.). - Synchronize definitions against Microsoft documentation to use the proper parameter types/names. - Break all functions with parameters over multiple lines.
2024-07-15Better implementation of GetLastError. (#20623)Lucas Santos
Instead of calling the dynamically loaded kernel32.GetLastError, we can extract it from the TEB. As shown by [Wine](https://github.com/wine-mirror/wine/blob/34b1606019982b71818780bc84b76460f650af31/include/winternl.h#L439), the last error lives at offset 0x34 of the TEB in 32-bit Windows and at offset 0x68 in 64-bit Windows.
2024-07-10dwarf: use StackIterator.MemoryAccessor to check memory accesses instead of ↵kcbanner
isValidMemory
2024-07-09debug: prevent segfaults on linuxJacob Young
2024-07-04add std.debug.assertReadableAndrew Kelley
Useful when trying to figure out whether a slice is valid memory.
2024-06-13std: Convert deprecated aliases to compile errors and fix usagesRyan Liptak
Deprecated aliases that are now compile errors: - `std.fs.MAX_PATH_BYTES` (renamed to `std.fs.max_path_bytes`) - `std.mem.tokenize` (split into `tokenizeAny`, `tokenizeSequence`, `tokenizeScalar`) - `std.mem.split` (split into `splitSequence`, `splitAny`, `splitScalar`) - `std.mem.splitBackwards` (split into `splitBackwardsSequence`, `splitBackwardsAny`, `splitBackwardsScalar`) - `std.unicode` + `utf16leToUtf8Alloc`, `utf16leToUtf8AllocZ`, `utf16leToUtf8`, `fmtUtf16le` (all renamed to have capitalized `Le`) + `utf8ToUtf16LeWithNull` (renamed to `utf8ToUtf16LeAllocZ`) - `std.zig.CrossTarget` (moved to `std.Target.Query`) Deprecated `lib/std/std.zig` decls were deleted instead of made a `@compileError` because the `refAllDecls` in the test block would trigger the `@compileError`. The deleted top-level `std` namespaces are: - `std.rand` (renamed to `std.Random`) - `std.TailQueue` (renamed to `std.DoublyLinkedList`) - `std.ChildProcess` (renamed/moved to `std.process.Child`) This is not exhaustive. Deprecated aliases that I didn't touch: + `std.io.*` + `std.Build.*` + `std.builtin.Mode` + `std.zig.c_translation.CIntLiteralRadix` + anything in `src/`
2024-06-12std.debug: lock stderr mutex when panickingAndrew Kelley
The doc comments for this global said: "Locked to avoid interleaving panic messages from multiple threads." Huh? There's already a mutex for that, it's the stderr mutex. Lock that one instead.
2024-05-31not android check on std.debug.getContextGeorge Thayamkery
have_getcontext must be false for android, this makes sure that std.debug.getContext wont call the non-existant function (and thus hit a compileError)
2024-05-29rename zig-cache to .zig-cacheAndrew Kelley
closes #20077