hare

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

backtrace.ha (601B)


      1 // SPDX-License-Identifier: MPL-2.0
      2 // (c) Hare authors <https://harelang.org>
      3 
      4 fn getfp() *frame;
      5 
      6 // Details for a stack frame. A null address indicates that you've reached the
      7 // top of the stack. Contents are architecture-specific.
      8 export type frame = struct {
      9 	fp: nullable *frame,
     10 	lr: nullable *opaque,
     11 };
     12 
     13 // Returns the caller's stack frame. Call [[nextframe]] to walk the stack.
     14 export fn backtrace() frame = *getfp();
     15 
     16 // Returns the frame above the current frame. The current frame must contain a
     17 // non-nullable address.
     18 export fn nextframe(sframe: frame) frame = *(sframe.fp as *frame);