stacktrace

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package stacktrace provides support for gathering stack traces efficiently.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Take

func Take(skip int, depth Depth) string

Take 返回当前 Stack 的字符串表示形式

skip 表示要跳过的帧数,skip=0 标识 跳过 Take

Types

type Depth

type Depth int

Depth 指定应捕获堆栈的深度

const (
	// First 捕获第一帧
	First Depth = iota

	// Full 捕获所有帧
	Full
)

type Formatter

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

Formatter formats a stack trace into a readable string representation.

func NewFormatter

func NewFormatter(b *buffer.Buffer) Formatter

NewFormatter builds a new Formatter.

func (*Formatter) FormatFrame

func (sf *Formatter) FormatFrame(frame runtime.Frame)

FormatFrame formats the given frame.

func (*Formatter) FormatStack

func (sf *Formatter) FormatStack(stack *Stack)

FormatStack formats all remaining frames in the provided stacktrace

type Stack

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

Stack 捕获堆栈信息

func Capture

func Capture(skip int, depth Depth) *Stack

Capture 捕获指定 Depth 的堆栈跟踪,跳过提供的帧数。 skip = 0 标识捕获的调用方

func (*Stack) Count

func (st *Stack) Count() int

Count reports the total number of frames in this stacktrace. Count DOES NOT change as Next is called.

func (*Stack) Free

func (st *Stack) Free()

Free releases resources associated with this stacktrace and returns it back to the pool.

func (*Stack) Next

func (st *Stack) Next() (_ runtime.Frame, more bool)

Next returns the next frame in the stack trace, and a boolean indicating whether there are more after it.

Jump to

Keyboard shortcuts

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