hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 3a500c8292e08abc12f8f0cea4506aaa27b4c91c
parent 0bb92fb58983bce02bead90f98a835e883aa02c2
Author: Drew DeVault <sir@cmpwn.com>
Date:   Fri,  4 Nov 2022 14:10:45 +0100

rt: fix rt::backtrace

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Mrt/+riscv64/backtrace.ha | 8++++++--
Mrt/+x86_64/backtrace.ha | 8++++++--
2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/rt/+riscv64/backtrace.ha b/rt/+riscv64/backtrace.ha @@ -10,8 +10,12 @@ export type frame = struct { }; // Returns the current stack frame. See [[nextframe]] to walk the stack. -export fn backtrace() frame = frame { - addr = getfp() +export fn backtrace() frame = { + let fp = frame { + addr = getfp() + }; + // Skip the call to backtrace itself + return nextframe(f) as frame; }; // Returns the frame above the current frame, if any. diff --git a/rt/+x86_64/backtrace.ha b/rt/+x86_64/backtrace.ha @@ -11,8 +11,12 @@ export type frame = struct { }; // Returns the current stack frame. See [[nextframe]] to walk the stack. -export fn backtrace() frame = frame { - addr = getfp() +export fn backtrace() frame = { + let fp = frame { + addr = getfp() + }; + // Skip the call to backtrace itself + return nextframe(fp) as frame; }; // Returns the frame above the current frame, if any.