hare

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

backtrace.ha (582B)


      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 	addr: nullable *frame,
     10 };
     11 
     12 // Returns the caller's stack frame. Call [[nextframe]] to walk the stack.
     13 export fn backtrace() frame = *getfp();
     14 
     15 // Returns the frame above the current frame. The current frame must contain a
     16 // non-nullable address.
     17 export fn nextframe(sframe: frame) frame = *(sframe.addr as *frame);