Skip to content

Commit f00fa0b

Browse files
aclementsgopherbot
authored andcommitted
runtime: document stkframe
The meaning of some of the fields in stkframe is actually quite subtle. Change-Id: Iac765ff6fbf4c3b7c9f2453f5b4a2e5e640f5750 Reviewed-on: https://go-review.googlesource.com/c/go/+/424256 TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Run-TryBot: Austin Clements <[email protected]> Reviewed-by: Michael Pratt <[email protected]> Auto-Submit: Austin Clements <[email protected]>
1 parent 5063056 commit f00fa0b

File tree

1 file changed

+48
-11
lines changed

1 file changed

+48
-11
lines changed

src/runtime/runtime2.go

Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -985,18 +985,55 @@ type _panic struct {
985985
goexit bool
986986
}
987987

988-
// stack traces
988+
// A stkframe holds information about a single physical stack frame.
989989
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
10001037
}
10011038

10021039
// ancestorInfo records details of where a goroutine was started.

0 commit comments

Comments
 (0)