2025-09-02 18:36:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-02 18:47:31 +01:00
|
|
|
|
2025-09-02 18:36:05 +01:00
|
|
|
|
|
|
|
|
|
2025-09-09 14:20:49 +01:00
|
|
|
|
|
|
|
|
|
2025-09-04 00:39:38 +01:00
|
|
|
|
2025-09-02 18:36:05 +01:00
|
|
|
|
|
|
|
|
|
2025-09-09 14:20:49 +01:00
|
|
|
|
2025-09-04 00:39:38 +01:00
|
|
|
|
2025-09-02 18:36:05 +01:00
|
|
|
|
2025-09-02 18:47:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-02 18:36:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-03 15:42:33 +01:00
|
|
|
|
2025-09-02 18:36:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-09 14:20:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-03 15:42:33 +01:00
|
|
|
|
2025-09-09 14:20:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-03 15:42:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-02 18:36:05 +01:00
|
|
|
|
|
|
|
|
|
2025-09-09 14:20:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-03 15:42:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-09 14:20:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-03 15:42:33 +01:00
|
|
|
|
|
|
|
|
|
2025-09-09 14:20:49 +01:00
|
|
|
|
|
|
|
|
|
2025-09-03 15:42:33 +01:00
|
|
|
|
|
|
|
|
|
2025-09-09 14:20:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-03 15:42:33 +01:00
|
|
|
|
2025-09-09 14:20:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-02 18:36:05 +01:00
|
|
|
|
2025-09-03 15:42:33 +01:00
|
|
|
|
2025-09-09 14:20:49 +01:00
|
|
|
|
2025-09-02 18:36:05 +01:00
|
|
|
|
2025-09-09 14:20:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-03 15:42:33 +01:00
|
|
|
|
2025-09-02 18:36:05 +01:00
|
|
|
|
2025-09-04 00:39:38 +01:00
|
|
|
|
2025-09-03 15:42:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-04 00:39:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-11 13:42:51 +01:00
|
|
|
|
2025-09-04 00:39:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-09 14:20:49 +01:00
|
|
|
|
2025-09-04 00:39:38 +01:00
|
|
|
|
|
|
|
|
|
2025-09-11 13:42:51 +01:00
|
|
|
|
2025-09-04 00:39:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-11 13:42:51 +01:00
|
|
|
|
|
|
|
|
|
2025-09-04 00:39:38 +01:00
|
|
|
|
2025-09-11 13:42:51 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-04 00:39:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-02 18:36:05 +01:00
|
|
|
|
2025-09-18 13:32:47 +01:00
|
|
|
|
2025-09-04 00:39:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-08 11:38:25 +01:00
|
|
|
|
2025-09-04 00:39:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-02 18:36:05 +01:00
|
|
|
|
2025-09-08 20:08:28 +01:00
|
|
|
|
2025-09-05 21:28:18 +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 21:28:18 +01:00
|
|
|
|
|
|
|
|
|
2025-09-02 18:36:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-09-09 14:20:49 +01:00
|
|
|
|
2025-09-02 18:36:05 +01:00
|
|
|
|
|
|
|
|
|
2025-09-03 15:42:33 +01:00
|
|
|
|
2025-09-02 18:36:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|