github.com/primecitizens/pcz/std@v0.2.1/core/stack/frame.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 4 package stack 5 6 import ( 7 "github.com/primecitizens/pcz/std/core/abi" 8 ) 9 10 // A Frame holds information about a single stack frame. 11 // 12 // see $GOROOT/src/runtime/symtab.go#stkframe 13 type Frame struct { 14 // fn is the function being run in this frame. If there is 15 // inlining, this is the outermost function. 16 fn abi.FuncInfo 17 18 // pc is the program counter within fn. 19 // 20 // The meaning of this is subtle: 21 // 22 // - Typically, this frame performed a regular function call 23 // and this is the return PC (just after the CALL 24 // instruction). In this case, pc-1 reflects the CALL 25 // instruction itself and is the correct source of symbolic 26 // information. 27 // 28 // - If this frame "called" sigpanic, then pc is the 29 // instruction that panicked, and pc is the correct address 30 // to use for symbolic information. 31 // 32 // - If this is the innermost frame, then PC is where 33 // execution will continue, but it may not be the 34 // instruction following a CALL. This may be from 35 // cooperative preemption, in which case this is the 36 // instruction after the call to morestack. Or this may be 37 // from a signal or an un-started goroutine, in which case 38 // PC could be any instruction, including the first 39 // instruction in a function. Conventionally, we use pc-1 40 // for symbolic information, unless pc == fn.entry(), in 41 // which case we use pc. 42 pc uintptr 43 44 // continpc is the PC where execution will continue in fn, or 45 // 0 if execution will not continue in this frame. 46 // 47 // This is usually the same as pc, unless this frame "called" 48 // sigpanic, in which case it's either the address of 49 // deferreturn or 0 if this frame will never execute again. 50 // 51 // This is the PC to use to look up GC liveness for this frame. 52 continpc uintptr 53 54 lr uintptr // program counter at caller aka link register 55 sp uintptr // stack pointer at pc 56 fp uintptr // stack pointer at caller aka frame pointer 57 varp uintptr // top of local variables 58 argp uintptr // pointer to function arguments 59 }