proc

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatDuration added in v0.7.0

func FormatDuration(d time.Duration) string

FormatDuration formats a duration into a human-readable string showing days, hours, minutes and seconds as appropriate

Types

type G

type G struct {
	Address       uint64 `json:"address"`         // goroutine structure address
	Goid          int64  `json:"go_id"`           // goroutine ID
	Status        string `json:"status"`          // goroutine status
	WaitReason    string `json:"wait_reason"`     // wait reason
	Stack         Stack  `json:"stack"`           // Stack info
	M             uint64 `json:"-"`               // associated M structure address
	Sched         Sched  `json:"sched"`           // scheduling info
	AtomicStatus  uint32 `json:"-"`               // raw status value
	FuncName      string `json:"func_name"`       // currently running function name
	StartPC       uint64 `json:"start_pc"`        // starting function address
	StartFuncName string `json:"start_func_name"` // starting function name
}

type MemStat

type MemStat struct {

	// Garbage collector statistics
	// NextGC        uint64 // next collection will happen when HeapAlloc ≥ this amount
	LastGC       uint64      `json:"last_gc"` // end time of last collection (unixtimestamp in seconds)
	PauseTotalNs uint64      `json:"pause_total_ns"`
	PauseNs      [256]uint64 `json:"-"` // circular buffer of recent GC pause durations
	PauseEnd     [256]uint64 `json:"-"` // circular buffer of recent GC pause end times
	NumGC        uint32      `json:"num_gc"`
}

type P

type P struct {
	Address   uint64 `json:"address"`    // P structure address
	ID        int32  `json:"id"`         // P ID
	Status    string `json:"status"`     // P status
	MCache    uint64 `json:"m_cache"`    // Per-P cache for small objects
	SchedTick uint32 `json:"sched_tick"` // Tick counter for scheduler
}

type ProcessMemReader added in v0.7.0

type ProcessMemReader interface {
	io.ReaderAt
	Close() error
	RuntimeInfo() (*Runtime, error)
	Goroutines(showDead bool) ([]G, error)
	GetGoroutineStackTraceByGoID(goid int64) ([]StackFrame, error)
	Ps() ([]P, error)
	MemStat() (*MemStat, error)
}

func NewProcessMemReader added in v0.7.0

func NewProcessMemReader(pid int, binPath string) (ProcessMemReader, error)

NewProcessMemReader creates a new memory reader for the specified process. On Linux it uses /proc/<pid>/mem, on Darwin it uses mach_vm_read.

type Runtime added in v0.7.0

type Runtime struct {
	InitTime  int64  `json:"-"`          // when runtime was initialized(monotime)
	GoVersion string `json:"go_version"` // Go runtime version
}

G represents a goroutine with detailed information

func (Runtime) Uptime added in v0.7.0

func (r Runtime) Uptime() time.Duration

type Sched

type Sched struct {
	PC uint64 `json:"pc"` // program counter
	SP uint64 `json:"sp"` // stack pointer
}

type Stack added in v0.7.0

type Stack struct {
	Lo uint64 `json:"lo"`
	Hi uint64 `json:"hi"`
}

type StackFrame added in v0.8.0

type StackFrame struct {
	PC       uint64
	SP       uint64
	Function string
	File     string
	Line     int
	Func     *gosym.Func // Store the gosym Func for potential later use
}