2024-08-01 14:18:16 -07:00
|
|
|
|
2025-10-19 14:08:21 -07:00
|
|
|
|
|
|
|
|
|
2017-10-31 04:47:55 -04:00
|
|
|
|
|
|
|
|
|
2024-03-18 22:39:59 -07:00
|
|
|
|
2019-05-26 13:17:34 -04:00
|
|
|
|
2022-01-22 22:52:27 +01:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-12-06 17:23:07 -08:00
|
|
|
|
2019-05-26 13:17:34 -04:00
|
|
|
|
2016-08-17 20:11:04 -07:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-05 21:28:18 +01:00
|
|
|
|
|
|
|
|
|
2024-08-01 13:40:47 -07:00
|
|
|
|
std.debug: rename Info to SelfInfo
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-01 16:31:03 -07:00
|
|
|
|
2025-09-09 14:20:49 +01:00
|
|
|
|
2025-11-19 12:01:49 +00:00
|
|
|
|
2024-08-02 16:31:49 -07:00
|
|
|
|
2024-08-04 00:16:28 -07:00
|
|
|
|
std: rework/remove ucontext_t
Our usage of `ucontext_t` in the standard library was kind of
problematic. We unnecessarily mimiced libc-specific structures, and our
`getcontext` implementation was overkill for our use case of stack
tracing.
This commit introduces a new namespace, `std.debug.cpu_context`, which
contains "context" types for various architectures (currently x86,
x86_64, ARM, and AARCH64) containing the general-purpose CPU registers;
the ones needed in practice for stack unwinding. Each implementation has
a function `current` which populates the structure using inline
assembly. The structure is user-overrideable, though that should only be
necessary if the standard library does not have an implementation for
the *architecture*: that is to say, none of this is OS-dependent.
Of course, in POSIX signal handlers, we get a `ucontext_t` from the
kernel. The function `std.debug.cpu_context.fromPosixSignalContext`
converts this to a `std.debug.cpu_context.Native` with a big ol' target
switch.
This functionality is not exposed from `std.c` or `std.posix`, and
neither are `ucontext_t`, `mcontext_t`, or `getcontext`. The rationale
is that these types and functions do not conform to a specific ABI, and
in fact tend to get updated over time based on CPU features and
extensions; in addition, different libcs use different structures which
are "partially compatible" with the kernel structure. Overall, it's a
mess, but all we need is the kernel context, so we can just define a
kernel-compatible structure as long as we don't claim C compatibility by
putting it in `std.c` or `std.posix`.
This change resulted in a few nice `std.debug` simplifications, but
nothing too noteworthy. However, the main benefit of this change is that
DWARF unwinding---sometimes necessary for collecting stack traces
reliably---now requires far less target-specific integration.
Also fix a bug I noticed in `PageAllocator` (I found this due to a bug
in my distro's QEMU distribution; thanks, broken QEMU patch!) and I
think a couple of minor bugs in `std.debug`.
Resolves: #23801
Resolves: #23802
2025-09-17 18:38:11 +01:00
|
|
|
|
2024-08-01 13:40:47 -07:00
|
|
|
|
2025-09-30 11:06:21 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-02-06 04:36:32 -05:00
|
|
|
|
2025-09-30 11:06:21 +01:00
|
|
|
|
2026-04-12 14:50:34 -07:00
|
|
|
|
2026-04-13 00:43:34 -07:00
|
|
|
|
2025-09-30 11:06:21 +01:00
|
|
|
|
2026-02-06 04:36:32 -05:00
|
|
|
|
|
|
|
|
|
2025-09-30 11:06:21 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-02-06 04:36:32 -05:00
|
|
|
|
|
|
|
|
|
2025-09-30 11:06:21 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-02-06 04:36:32 -05:00
|
|
|
|
2025-09-30 11:06:21 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-06-05 08:35:05 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-08-24 15:37:09 -07:00
|
|
|
|
|
|
|
|
|
2026-06-05 08:35:05 +09:00
|
|
|
|
|
|
|
|
|
2025-09-30 11:06:21 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-08 20:35:34 -07:00
|
|
|
|
2025-09-30 11:06:21 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-24 04:20:55 +00:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-24 04:20:55 +00:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-24 04:20:55 +00:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
2025-01-24 04:20:55 +00:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-24 04:20:55 +00:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-24 04:20:55 +00:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-24 04:20:55 +00:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-02-01 07:37:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
|
|
|
|
|
2025-01-24 04:20:55 +00:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-24 04:20:55 +00:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-24 04:20:55 +00:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-24 04:20:55 +00:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-24 04:20:55 +00:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
2026-05-19 17:01:54 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-06-01 07:41:24 +01:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
2025-06-01 07:41:24 +01:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-24 04:20:55 +00:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-24 04:20:55 +00:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-24 04:20:55 +00:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-24 04:20:55 +00:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-24 04:20:55 +00:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-24 04:20:55 +00:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-24 04:20:55 +00:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-24 04:20:55 +00:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-24 04:20:55 +00:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-24 04:20:55 +00:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
2025-04-27 12:17:59 -07:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
2025-04-27 12:17:59 -07:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-24 04:20:55 +00:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-24 04:20:55 +00:00
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
Sema: make loading uninstantiable types a runtime safety panic
For generic code, it is far more useful to consider this equivalent to
`unreachable`. Meanwhile, it is difficult to accidentally write concrete
code which performs this operation, so very little is actually lost from
not having a compile error.
If we accept that this operation does not trigger a compile error, then
it already has the potential to invoke Illegal Behavior today, because
uninstantiable types have an unspecified size in memory, so the
dereference always potentially exceeds the pointer's provenance. (That
said, this only means it is *possible* for the operation to invoke IB,
so the langspec should nonetheless explicitly specify that dereferencing
a pointer to an uninstantiable type is itself Illegal Behavior.)
Storing uninstantiable types into memory does not require any specific
language rules, because that operation can never be reached anyway due
to it requiring an operand (the RHS of `a = b`) whose type is the store
type, which is (by definition) impossible for uninstantiable types.
Resolves: https://codeberg.org/ziglang/zig/issues/36247
2026-07-21 11:02:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-24 02:19:28 +00:00
|
|
|
|
|
|
|
|
|
2024-09-26 14:24:18 -07:00
|
|
|
|
std.debug: rename Info to SelfInfo
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-01 16:31:03 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-02 17:45:31 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std.debug: rename Info to SelfInfo
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-01 16:31:03 -07:00
|
|
|
|
|
|
|
|
|
2024-08-02 16:31:49 -07:00
|
|
|
|
2025-09-02 15:54:36 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-02 16:31:49 -07:00
|
|
|
|
|
|
|
|
|
2026-07-19 21:28:40 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-07-05 15:09:02 -04:00
|
|
|
|
2025-09-17 23:30:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-06-25 21:27:56 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-03-23 13:12:45 +01:00
|
|
|
|
|
|
|
|
|
2022-06-25 21:27:56 -07:00
|
|
|
|
|
|
|
|
|
2026-07-19 17:22:10 -07:00
|
|
|
|
2022-06-25 21:27:56 -07:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2022-06-25 21:27:56 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-05-06 16:03:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-06-25 21:27:56 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-06-27 20:05:22 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-08 14:31:45 +01:00
|
|
|
|
2025-12-09 18:44:39 -08:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-12-09 18:44:39 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
|
|
|
|
|
2025-12-17 17:00:41 -08:00
|
|
|
|
2025-12-22 16:10:43 -08:00
|
|
|
|
2025-12-22 15:13:48 -08:00
|
|
|
|
|
|
|
|
|
2025-12-22 14:37:41 -08:00
|
|
|
|
2025-12-22 15:13:48 -08:00
|
|
|
|
2025-12-17 17:00:41 -08:00
|
|
|
|
2025-06-27 20:05:22 -07:00
|
|
|
|
|
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-12-22 16:10:43 -08:00
|
|
|
|
2025-12-22 14:37:41 -08:00
|
|
|
|
2025-06-27 20:05:22 -07:00
|
|
|
|
|
|
|
|
|
2025-12-09 18:44:39 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-10 12:58:47 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-09 18:44:39 -08:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-12-09 18:44:39 -08:00
|
|
|
|
2020-07-11 14:09:04 +03:00
|
|
|
|
2026-06-07 12:21:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-22 15:14:59 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-09 22:10:12 -08:00
|
|
|
|
2025-12-09 18:44:39 -08:00
|
|
|
|
2025-09-01 16:50:39 +01:00
|
|
|
|
|
|
|
|
|
2025-09-30 11:06:21 +01:00
|
|
|
|
2025-09-01 16:50:39 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-01-15 16:26:13 -05:00
|
|
|
|
|
|
|
|
|
2023-08-03 09:02:24 +02:00
|
|
|
|
2024-01-08 00:21:57 -07:00
|
|
|
|
2024-07-22 09:00:08 +09:00
|
|
|
|
2026-06-07 12:21:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-17 17:00:41 -08:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
|
|
|
|
|
2023-08-03 09:02:24 +02:00
|
|
|
|
|
|
|
|
|
2025-06-27 20:05:22 -07:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
|
|
|
|
|
2023-08-03 09:02:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-07-06 12:52:19 +02:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2023-08-03 09:02:24 +02:00
|
|
|
|
|
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
|
|
|
|
|
2023-08-03 09:02:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
|
|
|
|
|
2023-08-03 09:02:24 +02:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2023-08-03 09:02:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2023-08-03 09:02:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2023-08-03 09:02:24 +02:00
|
|
|
|
2024-01-08 00:21:57 -07:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
|
|
|
|
|
2023-08-03 09:02:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-08-03 09:02:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2023-08-03 09:02:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-06-27 20:05:22 -07:00
|
|
|
|
2025-12-18 22:03:10 -08:00
|
|
|
|
2025-03-25 23:20:56 +01:00
|
|
|
|
2025-12-18 22:03:10 -08:00
|
|
|
|
2025-06-27 20:05:22 -07:00
|
|
|
|
|
|
|
|
|
2025-12-18 22:03:10 -08:00
|
|
|
|
|
|
|
|
|
2025-03-25 23:20:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-18 22:03:10 -08:00
|
|
|
|
2025-12-09 22:10:12 -08:00
|
|
|
|
2025-03-25 23:20:56 +01:00
|
|
|
|
|
|
|
|
|
std: rework/remove ucontext_t
Our usage of `ucontext_t` in the standard library was kind of
problematic. We unnecessarily mimiced libc-specific structures, and our
`getcontext` implementation was overkill for our use case of stack
tracing.
This commit introduces a new namespace, `std.debug.cpu_context`, which
contains "context" types for various architectures (currently x86,
x86_64, ARM, and AARCH64) containing the general-purpose CPU registers;
the ones needed in practice for stack unwinding. Each implementation has
a function `current` which populates the structure using inline
assembly. The structure is user-overrideable, though that should only be
necessary if the standard library does not have an implementation for
the *architecture*: that is to say, none of this is OS-dependent.
Of course, in POSIX signal handlers, we get a `ucontext_t` from the
kernel. The function `std.debug.cpu_context.fromPosixSignalContext`
converts this to a `std.debug.cpu_context.Native` with a big ol' target
switch.
This functionality is not exposed from `std.c` or `std.posix`, and
neither are `ucontext_t`, `mcontext_t`, or `getcontext`. The rationale
is that these types and functions do not conform to a specific ABI, and
in fact tend to get updated over time based on CPU features and
extensions; in addition, different libcs use different structures which
are "partially compatible" with the kernel structure. Overall, it's a
mess, but all we need is the kernel context, so we can just define a
kernel-compatible structure as long as we don't claim C compatibility by
putting it in `std.c` or `std.posix`.
This change resulted in a few nice `std.debug` simplifications, but
nothing too noteworthy. However, the main benefit of this change is that
DWARF unwinding---sometimes necessary for collecting stack traces
reliably---now requires far less target-specific integration.
Also fix a bug I noticed in `PageAllocator` (I found this due to a bug
in my distro's QEMU distribution; thanks, broken QEMU patch!) and I
think a couple of minor bugs in `std.debug`.
Resolves: #23801
Resolves: #23802
2025-09-17 18:38:11 +01:00
|
|
|
|
|
|
|
|
|
2023-07-09 14:45:34 -04:00
|
|
|
|
2024-07-03 13:28:21 -07:00
|
|
|
|
|
|
|
|
|
2026-07-19 17:22:10 -07:00
|
|
|
|
2017-10-31 04:47:55 -04:00
|
|
|
|
2024-07-03 13:28:21 -07:00
|
|
|
|
2026-07-19 17:22:10 -07:00
|
|
|
|
2024-07-03 13:28:21 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-09 22:10:12 -08:00
|
|
|
|
2024-07-03 13:28:21 -07:00
|
|
|
|
2026-07-19 17:22:10 -07:00
|
|
|
|
2019-02-08 18:18:47 -05:00
|
|
|
|
2018-01-25 04:10:11 -05:00
|
|
|
|
rework fuzz testing to be smith based
-- On the standard library side:
The `input: []const u8` parameter of functions passed to `testing.fuzz`
has changed to `smith: *testing.Smith`. `Smith` is used to generate
values from libfuzzer or input bytes generated by libfuzzer.
`Smith` contains the following base methods:
* `value` as a generic method for generating any type
* `eos` for generating end-of-stream markers. Provides the additional
guarantee `true` will eventually by provided.
* `bytes` for filling a byte array.
* `slice` for filling part of a buffer and providing the length.
`Smith.Weight` is used for giving value ranges a higher probability of
being selected. By default, every value has a weight of zero (i.e. they
will not be selected). Weights can only apply to values that fit within
a u64. The above functions have corresponding ones that accept weights.
Additionally, the following functions are provided:
* `baselineWeights` which provides a set of weights containing every
possible value of a type.
* `eosSimpleWeighted` for unique weights for `true` and `false`
* `valueRangeAtMost` and `valueRangeLessThan` for weighing only a range
of values.
-- On the libfuzzer and abi side:
--- Uids
These are u32s which are used to classify requested values. This solves
the problem of a mutation causing a new value to be requested and
shifting all future values; for example:
1. An initial input contains the values 1, 2, 3 which are interpreted
as a, b, and c respectively by the test.
2. The 1 is mutated to a 4 which causes the test to request an extra
value interpreted as d. The input is now 4, 2, 3, 5 (new value) which
the test corresponds to a, d, b, c; however, b and c no longer
correspond to their original values.
Uids contain a hash component and type component. The hash component
is currently determined in `Smith` by taking a hash of the calling
`@returnAddress()` or via an argument in the corresponding `WithHash`
functions. The type component is used extensively in libfuzzer with its
hashmaps.
--- Mutations
At the start of a cycle (a run), a random number of values to mutate is
selected with less being exponentially more likely. The indexes of the
values are selected from a selected uid with a logarithmic bias to uids
with more values.
Mutations may change a single values, several consecutive values in a
uid, or several consecutive values in the uid-independent order they
were requested. They may generate random values, mutate from previous
ones, or copy from other values in the same uid from the same input or
spliced from another.
For integers, mutations from previous ones currently only generates
random values. For bytes, mutations from previous mix new random data
and previous bytes with a set number of mutations.
--- Passive Minimization
A different approach has been taken for minimizing inputs: instead of
trying a fixed set of mutations when a fresh input is found, the input
is instead simply added to the corpus and removed when it is no longer
valuable.
The quality of an input is measured based off how many unique pcs it
hit and how many values it needed from the fuzzer. It is tracked which
inputs hold the best qualities for each pc for hitting the minimum and
maximum unique pcs while needing the least values.
Once all an input's qualities have been superseded for the pcs it hit,
it is removed from the corpus.
-- Comparison to byte-based smith
A byte-based smith would be much more inefficient and complex than this
solution. It would be unable to solve the shifting problem that Uids
do. It is unable to provide values from the fuzzer past end-of-stream.
Even with feedback, it would be unable to act on dynamic weights which
have proven essential with the updated tests (e.g. to constrain values
to a range).
-- Test updates
All the standard library tests have been updated to use the new smith
interface. For `Deque`, an ad hoc allocator was written to improve
performance and remove reliance on heap allocation. `TokenSmith` has
been added to aid in testing Ast and help inform decisions on the smith
interface.
2026-02-13 17:48:57 -05:00
|
|
|
|
2019-02-08 18:18:47 -05:00
|
|
|
|
2017-10-31 04:47:55 -04:00
|
|
|
|
|
|
|
|
|
2024-07-03 13:28:21 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-18 10:42:04 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-07 20:22:38 -07:00
|
|
|
|
2025-07-18 10:42:04 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-09-25 11:11:48 -07:00
|
|
|
|
2020-07-11 14:09:04 +03:00
|
|
|
|
2024-08-24 16:16:53 +01:00
|
|
|
|
2025-01-24 04:20:55 +00:00
|
|
|
|
2021-06-26 11:28:03 -05:00
|
|
|
|
|
|
|
|
|
2025-09-08 14:31:45 +01:00
|
|
|
|
|
|
|
|
|
2021-06-26 11:28:03 -05:00
|
|
|
|
2022-09-15 00:43:48 +03:00
|
|
|
|
2021-06-26 11:28:03 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-24 16:16:53 +01:00
|
|
|
|
2021-06-26 11:28:03 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-06-27 20:05:22 -07:00
|
|
|
|
2021-06-26 11:28:03 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-06-27 20:05:22 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-06-26 11:28:03 -05:00
|
|
|
|
2025-01-24 04:20:55 +00:00
|
|
|
|
2018-03-09 22:21:13 -05:00
|
|
|
|
|
|
|
|
|
2020-03-13 17:55:40 +01:00
|
|
|
|
|
|
|
|
|
2023-11-22 18:49:18 -07:00
|
|
|
|
2018-03-09 22:21:13 -05:00
|
|
|
|
2020-03-13 17:55:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-08-07 15:16:01 +08:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-09-26 14:24:18 -07:00
|
|
|
|
2025-12-21 17:06:02 -08:00
|
|
|
|
2024-08-24 16:16:53 +01:00
|
|
|
|
2017-06-14 00:04:34 -04:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
2024-09-25 11:11:48 -07:00
|
|
|
|
2026-06-18 14:18:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-07-07 15:33:50 +02:00
|
|
|
|
2026-08-26 10:02:45 +03:00
|
|
|
|
2026-06-18 14:18:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-09-25 11:11:48 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-09-26 14:24:18 -07:00
|
|
|
|
2024-10-07 01:33:42 +09:00
|
|
|
|
2024-09-26 14:24:18 -07:00
|
|
|
|
2024-09-25 11:11:48 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-04-01 03:47:51 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-09-25 11:11:48 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-05-03 21:09:17 +01:00
|
|
|
|
2025-07-12 10:18:53 -07:00
|
|
|
|
2024-09-25 11:11:48 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-08 16:13:51 -08:00
|
|
|
|
2024-09-25 11:11:48 -07:00
|
|
|
|
2024-09-26 14:24:18 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-09-25 11:11:48 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-02-09 14:19:27 -05:00
|
|
|
|
2026-01-06 10:50:45 +00:00
|
|
|
|
2019-07-22 12:15:16 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
2020-02-18 19:03:31 +01:00
|
|
|
|
2020-03-13 17:55:40 +01:00
|
|
|
|
2024-02-18 21:52:23 -08:00
|
|
|
|
2020-03-13 17:55:40 +01:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-12-17 17:00:41 -08:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
|
|
|
|
|
2020-03-13 17:55:40 +01:00
|
|
|
|
2024-09-26 14:24:18 -07:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2024-09-26 14:24:18 -07:00
|
|
|
|
|
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2024-09-26 14:24:18 -07:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2024-09-26 14:24:18 -07:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2026-04-08 13:49:44 -07:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2020-03-13 17:55:40 +01:00
|
|
|
|
|
|
|
|
|
2023-04-08 08:36:31 -07:00
|
|
|
|
2019-12-20 17:48:45 -05:00
|
|
|
|
2020-02-18 19:03:31 +01:00
|
|
|
|
2020-03-13 17:55:40 +01:00
|
|
|
|
2024-09-25 11:11:48 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-17 17:00:41 -08:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2019-12-20 17:48:45 -05:00
|
|
|
|
2024-09-25 11:11:48 -07:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2020-03-13 17:55:40 +01:00
|
|
|
|
2025-12-08 16:13:51 -08:00
|
|
|
|
2018-01-15 16:26:13 -05:00
|
|
|
|
|
|
|
|
|
2023-04-08 08:36:31 -07:00
|
|
|
|
|
|
|
|
|
2024-02-18 21:52:23 -08:00
|
|
|
|
2023-04-08 08:36:31 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-01-24 17:00:36 +01:00
|
|
|
|
|
|
|
|
|
2023-04-08 08:36:31 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-08 13:49:44 -07:00
|
|
|
|
2026-04-09 15:43:05 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-08 17:18:16 -07:00
|
|
|
|
2026-04-09 15:43:05 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-08 13:49:44 -07:00
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std: rework/remove ucontext_t
Our usage of `ucontext_t` in the standard library was kind of
problematic. We unnecessarily mimiced libc-specific structures, and our
`getcontext` implementation was overkill for our use case of stack
tracing.
This commit introduces a new namespace, `std.debug.cpu_context`, which
contains "context" types for various architectures (currently x86,
x86_64, ARM, and AARCH64) containing the general-purpose CPU registers;
the ones needed in practice for stack unwinding. Each implementation has
a function `current` which populates the structure using inline
assembly. The structure is user-overrideable, though that should only be
necessary if the standard library does not have an implementation for
the *architecture*: that is to say, none of this is OS-dependent.
Of course, in POSIX signal handlers, we get a `ucontext_t` from the
kernel. The function `std.debug.cpu_context.fromPosixSignalContext`
converts this to a `std.debug.cpu_context.Native` with a big ol' target
switch.
This functionality is not exposed from `std.c` or `std.posix`, and
neither are `ucontext_t`, `mcontext_t`, or `getcontext`. The rationale
is that these types and functions do not conform to a specific ABI, and
in fact tend to get updated over time based on CPU features and
extensions; in addition, different libcs use different structures which
are "partially compatible" with the kernel structure. Overall, it's a
mess, but all we need is the kernel context, so we can just define a
kernel-compatible structure as long as we don't claim C compatibility by
putting it in `std.c` or `std.posix`.
This change resulted in a few nice `std.debug` simplifications, but
nothing too noteworthy. However, the main benefit of this change is that
DWARF unwinding---sometimes necessary for collecting stack traces
reliably---now requires far less target-specific integration.
Also fix a bug I noticed in `PageAllocator` (I found this due to a bug
in my distro's QEMU distribution; thanks, broken QEMU patch!) and I
think a couple of minor bugs in `std.debug`.
Resolves: #23801
Resolves: #23802
2025-09-17 18:38:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-01-12 02:12:11 -05:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-19 14:08:21 -07:00
|
|
|
|
2026-04-06 13:01:27 -07:00
|
|
|
|
2026-04-08 17:18:16 -07:00
|
|
|
|
2026-04-09 15:43:05 -07:00
|
|
|
|
2026-04-06 13:01:27 -07:00
|
|
|
|
2025-09-17 23:52:52 +01:00
|
|
|
|
2025-11-08 11:12:40 +00:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-09-17 23:52:52 +01:00
|
|
|
|
2025-12-08 21:57:46 -08:00
|
|
|
|
2025-12-22 16:10:43 -08:00
|
|
|
|
2025-12-08 21:57:46 -08:00
|
|
|
|
2025-09-20 14:44:10 +01:00
|
|
|
|
2025-09-26 10:52:09 +01:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2026-04-09 15:43:05 -07:00
|
|
|
|
2025-09-26 10:52:09 +01:00
|
|
|
|
|
|
|
|
|
2026-04-09 15:43:05 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-18 13:32:47 +01:00
|
|
|
|
2025-09-20 14:44:10 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-09 15:43:05 -07:00
|
|
|
|
2025-09-20 14:44:10 +01:00
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-09-18 13:32:47 +01:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
2025-09-26 10:52:09 +01:00
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2026-04-09 15:43:05 -07:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2026-04-08 17:18:16 -07:00
|
|
|
|
2026-04-09 15:43:05 -07:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
|
|
|
|
|
2026-04-13 00:43:34 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-17 23:52:52 +01:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-09-17 23:52:52 +01:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-09-17 23:52:52 +01:00
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-11-08 11:12:40 +00:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
2025-09-20 14:44:10 +01:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
2025-12-22 16:10:43 -08:00
|
|
|
|
2025-12-08 16:41:24 -08:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-10-07 05:50:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-02-06 04:36:32 -05:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-08 20:35:34 -07:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-18 13:32:47 +01:00
|
|
|
|
2025-09-20 14:44:10 +01:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-09-20 14:44:10 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-09-20 14:44:10 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-09-18 13:32:47 +01:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
2025-09-18 13:32:47 +01:00
|
|
|
|
|
|
|
|
|
2026-04-13 00:43:34 -07:00
|
|
|
|
2026-04-06 13:01:27 -07:00
|
|
|
|
2026-04-08 13:49:44 -07:00
|
|
|
|
2026-04-06 13:01:27 -07:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-06-07 12:21:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-17 17:00:41 -08:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-09-09 08:55:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-09-25 20:18:15 -07:00
|
|
|
|
2025-10-19 14:08:21 -07:00
|
|
|
|
|
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-10-19 14:08:21 -07:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-19 14:08:21 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-08 13:49:44 -07:00
|
|
|
|
2026-04-11 16:04:57 -07:00
|
|
|
|
2026-04-09 15:43:05 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-07-17 23:30:26 +02:00
|
|
|
|
2026-04-08 13:49:44 -07:00
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2026-04-08 17:18:16 -07:00
|
|
|
|
2026-04-09 15:43:05 -07:00
|
|
|
|
2026-04-08 13:49:44 -07:00
|
|
|
|
|
|
|
|
|
2026-04-08 17:18:16 -07:00
|
|
|
|
|
|
|
|
|
2026-04-09 15:43:05 -07:00
|
|
|
|
2026-04-08 17:18:16 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-13 00:43:34 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-09-17 23:52:52 +01:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-09-17 23:52:52 +01:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-09-17 23:52:52 +01:00
|
|
|
|
|
|
|
|
|
2025-10-19 14:08:21 -07:00
|
|
|
|
2026-04-09 15:43:05 -07:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-22 16:10:43 -08:00
|
|
|
|
2026-04-09 15:43:05 -07:00
|
|
|
|
|
|
|
|
|
2025-09-18 13:32:47 +01:00
|
|
|
|
2026-04-13 00:43:34 -07:00
|
|
|
|
2026-04-09 15:43:05 -07:00
|
|
|
|
2026-04-08 13:49:44 -07:00
|
|
|
|
2026-04-06 13:01:27 -07:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2026-04-09 15:43:05 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-09-25 20:18:15 -07:00
|
|
|
|
2018-01-12 02:12:11 -05:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-10-21 04:40:44 -07:00
|
|
|
|
2026-06-07 12:21:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-17 17:00:41 -08:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-01-12 02:12:11 -05:00
|
|
|
|
2026-04-08 13:49:44 -07:00
|
|
|
|
2026-04-11 16:04:57 -07:00
|
|
|
|
2026-06-07 12:21:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-08 13:49:44 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-11-08 11:12:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-11-08 11:12:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2018-12-02 18:54:04 -05:00
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
std: rework/remove ucontext_t
Our usage of `ucontext_t` in the standard library was kind of
problematic. We unnecessarily mimiced libc-specific structures, and our
`getcontext` implementation was overkill for our use case of stack
tracing.
This commit introduces a new namespace, `std.debug.cpu_context`, which
contains "context" types for various architectures (currently x86,
x86_64, ARM, and AARCH64) containing the general-purpose CPU registers;
the ones needed in practice for stack unwinding. Each implementation has
a function `current` which populates the structure using inline
assembly. The structure is user-overrideable, though that should only be
necessary if the standard library does not have an implementation for
the *architecture*: that is to say, none of this is OS-dependent.
Of course, in POSIX signal handlers, we get a `ucontext_t` from the
kernel. The function `std.debug.cpu_context.fromPosixSignalContext`
converts this to a `std.debug.cpu_context.Native` with a big ol' target
switch.
This functionality is not exposed from `std.c` or `std.posix`, and
neither are `ucontext_t`, `mcontext_t`, or `getcontext`. The rationale
is that these types and functions do not conform to a specific ABI, and
in fact tend to get updated over time based on CPU features and
extensions; in addition, different libcs use different structures which
are "partially compatible" with the kernel structure. Overall, it's a
mess, but all we need is the kernel context, so we can just define a
kernel-compatible structure as long as we don't claim C compatibility by
putting it in `std.c` or `std.posix`.
This change resulted in a few nice `std.debug` simplifications, but
nothing too noteworthy. However, the main benefit of this change is that
DWARF unwinding---sometimes necessary for collecting stack traces
reliably---now requires far less target-specific integration.
Also fix a bug I noticed in `PageAllocator` (I found this due to a bug
in my distro's QEMU distribution; thanks, broken QEMU patch!) and I
think a couple of minor bugs in `std.debug`.
Resolves: #23801
Resolves: #23802
2025-09-17 18:38:11 +01:00
|
|
|
|
|
|
|
|
|
2025-11-08 11:12:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std: rework/remove ucontext_t
Our usage of `ucontext_t` in the standard library was kind of
problematic. We unnecessarily mimiced libc-specific structures, and our
`getcontext` implementation was overkill for our use case of stack
tracing.
This commit introduces a new namespace, `std.debug.cpu_context`, which
contains "context" types for various architectures (currently x86,
x86_64, ARM, and AARCH64) containing the general-purpose CPU registers;
the ones needed in practice for stack unwinding. Each implementation has
a function `current` which populates the structure using inline
assembly. The structure is user-overrideable, though that should only be
necessary if the standard library does not have an implementation for
the *architecture*: that is to say, none of this is OS-dependent.
Of course, in POSIX signal handlers, we get a `ucontext_t` from the
kernel. The function `std.debug.cpu_context.fromPosixSignalContext`
converts this to a `std.debug.cpu_context.Native` with a big ol' target
switch.
This functionality is not exposed from `std.c` or `std.posix`, and
neither are `ucontext_t`, `mcontext_t`, or `getcontext`. The rationale
is that these types and functions do not conform to a specific ABI, and
in fact tend to get updated over time based on CPU features and
extensions; in addition, different libcs use different structures which
are "partially compatible" with the kernel structure. Overall, it's a
mess, but all we need is the kernel context, so we can just define a
kernel-compatible structure as long as we don't claim C compatibility by
putting it in `std.c` or `std.posix`.
This change resulted in a few nice `std.debug` simplifications, but
nothing too noteworthy. However, the main benefit of this change is that
DWARF unwinding---sometimes necessary for collecting stack traces
reliably---now requires far less target-specific integration.
Also fix a bug I noticed in `PageAllocator` (I found this due to a bug
in my distro's QEMU distribution; thanks, broken QEMU patch!) and I
think a couple of minor bugs in `std.debug`.
Resolves: #23801
Resolves: #23802
2025-09-17 18:38:11 +01:00
|
|
|
|
2025-11-08 11:12:40 +00:00
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-11-08 11:12:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-18 15:52:02 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-30 11:06:21 +01:00
|
|
|
|
|
|
|
|
|
2025-10-07 05:50:37 +02:00
|
|
|
|
|
|
|
|
|
2025-09-18 15:52:02 +01:00
|
|
|
|
std: rework/remove ucontext_t
Our usage of `ucontext_t` in the standard library was kind of
problematic. We unnecessarily mimiced libc-specific structures, and our
`getcontext` implementation was overkill for our use case of stack
tracing.
This commit introduces a new namespace, `std.debug.cpu_context`, which
contains "context" types for various architectures (currently x86,
x86_64, ARM, and AARCH64) containing the general-purpose CPU registers;
the ones needed in practice for stack unwinding. Each implementation has
a function `current` which populates the structure using inline
assembly. The structure is user-overrideable, though that should only be
necessary if the standard library does not have an implementation for
the *architecture*: that is to say, none of this is OS-dependent.
Of course, in POSIX signal handlers, we get a `ucontext_t` from the
kernel. The function `std.debug.cpu_context.fromPosixSignalContext`
converts this to a `std.debug.cpu_context.Native` with a big ol' target
switch.
This functionality is not exposed from `std.c` or `std.posix`, and
neither are `ucontext_t`, `mcontext_t`, or `getcontext`. The rationale
is that these types and functions do not conform to a specific ABI, and
in fact tend to get updated over time based on CPU features and
extensions; in addition, different libcs use different structures which
are "partially compatible" with the kernel structure. Overall, it's a
mess, but all we need is the kernel context, so we can just define a
kernel-compatible structure as long as we don't claim C compatibility by
putting it in `std.c` or `std.posix`.
This change resulted in a few nice `std.debug` simplifications, but
nothing too noteworthy. However, the main benefit of this change is that
DWARF unwinding---sometimes necessary for collecting stack traces
reliably---now requires far less target-specific integration.
Also fix a bug I noticed in `PageAllocator` (I found this due to a bug
in my distro's QEMU distribution; thanks, broken QEMU patch!) and I
think a couple of minor bugs in `std.debug`.
Resolves: #23801
Resolves: #23802
2025-09-17 18:38:11 +01:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-10-14 09:52:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-11-08 11:12:40 +00:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2026-02-06 04:36:32 -05:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
2021-04-25 19:10:11 +02:00
|
|
|
|
2025-10-14 09:37:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-07 05:50:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-20 03:44:10 +02:00
|
|
|
|
2025-10-16 13:50:39 +02:00
|
|
|
|
|
|
|
|
|
2025-10-20 03:44:10 +02:00
|
|
|
|
|
|
|
|
|
2025-10-04 04:10:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-16 13:50:39 +02:00
|
|
|
|
2025-10-20 03:44:10 +02:00
|
|
|
|
|
|
|
|
|
2025-10-16 13:50:39 +02:00
|
|
|
|
2026-05-26 08:05:53 +02:00
|
|
|
|
|
|
|
|
|
2025-10-07 05:50:37 +02:00
|
|
|
|
2025-10-03 21:19:38 +02:00
|
|
|
|
2025-10-07 05:50:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-03 21:19:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-14 09:47:29 +02:00
|
|
|
|
|
|
|
|
|
2025-10-07 05:50:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-03 21:19:38 +02:00
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-11-08 11:12:40 +00:00
|
|
|
|
2025-09-11 13:32:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-07 05:50:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-04 04:10:00 +02:00
|
|
|
|
2018-12-02 18:54:04 -05:00
|
|
|
|
2018-07-29 23:25:40 -04:00
|
|
|
|
2018-12-02 18:54:04 -05:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-09-18 13:32:47 +01:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-17 23:03:45 +01:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
2025-09-30 11:06:21 +01:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
2025-09-18 13:32:47 +01:00
|
|
|
|
2025-12-08 13:39:09 -08:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-11-08 11:12:40 +00:00
|
|
|
|
|
|
|
|
|
2026-08-28 14:07:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-11-08 11:12:40 +00:00
|
|
|
|
2025-09-18 13:32:47 +01:00
|
|
|
|
|
|
|
|
|
2025-11-08 11:12:40 +00:00
|
|
|
|
2025-09-17 23:03:45 +01:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
2026-02-06 04:36:32 -05:00
|
|
|
|
2025-09-08 20:08:28 +01:00
|
|
|
|
2026-08-28 14:07:24 +02:00
|
|
|
|
2026-08-17 12:40:47 +02:00
|
|
|
|
2025-10-14 23:07:22 +02:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-09-08 20:08:28 +01:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
2025-09-17 23:03:45 +01:00
|
|
|
|
2025-09-18 13:32:47 +01:00
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-14 09:54:48 +02:00
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-14 09:54:48 +02:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-10-20 03:44:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
2025-10-20 03:44:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
2025-09-17 23:03:45 +01:00
|
|
|
|
2025-09-13 10:29:20 +01:00
|
|
|
|
2025-09-18 13:32:47 +01:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2023-07-18 22:51:52 -04:00
|
|
|
|
2023-05-15 01:52:53 -04:00
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-10-14 09:54:48 +02:00
|
|
|
|
2025-10-20 03:45:20 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-14 09:54:48 +02:00
|
|
|
|
|
|
|
|
|
2025-10-09 20:42:54 +02:00
|
|
|
|
2025-10-18 15:01:48 +02:00
|
|
|
|
|
|
|
|
|
2025-10-14 09:54:48 +02:00
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-10-14 09:54:48 +02:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
2021-02-04 20:51:41 +07:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-10-14 09:54:48 +02:00
|
|
|
|
2025-10-20 03:45:20 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-14 09:54:48 +02:00
|
|
|
|
|
|
|
|
|
2025-10-18 15:01:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-03 20:08:06 +02:00
|
|
|
|
2025-10-03 03:24:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-14 09:54:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
2021-02-04 20:51:41 +07:00
|
|
|
|
2025-10-14 09:54:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-14 22:32:37 +02:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
2019-10-13 12:13:41 +02:00
|
|
|
|
2025-10-14 09:57:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-12-02 18:54:04 -05:00
|
|
|
|
|
|
|
|
|
2018-07-29 23:25:40 -04:00
|
|
|
|
2025-09-17 23:03:45 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-06 13:01:27 -07:00
|
|
|
|
|
|
|
|
|
2026-04-08 13:49:44 -07:00
|
|
|
|
2026-04-06 13:01:27 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-13 00:43:34 -07:00
|
|
|
|
2026-04-06 13:01:27 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-13 00:43:34 -07:00
|
|
|
|
2026-04-12 14:50:34 -07:00
|
|
|
|
2026-04-13 00:43:34 -07:00
|
|
|
|
|
|
|
|
|
2026-04-16 19:28:48 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-13 00:43:34 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-10 19:29:43 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-03-20 17:51:34 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-10 19:29:43 -07:00
|
|
|
|
|
|
|
|
|
2026-03-20 17:51:34 -07:00
|
|
|
|
|
|
|
|
|
2026-04-10 19:29:43 -07:00
|
|
|
|
2026-03-20 17:51:34 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-10 19:29:43 -07:00
|
|
|
|
|
|
|
|
|
2026-04-12 14:50:34 -07:00
|
|
|
|
2026-04-13 00:43:34 -07:00
|
|
|
|
|
|
|
|
|
2026-04-12 14:50:34 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-13 00:43:34 -07:00
|
|
|
|
2026-03-20 17:51:34 -07:00
|
|
|
|
2018-12-02 19:34:11 -05:00
|
|
|
|
2018-08-23 16:11:34 -04:00
|
|
|
|
2025-12-03 20:37:43 -08:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2026-04-10 19:29:43 -07:00
|
|
|
|
2018-08-23 16:11:34 -04:00
|
|
|
|
2026-04-13 00:43:34 -07:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-12-22 15:14:59 -08:00
|
|
|
|
|
|
|
|
|
2020-01-21 20:51:57 +01:00
|
|
|
|
2026-04-13 00:43:34 -07:00
|
|
|
|
2026-04-07 16:01:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-22 15:14:59 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-01-21 20:51:57 +01:00
|
|
|
|
2025-12-22 15:14:59 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-10 19:29:43 -07:00
|
|
|
|
|
|
|
|
|
2026-04-13 00:43:34 -07:00
|
|
|
|
|
|
|
|
|
2026-04-10 19:29:43 -07:00
|
|
|
|
2025-12-22 15:14:59 -08:00
|
|
|
|
|
|
|
|
|
2020-01-21 20:51:57 +01:00
|
|
|
|
2025-12-22 15:14:59 -08:00
|
|
|
|
2026-04-13 00:43:34 -07:00
|
|
|
|
2025-12-22 15:14:59 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-01-21 20:51:57 +01:00
|
|
|
|
2025-12-22 15:14:59 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-23 16:11:34 -04:00
|
|
|
|
2025-12-22 15:14:59 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-23 16:11:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-03 20:37:43 -08:00
|
|
|
|
2025-09-08 14:31:45 +01:00
|
|
|
|
2025-09-05 21:28:18 +01:00
|
|
|
|
2025-12-03 20:37:43 -08:00
|
|
|
|
2025-09-05 21:28:18 +01:00
|
|
|
|
|
|
|
|
|
2020-03-10 19:28:05 -04:00
|
|
|
|
|
|
|
|
|
2025-12-03 20:37:43 -08:00
|
|
|
|
2025-12-08 16:41:24 -08:00
|
|
|
|
|
|
|
|
|
2017-04-24 12:01:19 -04:00
|
|
|
|
2025-12-08 16:41:24 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-19 12:10:21 -08:00
|
|
|
|
|
|
|
|
|
2025-12-08 16:41:24 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-19 12:10:21 -08:00
|
|
|
|
2025-12-08 16:41:24 -08:00
|
|
|
|
|
|
|
|
|
2017-04-24 12:01:19 -04:00
|
|
|
|
2025-12-19 12:10:21 -08:00
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
|
|
|
|
|
2017-04-24 12:01:19 -04:00
|
|
|
|
2025-09-01 16:50:39 +01:00
|
|
|
|
2025-12-09 22:10:12 -08:00
|
|
|
|
|
|
|
|
|
2025-12-03 20:37:43 -08:00
|
|
|
|
|
|
|
|
|
2025-06-27 20:05:22 -07:00
|
|
|
|
2025-07-01 09:41:41 -07:00
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
|
|
|
|
|
2025-12-09 22:10:12 -08:00
|
|
|
|
|
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
2025-12-09 22:10:12 -08:00
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
std.debug: rename Info to SelfInfo
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-01 16:31:03 -07:00
|
|
|
|
2025-12-03 20:37:43 -08:00
|
|
|
|
|
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-03 20:37:43 -08:00
|
|
|
|
|
|
|
|
|
2025-12-08 17:21:52 -08:00
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
2025-12-08 23:14:34 -08:00
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
2025-12-03 20:37:43 -08:00
|
|
|
|
2025-08-13 09:33:02 +02:00
|
|
|
|
2025-06-27 20:05:22 -07:00
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
|
|
|
|
|
2025-12-03 20:37:43 -08:00
|
|
|
|
|
|
|
|
|
2025-12-08 17:21:52 -08:00
|
|
|
|
2024-05-02 20:54:48 -07:00
|
|
|
|
|
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-05-02 20:54:48 -07:00
|
|
|
|
|
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
2025-12-03 20:37:43 -08:00
|
|
|
|
2025-08-13 09:33:02 +02:00
|
|
|
|
2025-06-27 20:05:22 -07:00
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
2025-12-03 20:37:43 -08:00
|
|
|
|
2025-08-13 09:33:02 +02:00
|
|
|
|
2025-06-27 20:05:22 -07:00
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
|
|
|
|
|
2025-12-08 13:39:09 -08:00
|
|
|
|
2025-12-05 19:08:37 -08:00
|
|
|
|
2025-12-03 20:37:43 -08:00
|
|
|
|
|
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
|
|
|
|
|
2025-06-30 15:54:41 -07:00
|
|
|
|
2025-12-08 17:14:31 -08:00
|
|
|
|
2025-06-27 20:05:22 -07:00
|
|
|
|
|
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
2025-06-27 20:05:22 -07:00
|
|
|
|
2025-06-30 15:54:41 -07:00
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
2025-12-03 20:37:43 -08:00
|
|
|
|
2026-04-29 19:30:34 +01:00
|
|
|
|
2025-06-27 20:05:22 -07:00
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
|
|
|
|
|
2025-12-08 13:39:09 -08:00
|
|
|
|
2025-12-05 19:08:37 -08:00
|
|
|
|
2025-12-03 20:37:43 -08:00
|
|
|
|
|
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
2025-12-08 17:14:31 -08:00
|
|
|
|
2025-06-27 20:05:22 -07:00
|
|
|
|
|
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
2025-12-03 20:37:43 -08:00
|
|
|
|
2026-04-29 19:30:34 +01:00
|
|
|
|
2025-06-27 20:05:22 -07:00
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
|
|
|
|
|
2025-12-08 13:39:09 -08:00
|
|
|
|
2025-12-05 19:08:37 -08:00
|
|
|
|
2025-12-03 20:37:43 -08:00
|
|
|
|
|
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
2025-12-08 17:14:31 -08:00
|
|
|
|
2025-06-27 20:05:22 -07:00
|
|
|
|
|
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
2025-12-08 23:14:34 -08:00
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
2026-04-29 19:30:34 +01:00
|
|
|
|
|
|
|
|
|
2025-12-03 20:37:43 -08:00
|
|
|
|
2026-04-29 19:30:34 +01:00
|
|
|
|
2025-06-27 20:05:22 -07:00
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-03 20:37:43 -08:00
|
|
|
|
2026-04-29 19:30:34 +01:00
|
|
|
|
2025-06-27 20:05:22 -07:00
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
2025-12-03 20:37:43 -08:00
|
|
|
|
2025-08-13 09:33:02 +02:00
|
|
|
|
2025-06-27 20:05:22 -07:00
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
|
|
|
|
|
2025-12-08 13:39:09 -08:00
|
|
|
|
2025-12-05 19:08:37 -08:00
|
|
|
|
2025-12-03 20:37:43 -08:00
|
|
|
|
|
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
2025-12-08 17:14:31 -08:00
|
|
|
|
2025-06-27 20:05:22 -07:00
|
|
|
|
2025-01-29 14:16:25 -08:00
|
|
|
|
2025-06-27 20:05:22 -07:00
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
|
|
|
|
|
2025-12-03 20:37:43 -08:00
|
|
|
|
2025-08-13 09:33:02 +02:00
|
|
|
|
2025-06-27 20:05:22 -07:00
|
|
|
|
2023-11-29 20:58:56 +01:00
|
|
|
|
2025-12-03 20:37:43 -08:00
|
|
|
|
2025-08-13 09:33:02 +02:00
|
|
|
|
2025-06-27 20:05:22 -07:00
|
|
|
|
2017-04-24 12:01:19 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-19 13:35:12 +01:00
|
|
|
|
|
|
|
|
|
2025-11-19 12:55:17 +00:00
|
|
|
|
2025-09-08 14:31:45 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-01 16:50:39 +01:00
|
|
|
|
2025-09-08 14:31:45 +01:00
|
|
|
|
|
|
|
|
|
2025-09-19 13:35:12 +01:00
|
|
|
|
2025-09-08 14:31:45 +01:00
|
|
|
|
2026-02-15 17:05:00 +01:00
|
|
|
|
2018-04-15 20:15:19 -04:00
|
|
|
|
2019-07-02 13:27:40 -04:00
|
|
|
|
|
|
|
|
|
2021-04-12 16:43:50 -07:00
|
|
|
|
2025-10-09 09:49:27 +02:00
|
|
|
|
2022-02-07 18:20:33 +01:00
|
|
|
|
2025-10-03 22:37:05 +01:00
|
|
|
|
2025-10-09 09:49:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-11-13 18:05:46 +01:00
|
|
|
|
2025-10-09 09:49:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-02-07 18:20:33 +01:00
|
|
|
|
|
|
|
|
|
2020-04-01 11:03:36 +02:00
|
|
|
|
|
|
|
|
|
2023-01-03 19:37:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-07-22 12:15:16 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-09-25 11:11:48 -07:00
|
|
|
|
2019-07-22 12:15:16 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-07-02 13:27:40 -04:00
|
|
|
|
2024-07-21 13:31:06 +02:00
|
|
|
|
2025-10-27 16:16:49 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-21 10:14:44 +01:00
|
|
|
|
|
|
|
|
|
2025-09-08 14:31:45 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-01-12 11:41:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-08 14:31:45 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-07-02 13:27:40 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-04-12 16:43:50 -07:00
|
|
|
|
2025-10-31 21:54:50 +08:00
|
|
|
|
2019-07-22 12:15:16 -04:00
|
|
|
|
2019-07-03 10:16:52 -05:00
|
|
|
|
2026-01-12 11:41:53 +00:00
|
|
|
|
2022-01-17 17:46:48 +01:00
|
|
|
|
2025-04-22 14:19:06 -07:00
|
|
|
|
2026-01-12 11:41:53 +00:00
|
|
|
|
2019-07-22 12:15:16 -04:00
|
|
|
|
2024-07-21 13:31:06 +02:00
|
|
|
|
2019-07-02 13:27:40 -04:00
|
|
|
|
|
|
|
|
|
2019-07-22 12:15:16 -04:00
|
|
|
|
2021-04-12 16:43:50 -07:00
|
|
|
|
2019-07-22 12:15:16 -04:00
|
|
|
|
2025-10-31 21:54:50 +08:00
|
|
|
|
2019-07-22 12:15:16 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-04-22 14:19:06 -07:00
|
|
|
|
2024-03-18 22:39:59 -07:00
|
|
|
|
2025-04-22 14:19:06 -07:00
|
|
|
|
2019-07-02 13:27:40 -04:00
|
|
|
|
|
|
|
|
|
2024-07-21 13:31:06 +02:00
|
|
|
|
2019-07-22 12:15:16 -04:00
|
|
|
|
|
|
|
|
|
2025-10-27 16:16:49 -07:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-10-29 19:21:32 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-10-27 16:16:49 -07:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-09 09:49:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-11-13 18:05:46 +01:00
|
|
|
|
2025-10-09 09:49:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-14 19:10:21 +01:00
|
|
|
|
2025-10-09 09:49:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-27 16:16:49 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std: rework/remove ucontext_t
Our usage of `ucontext_t` in the standard library was kind of
problematic. We unnecessarily mimiced libc-specific structures, and our
`getcontext` implementation was overkill for our use case of stack
tracing.
This commit introduces a new namespace, `std.debug.cpu_context`, which
contains "context" types for various architectures (currently x86,
x86_64, ARM, and AARCH64) containing the general-purpose CPU registers;
the ones needed in practice for stack unwinding. Each implementation has
a function `current` which populates the structure using inline
assembly. The structure is user-overrideable, though that should only be
necessary if the standard library does not have an implementation for
the *architecture*: that is to say, none of this is OS-dependent.
Of course, in POSIX signal handlers, we get a `ucontext_t` from the
kernel. The function `std.debug.cpu_context.fromPosixSignalContext`
converts this to a `std.debug.cpu_context.Native` with a big ol' target
switch.
This functionality is not exposed from `std.c` or `std.posix`, and
neither are `ucontext_t`, `mcontext_t`, or `getcontext`. The rationale
is that these types and functions do not conform to a specific ABI, and
in fact tend to get updated over time based on CPU features and
extensions; in addition, different libcs use different structures which
are "partially compatible" with the kernel structure. Overall, it's a
mess, but all we need is the kernel context, so we can just define a
kernel-compatible structure as long as we don't claim C compatibility by
putting it in `std.c` or `std.posix`.
This change resulted in a few nice `std.debug` simplifications, but
nothing too noteworthy. However, the main benefit of this change is that
DWARF unwinding---sometimes necessary for collecting stack traces
reliably---now requires far less target-specific integration.
Also fix a bug I noticed in `PageAllocator` (I found this due to a bug
in my distro's QEMU distribution; thanks, broken QEMU patch!) and I
think a couple of minor bugs in `std.debug`.
Resolves: #23801
Resolves: #23802
2025-09-17 18:38:11 +01:00
|
|
|
|
2025-10-14 09:49:20 +02:00
|
|
|
|
std: rework/remove ucontext_t
Our usage of `ucontext_t` in the standard library was kind of
problematic. We unnecessarily mimiced libc-specific structures, and our
`getcontext` implementation was overkill for our use case of stack
tracing.
This commit introduces a new namespace, `std.debug.cpu_context`, which
contains "context" types for various architectures (currently x86,
x86_64, ARM, and AARCH64) containing the general-purpose CPU registers;
the ones needed in practice for stack unwinding. Each implementation has
a function `current` which populates the structure using inline
assembly. The structure is user-overrideable, though that should only be
necessary if the standard library does not have an implementation for
the *architecture*: that is to say, none of this is OS-dependent.
Of course, in POSIX signal handlers, we get a `ucontext_t` from the
kernel. The function `std.debug.cpu_context.fromPosixSignalContext`
converts this to a `std.debug.cpu_context.Native` with a big ol' target
switch.
This functionality is not exposed from `std.c` or `std.posix`, and
neither are `ucontext_t`, `mcontext_t`, or `getcontext`. The rationale
is that these types and functions do not conform to a specific ABI, and
in fact tend to get updated over time based on CPU features and
extensions; in addition, different libcs use different structures which
are "partially compatible" with the kernel structure. Overall, it's a
mess, but all we need is the kernel context, so we can just define a
kernel-compatible structure as long as we don't claim C compatibility by
putting it in `std.c` or `std.posix`.
This change resulted in a few nice `std.debug` simplifications, but
nothing too noteworthy. However, the main benefit of this change is that
DWARF unwinding---sometimes necessary for collecting stack traces
reliably---now requires far less target-specific integration.
Also fix a bug I noticed in `PageAllocator` (I found this due to a bug
in my distro's QEMU distribution; thanks, broken QEMU patch!) and I
think a couple of minor bugs in `std.debug`.
Resolves: #23801
Resolves: #23802
2025-09-17 18:38:11 +01:00
|
|
|
|
2019-07-02 13:27:40 -04:00
|
|
|
|
2019-07-03 10:16:52 -05:00
|
|
|
|
2024-11-01 01:06:45 +01:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-07-03 10:16:52 -05:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
std: rework/remove ucontext_t
Our usage of `ucontext_t` in the standard library was kind of
problematic. We unnecessarily mimiced libc-specific structures, and our
`getcontext` implementation was overkill for our use case of stack
tracing.
This commit introduces a new namespace, `std.debug.cpu_context`, which
contains "context" types for various architectures (currently x86,
x86_64, ARM, and AARCH64) containing the general-purpose CPU registers;
the ones needed in practice for stack unwinding. Each implementation has
a function `current` which populates the structure using inline
assembly. The structure is user-overrideable, though that should only be
necessary if the standard library does not have an implementation for
the *architecture*: that is to say, none of this is OS-dependent.
Of course, in POSIX signal handlers, we get a `ucontext_t` from the
kernel. The function `std.debug.cpu_context.fromPosixSignalContext`
converts this to a `std.debug.cpu_context.Native` with a big ol' target
switch.
This functionality is not exposed from `std.c` or `std.posix`, and
neither are `ucontext_t`, `mcontext_t`, or `getcontext`. The rationale
is that these types and functions do not conform to a specific ABI, and
in fact tend to get updated over time based on CPU features and
extensions; in addition, different libcs use different structures which
are "partially compatible" with the kernel structure. Overall, it's a
mess, but all we need is the kernel context, so we can just define a
kernel-compatible structure as long as we don't claim C compatibility by
putting it in `std.c` or `std.posix`.
This change resulted in a few nice `std.debug` simplifications, but
nothing too noteworthy. However, the main benefit of this change is that
DWARF unwinding---sometimes necessary for collecting stack traces
reliably---now requires far less target-specific integration.
Also fix a bug I noticed in `PageAllocator` (I found this due to a bug
in my distro's QEMU distribution; thanks, broken QEMU patch!) and I
think a couple of minor bugs in `std.debug`.
Resolves: #23801
Resolves: #23802
2025-09-17 18:38:11 +01:00
|
|
|
|
2019-07-03 10:16:52 -05:00
|
|
|
|
2019-09-11 20:22:49 -04:00
|
|
|
|
std: rework/remove ucontext_t
Our usage of `ucontext_t` in the standard library was kind of
problematic. We unnecessarily mimiced libc-specific structures, and our
`getcontext` implementation was overkill for our use case of stack
tracing.
This commit introduces a new namespace, `std.debug.cpu_context`, which
contains "context" types for various architectures (currently x86,
x86_64, ARM, and AARCH64) containing the general-purpose CPU registers;
the ones needed in practice for stack unwinding. Each implementation has
a function `current` which populates the structure using inline
assembly. The structure is user-overrideable, though that should only be
necessary if the standard library does not have an implementation for
the *architecture*: that is to say, none of this is OS-dependent.
Of course, in POSIX signal handlers, we get a `ucontext_t` from the
kernel. The function `std.debug.cpu_context.fromPosixSignalContext`
converts this to a `std.debug.cpu_context.Native` with a big ol' target
switch.
This functionality is not exposed from `std.c` or `std.posix`, and
neither are `ucontext_t`, `mcontext_t`, or `getcontext`. The rationale
is that these types and functions do not conform to a specific ABI, and
in fact tend to get updated over time based on CPU features and
extensions; in addition, different libcs use different structures which
are "partially compatible" with the kernel structure. Overall, it's a
mess, but all we need is the kernel context, so we can just define a
kernel-compatible structure as long as we don't claim C compatibility by
putting it in `std.c` or `std.posix`.
This change resulted in a few nice `std.debug` simplifications, but
nothing too noteworthy. However, the main benefit of this change is that
DWARF unwinding---sometimes necessary for collecting stack traces
reliably---now requires far less target-specific integration.
Also fix a bug I noticed in `PageAllocator` (I found this due to a bug
in my distro's QEMU distribution; thanks, broken QEMU patch!) and I
think a couple of minor bugs in `std.debug`.
Resolves: #23801
Resolves: #23802
2025-09-17 18:38:11 +01:00
|
|
|
|
2025-09-08 14:31:45 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std: rework/remove ucontext_t
Our usage of `ucontext_t` in the standard library was kind of
problematic. We unnecessarily mimiced libc-specific structures, and our
`getcontext` implementation was overkill for our use case of stack
tracing.
This commit introduces a new namespace, `std.debug.cpu_context`, which
contains "context" types for various architectures (currently x86,
x86_64, ARM, and AARCH64) containing the general-purpose CPU registers;
the ones needed in practice for stack unwinding. Each implementation has
a function `current` which populates the structure using inline
assembly. The structure is user-overrideable, though that should only be
necessary if the standard library does not have an implementation for
the *architecture*: that is to say, none of this is OS-dependent.
Of course, in POSIX signal handlers, we get a `ucontext_t` from the
kernel. The function `std.debug.cpu_context.fromPosixSignalContext`
converts this to a `std.debug.cpu_context.Native` with a big ol' target
switch.
This functionality is not exposed from `std.c` or `std.posix`, and
neither are `ucontext_t`, `mcontext_t`, or `getcontext`. The rationale
is that these types and functions do not conform to a specific ABI, and
in fact tend to get updated over time based on CPU features and
extensions; in addition, different libcs use different structures which
are "partially compatible" with the kernel structure. Overall, it's a
mess, but all we need is the kernel context, so we can just define a
kernel-compatible structure as long as we don't claim C compatibility by
putting it in `std.c` or `std.posix`.
This change resulted in a few nice `std.debug` simplifications, but
nothing too noteworthy. However, the main benefit of this change is that
DWARF unwinding---sometimes necessary for collecting stack traces
reliably---now requires far less target-specific integration.
Also fix a bug I noticed in `PageAllocator` (I found this due to a bug
in my distro's QEMU distribution; thanks, broken QEMU patch!) and I
think a couple of minor bugs in `std.debug`.
Resolves: #23801
Resolves: #23802
2025-09-17 18:38:11 +01:00
|
|
|
|
2026-02-09 14:19:27 -05:00
|
|
|
|
2026-01-06 10:50:45 +00:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
2024-09-25 11:11:48 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-01-29 16:57:43 +02:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-12-17 17:00:41 -08:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2023-04-08 08:36:31 -07:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2024-09-25 11:11:48 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-17 17:00:41 -08:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2024-09-25 11:11:48 -07:00
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-08 16:13:51 -08:00
|
|
|
|
2020-01-29 16:57:43 +02:00
|
|
|
|
|
|
|
|
|
2019-09-11 20:22:49 -04:00
|
|
|
|
2019-09-25 18:17:29 +03:00
|
|
|
|
2021-08-29 11:57:32 +02:00
|
|
|
|
2019-09-25 18:17:29 +03:00
|
|
|
|
2024-09-25 11:11:48 -07:00
|
|
|
|
2019-09-11 20:22:49 -04:00
|
|
|
|
2022-04-21 10:14:23 +02:00
|
|
|
|
2022-12-15 15:56:13 -07:00
|
|
|
|
2025-09-30 11:06:21 +01:00
|
|
|
|
2025-12-05 15:10:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-09 22:10:12 -08:00
|
|
|
|
|
|
|
|
|
2025-12-09 18:44:39 -08:00
|
|
|
|
2025-09-13 10:29:20 +01:00
|
|
|
|
2026-02-06 04:36:32 -05:00
|
|
|
|
2025-12-18 21:32:34 -08:00
|
|
|
|
2026-04-13 00:43:34 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-04-06 13:01:27 -07:00
|
|
|
|
2026-04-11 22:27:23 -07:00
|
|
|
|
2026-04-06 13:01:27 -07:00
|
|
|
|
2022-04-21 10:14:23 +02:00
|
|
|
|
2022-06-07 17:48:53 -07:00
|
|
|
|
2022-06-08 12:55:24 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-07-19 17:22:10 -07:00
|
|
|
|
2022-06-08 12:55:24 -07:00
|
|
|
|
2022-08-16 16:55:49 +03:00
|
|
|
|
2022-06-07 17:48:53 -07:00
|
|
|
|
2024-05-24 10:34:29 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-06-07 17:48:53 -07:00
|
|
|
|
2022-06-08 12:55:24 -07:00
|
|
|
|
|
|
|
|
|
2022-06-07 17:48:53 -07:00
|
|
|
|
2024-05-24 10:34:29 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-08-16 16:55:49 +03:00
|
|
|
|
2022-06-08 12:55:24 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-06-07 17:48:53 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-06-08 12:55:24 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-06-07 17:48:53 -07:00
|
|
|
|
2022-06-08 12:55:24 -07:00
|
|
|
|
|
|
|
|
|
2022-06-07 17:48:53 -07:00
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
|
|
|
|
|
2026-04-09 15:43:05 -07:00
|
|
|
|
|
|
|
|
|
2025-09-05 19:43:08 +01:00
|
|
|
|
2022-06-07 17:48:53 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-06-08 12:55:24 -07:00
|
|
|
|
|
|
|
|
|
2025-12-17 17:00:41 -08:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2022-10-03 20:04:30 +03:30
|
|
|
|
2023-02-18 09:02:57 -07:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2022-06-07 17:48:53 -07:00
|
|
|
|
|
|
|
|
|
2026-04-09 15:43:05 -07:00
|
|
|
|
2025-10-19 14:08:21 -07:00
|
|
|
|
2026-04-09 15:43:05 -07:00
|
|
|
|
|
|
|
|
|
2022-06-07 17:48:53 -07:00
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2022-06-07 17:48:53 -07:00
|
|
|
|
|
|
|
|
|
2025-12-17 15:47:33 -08:00
|
|
|
|
2022-06-07 17:48:53 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-06-12 00:57:59 -07:00
|
|
|
|
|
|
|
|
|
2025-01-20 02:01:55 +03:00
|
|
|
|
2022-06-12 00:57:59 -07:00
|
|
|
|
2025-08-31 12:48:45 -07:00
|
|
|
|
2025-06-27 20:05:22 -07:00
|
|
|
|
2022-06-12 00:57:59 -07:00
|
|
|
|
2022-11-12 20:03:24 +01:00
|
|
|
|
2022-06-12 00:57:59 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-06-07 17:48:53 -07:00
|
|
|
|
|
|
|
|
|
2024-01-08 00:21:57 -07:00
|
|
|
|
2024-03-16 15:45:10 -07:00
|
|
|
|
2024-10-07 01:16:20 -07:00
|
|
|
|
2024-03-16 15:45:10 -07:00
|
|
|
|
2026-09-04 22:37:27 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-16 15:45:10 -07:00
|
|
|
|
2026-09-04 22:37:27 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-16 15:45:10 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-09-04 22:37:27 -06:00
|
|
|
|
2024-03-16 15:45:10 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-09-04 22:37:27 -06:00
|
|
|
|
2024-03-16 15:45:10 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-09-04 22:37:27 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-03-16 15:45:10 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-10-07 01:16:20 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-09-04 22:37:27 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-10-07 01:16:20 -07:00
|
|
|
|
2024-03-16 15:45:10 -07:00
|
|
|
|
|
|
|
|
|
2024-10-07 01:16:20 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-09-04 22:37:27 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-10-07 01:16:20 -07:00
|
|
|
|
|
|
|
|
|
2024-03-21 14:35:08 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-01-08 00:21:57 -07:00
|
|
|
|
2024-08-02 12:00:08 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-22 09:00:08 +09:00
|
|
|
|
2024-01-08 00:21:57 -07:00
|
|
|
|