mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime/traceback: support tracking goroutine ancestor tracebacks with GODEBUG="tracebackancestors=N"
Currently, collecting a stack trace via runtime.Stack captures the stack for the immediately running goroutines. This change extends those tracebacks to include the tracebacks of their ancestors. This is done with a low memory cost and only utilized when debug option tracebackancestors is set to a value greater than 0. Resolves #22289 Change-Id: I7edacc62b2ee3bd278600c4a21052c351f313f3a Reviewed-on: https://go-review.googlesource.com/70993 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
parent
115b1cd192
commit
d9b006a705
8 changed files with 248 additions and 30 deletions
|
|
@ -378,8 +378,9 @@ type g struct {
|
|||
sigcode0 uintptr
|
||||
sigcode1 uintptr
|
||||
sigpc uintptr
|
||||
gopc uintptr // pc of go statement that created this goroutine
|
||||
startpc uintptr // pc of goroutine function
|
||||
gopc uintptr // pc of go statement that created this goroutine
|
||||
ancestors *[]ancestorInfo // ancestor information goroutine(s) that created this goroutine (only used if debug.tracebackancestors)
|
||||
startpc uintptr // pc of goroutine function
|
||||
racectx uintptr
|
||||
waiting *sudog // sudog structures this g is waiting on (that have a valid elem ptr); in lock order
|
||||
cgoCtxt []uintptr // cgo traceback context
|
||||
|
|
@ -743,6 +744,13 @@ type stkframe struct {
|
|||
argmap *bitvector // force use of this argmap
|
||||
}
|
||||
|
||||
// ancestorInfo records details of where a goroutine was started.
|
||||
type ancestorInfo struct {
|
||||
pcs []uintptr // pcs from the stack of this goroutine
|
||||
goid int64 // goroutine id of this goroutine; original goroutine possibly dead
|
||||
gopc uintptr // pc of go statement that created this goroutine
|
||||
}
|
||||
|
||||
const (
|
||||
_TraceRuntimeFrames = 1 << iota // include frames for internal runtime functions.
|
||||
_TraceTrap // the initial PC, SP are from a trap, not a return PC from a call
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue