Skip to content

Commit 3144a5b

Browse files
authored
Implement jl_rec_backtrace for ASM/SETJMP on FreeBSD (#47156)
This removes the message emitted while compiling on FreeBSD that says it isn't supported.
1 parent c63c1e4 commit 3144a5b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/stackwalk.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,19 @@ void jl_rec_backtrace(jl_task_t *t)
10511051
(void)mctx;
10521052
(void)c;
10531053
#endif
1054+
#elif defined(_OS_FREEBSD_) && defined(_CPU_X86_64_)
1055+
sigjmp_buf *mctx = &t->ctx.ctx.uc_mcontext;
1056+
mcontext_t *mc = &c.uc_mcontext;
1057+
// https://github.com/freebsd/freebsd-src/blob/releng/13.1/lib/libc/amd64/gen/_setjmp.S
1058+
mc->mc_rip = ((long*)mctx)[0];
1059+
mc->mc_rbx = ((long*)mctx)[1];
1060+
mc->mc_rsp = ((long*)mctx)[2];
1061+
mc->mc_rbp = ((long*)mctx)[3];
1062+
mc->mc_r12 = ((long*)mctx)[4];
1063+
mc->mc_r13 = ((long*)mctx)[5];
1064+
mc->mc_r14 = ((long*)mctx)[6];
1065+
mc->mc_r15 = ((long*)mctx)[7];
1066+
context = &c;
10541067
#else
10551068
#pragma message("jl_rec_backtrace not defined for ASM/SETJMP on unknown system")
10561069
(void)c;

0 commit comments

Comments
 (0)