package stack
import "golang.org/x/tools/internal/stack"
Package stack provides support for parsing standard goroutine stack traces.
Index ¶
- func Process(out io.Writer, in io.Reader) error
- type Call
- type Delta
- type Dump
- type Frame
- type Function
- type Goroutine
- type Group
- type Position
- type Scanner
- func NewScanner(r io.Reader) *Scanner
- func (s *Scanner) Done() bool
- func (s *Scanner) Err() error
- func (s *Scanner) Match(re *regexp.Regexp) []string
- func (s *Scanner) Next() string
- func (s *Scanner) Peek() string
- func (s *Scanner) Skip()
- func (s *Scanner) SkipBlank()
- type Stack
- type Summary
Functions ¶
func Process ¶
Process and input stream to an output stream, summarizing any stacks that are detected in place.
Types ¶
type Call ¶
type Call struct { Stack Stack // the shared callstack information Groups []Group // the sets of goroutines with the same state }
Call is set of goroutines that all share the same callstack. They will be grouped by state.
func (Call) Format ¶
type Delta ¶
type Delta struct { Before Dump // The goroutines that were only in the before set. Dump // The goroutines that were in both sets. After Dump // The goroutines that were only in the after set. }
Delta represents the difference between two stack dumps.
func Diff ¶
Diff calculates the delta between two dumps.
type Dump ¶
type Dump []Goroutine
Dump is a raw set of goroutines and their stacks.
func Capture ¶
func Capture() Dump
Capture get the current stack traces from the runtime.
func Parse ¶
Parse the current contiguous block of goroutine stack traces until the scanned content no longer matches.
type Frame ¶
Frame is a point in a call stack.
func (Frame) Format ¶
type Function ¶
type Function struct { Package string // package name of function if known Type string // if set function is a method of this type Name string // function name of the frame }
Function is the function called at a frame.
func (Function) Format ¶
type Goroutine ¶
type Goroutine struct { State string // state that the goroutine is in. ID int // id of the goroutine. Stack Stack // call frames that make up the stack }
Goroutine is a single parsed goroutine dump.
type Group ¶
type Group struct { State string // the shared state of the goroutines Goroutines []Goroutine // the set of goroutines in this group }
Group is a set of goroutines with the same stack that are in the same state.
func (Group) Format ¶
type Position ¶
Position is the file position for a frame.
func (Position) Format ¶
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner splits an input stream into lines in a way that is consumable by the parser.
func NewScanner ¶
NewScanner creates a scanner on top of a reader.
func (*Scanner) Done ¶
Done returns true if the scanner has reached the end of the underlying stream.
func (*Scanner) Err ¶
Err returns true if the scanner has reached the end of the underlying stream.
func (*Scanner) Match ¶
Match returns the submatchs of the regular expression against the next line. If it matched the line is also consumed.
func (*Scanner) Next ¶
Next consumes and returns the next line.
func (*Scanner) Peek ¶
Peek returns the next line without consuming it.
func (*Scanner) Skip ¶
func (s *Scanner) Skip()
Skip consumes the next line without looking at it. Normally used after it has already been looked at using Peek.
func (*Scanner) SkipBlank ¶
func (s *Scanner) SkipBlank()
SkipBlank skips any number of pure whitespace lines.
type Stack ¶
type Stack []Frame
Stack is a set of frames in a callstack.
type Summary ¶
type Summary struct { Total int // the total count of goroutines in the summary Calls []Call // the collated stack traces }
Summary is a set of stacks processed and collated into Calls.
func Summarize ¶
Summarize a dump for easier consumption. This collates goroutines with equivalent stacks.
func (Summary) Format ¶
Source Files ¶
parse.go process.go stack.go
Directories ¶
Path | Synopsis |
---|---|
internal/stack/gostacks | The gostacks command processes stdin looking for things that look like stack traces and simplifying them to make the log more readable. |
internal/stack/stacktest |
- Version
- v0.30.0 (latest)
- Published
- Feb 10, 2025
- Platform
- linux/amd64
- Imports
- 10 packages
- Last checked
- 8 hours ago –
Tools for package owners.