@@ -985,18 +985,55 @@ type _panic struct {
985
985
goexit bool
986
986
}
987
987
988
- // stack traces
988
+ // A stkframe holds information about a single physical stack frame.
989
989
type stkframe struct {
990
- fn funcInfo // function being run
991
- pc uintptr // program counter within fn
992
- continpc uintptr // program counter where execution can continue, or 0 if not
993
- lr uintptr // program counter at caller aka link register
994
- sp uintptr // stack pointer at pc
995
- fp uintptr // stack pointer at caller aka frame pointer
996
- varp uintptr // top of local variables
997
- argp uintptr // pointer to function arguments
998
- arglen uintptr // number of bytes at argp
999
- argmap * bitvector // force use of this argmap
990
+ // fn is the function being run in this frame. If there is
991
+ // inlining, this is the outermost function.
992
+ fn funcInfo
993
+
994
+ // pc is the program counter within fn.
995
+ //
996
+ // The meaning of this is subtle:
997
+ //
998
+ // - Typically, this frame performed a regular function call
999
+ // and this is the return PC (just after the CALL
1000
+ // instruction). In this case, pc-1 reflects the CALL
1001
+ // instruction itself and is the correct source of symbolic
1002
+ // information.
1003
+ //
1004
+ // - If this frame "called" sigpanic, then pc is the
1005
+ // instruction that panicked, and pc is the correct address
1006
+ // to use for symbolic information.
1007
+ //
1008
+ // - If this is the innermost frame, then PC is where
1009
+ // execution will continue, but it may not be the
1010
+ // instruction following a CALL. This may be from
1011
+ // cooperative preemption, in which case this is the
1012
+ // instruction after the call to morestack. Or this may be
1013
+ // from a signal or an un-started goroutine, in which case
1014
+ // PC could be any instruction, including the first
1015
+ // instruction in a function. Conventionally, we use pc-1
1016
+ // for symbolic information, unless pc == fn.entry(), in
1017
+ // which case we use pc.
1018
+ pc uintptr
1019
+
1020
+ // continpc is the PC where execution will continue in fn, or
1021
+ // 0 if execution will not continue in this frame.
1022
+ //
1023
+ // This is usually the same as pc, unless this frame "called"
1024
+ // sigpanic, in which case it's either the address of
1025
+ // deferreturn or 0 if this frame will never execute again.
1026
+ //
1027
+ // This is the PC to use to look up GC liveness for this frame.
1028
+ continpc uintptr
1029
+
1030
+ lr uintptr // program counter at caller aka link register
1031
+ sp uintptr // stack pointer at pc
1032
+ fp uintptr // stack pointer at caller aka frame pointer
1033
+ varp uintptr // top of local variables
1034
+ argp uintptr // pointer to function arguments
1035
+ arglen uintptr // number of bytes at argp
1036
+ argmap * bitvector // force use of this argmap
1000
1037
}
1001
1038
1002
1039
// ancestorInfo records details of where a goroutine was started.
0 commit comments