Debian Codegraph @

debug/+freebsd/+aarch64/ucontext.ha

raw
1 // SPDX-License-Identifier: MPL-2.0
2 // (c) Hare authors <https://harelang.org>
3
4 use rt;
5
6 def AARCH64_FP: uint = 29; // fp is an alias of r29
7 def AARCH64_LR: uint = 30; // lr is an alias of r30
8
9 // Returns the stack pointer from a ucontext.
10 fn uctx_sp(uctx: *opaque) uintptr = {
11 const uctx = uctx: *rt::ucontext_t;
12 return uctx.uc_mcontext.mc_gpregs.gp_sp: uintptr;
13 };
14
15 // Returns the instruction pointer from a ucontext.
16 fn uctx_ip(uctx: *opaque) uintptr = {
17 const uctx = uctx: *rt::ucontext_t;
18 return uctx.uc_mcontext.mc_gpregs.gp_elr: uintptr;
19 };
20
21 // Returns the current call frame from a ucontext.
22 fn uctx_frame(uctx: *opaque) stackframe = {
23 const uctx = uctx: *rt::ucontext_t;
24 return *(uctx.uc_mcontext.mc_gpregs.gp_x[AARCH64_FP]: uintptr: *stackframe);
25 };