stack

package
v0.38.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2024 License: Apache-2.0, MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StackFrame

type StackFrame struct {
	// Function provides the name of the function being called, or the empty string if unknown.
	Function string
	// File gives the name of the file, or an empty string if the file is unknown.
	File string
	// Line gives the line number (starting from 1), or zero if the line number is unknown.
	Line int
}

Individual stack frame, contained in a StackTrace, produced by GetStackTrace.

type StackTrace

type StackTrace struct {
	// Frames provides the frames of this stack trace. Each frame's caller is at the index following
	// it; the first frame is the direct caller.
	Frames []StackFrame
	// Parent, if not nil, provides the "parent" stack trace - typically the stack trace at the
	// point this goroutine was spawned.
	Parent *StackTrace
}

StackTrace represents a collected stack trace, possibly with a parent (i.e caller)

StackTraces are designed to make it easy to track callers across goroutines. They are typically produced by GetStackTrace; refer to that function for more information.

func GetStackTrace

func GetStackTrace(parent *StackTrace, skip uint) StackTrace

GetStackTrace produces a StackTrace, optionally with a parent's stack trace to append.

skip sets the number of initial calling stack frames to exclude. Setting skip to zero will produce a StackTrace where the first StackFrame represents the location where GetStackTrace was called.

func (StackTrace) String

func (st StackTrace) String() string

String produces a string representation of the stack trace, roughly similar to the default panic handler's.

For some examples of formatting, refer to the StackTrace tests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL