...

Package stack

import "golang.org/x/tools/internal/stack"
Overview
Index
Subdirectories

Overview ▾

Package stack provides support for parsing standard goroutine stack traces.

func Process

func Process(out io.Writer, in io.Reader) error

Process and input stream to an output stream, summarizing any stacks that are detected in place.

type Call

Call is set of goroutines that all share the same callstack. They will be grouped by state.

type Call struct {
    Stack  Stack   // the shared callstack information
    Groups []Group // the sets of goroutines with the same state
}

func (Call) Format

func (c Call) Format(w fmt.State, r rune)

type Delta

Delta represents the difference between two stack dumps.

type Delta struct {
    Before Dump // The goroutines that were only in the before set.
    Shared Dump // The goroutines that were in both sets.
    After  Dump // The goroutines that were only in the after set.
}

func Diff

func Diff(before, after Dump) Delta

Diff calculates the delta between two dumps.

type Dump

Dump is a raw set of goroutines and their stacks.

type Dump []Goroutine

func Capture

func Capture() Dump

Capture get the current stack traces from the runtime.

func Parse

func Parse(scanner *Scanner) (Dump, error)

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.

type Frame struct {
    Function Function
    Position Position
}

func (Frame) Format

func (f Frame) Format(w fmt.State, c rune)

type Function

Function is the function called at a frame.

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
}

func (Function) Format

func (f Function) Format(w fmt.State, c rune)

type Goroutine

Goroutine is a single parsed goroutine dump.

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
}

type Group

Group is a set of goroutines with the same stack that are in the same state.

type Group struct {
    State      string      // the shared state of the goroutines
    Goroutines []Goroutine // the set of goroutines in this group
}

func (Group) Format

func (g Group) Format(w fmt.State, r rune)

type Position

Position is the file position for a frame.

type Position struct {
    Filename string // source filename
    Line     int    // line number within file
}

func (Position) Format

func (p Position) Format(w fmt.State, c rune)

type Scanner

Scanner splits an input stream into lines in a way that is consumable by the parser.

type Scanner struct {
    // contains filtered or unexported fields
}

func NewScanner

func NewScanner(r io.Reader) *Scanner

NewScanner creates a scanner on top of a reader.

func (*Scanner) Done

func (s *Scanner) Done() bool

Done returns true if the scanner has reached the end of the underlying stream.

func (*Scanner) Err

func (s *Scanner) Err() error

Err returns true if the scanner has reached the end of the underlying stream.

func (*Scanner) Match

func (s *Scanner) Match(re *regexp.Regexp) []string

Match returns the submatchs of the regular expression against the next line. If it matched the line is also consumed.

func (*Scanner) Next

func (s *Scanner) Next() string

Next consumes and returns the next line.

func (*Scanner) Peek

func (s *Scanner) Peek() string

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

Stack is a set of frames in a callstack.

type Stack []Frame

type Summary

Summary is a set of stacks processed and collated into Calls.

type Summary struct {
    Total int    // the total count of goroutines in the summary
    Calls []Call // the collated stack traces
}

func Summarize

func Summarize(dump Dump) Summary

Summarize a dump for easier consumption. This collates goroutines with equivalent stacks.

func (Summary) Format

func (s Summary) Format(w fmt.State, r rune)

Subdirectories

Name Synopsis
..