process

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2025 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package process provides type and functionality for target Go processes.

Index

Constants

View Source
const (
	// MadvisePopulateRead is the MADV_POPULATE_READ advice flag.
	MadvisePopulateRead = 0x16
	// MadvisePopulateWrite is the MADV_POPULATE_WRITE advice flag.
	MadvisePopulateWrite = 0x17
)

Variables

View Source
var ErrDWARFEntry = errors.New("DWARF entry not found")

ErrDWARFEntry is returned if an entry is not found within DWARF data.

View Source
var VerDevel = semver.MustParse("0.0.0-dev")

VerDevel is the placeholder version used for modules that use the development version "(devel)".

Functions

This section is empty.

Types

type Allocation added in v0.22.0

type Allocation struct {
	StartAddr uint64
	EndAddr   uint64
	NumCPU    uint64
}

Allocation represent memory that has been allocated for a process.

type DWARF added in v0.20.0

type DWARF struct {
	Reader *dwarf.Reader
}

DWARF provides convenience in accessing DWARF debugging data.

func (DWARF) Entry added in v0.20.0

func (d DWARF) Entry(tag dwarf.Tag, name string) (*dwarf.Entry, error)

Entry returns the entry with a tag equal to name. ErrDWARFEntry is returned if the entry cannot be found.

func (DWARF) EntryInChildren added in v0.20.0

func (d DWARF) EntryInChildren(tag dwarf.Tag, name string) (*dwarf.Entry, error)

EntryInChildren returns the entry with a tag equal to name within the children of the current entry. ErrDWARFEntry is returned if the entry cannot be found.

func (DWARF) Field added in v0.20.0

func (d DWARF) Field(e *dwarf.Entry, a dwarf.Attr) (dwarf.Field, bool)

Field returns the field from the entry e that has attribute a and true. If no field is found, an empty field is returned with false.

func (DWARF) GoStructField added in v0.20.0

func (d DWARF) GoStructField(id structfield.ID) (int64, error)

GoStructField returns the offset value of a Go struct field. If the struct field cannot be found -1 and a non-nil error will be returned.

func (DWARF) GoToEntry added in v0.20.0

func (d DWARF) GoToEntry(tag dwarf.Tag, name string) bool

GoToEntry reads until the entry with a tag equal to name is found. True is returned if the entry is found, otherwise false is returned.

type ID added in v0.22.0

type ID int

ID represents a process identification number.

func (ID) BuildInfo added in v0.22.0

func (id ID) BuildInfo() (*buildinfo.BuildInfo, error)

BuildInfo returns the Go build info of the process ID executable.

func (id ID) ExeLink() (string, error)

ExeLink returns the resolved absolute path to the linked executable being run by the process.

func (ID) ExePath added in v0.22.0

func (id ID) ExePath() string

ExePath returns the file path for the executable link of the process ID.

func (ID) Tasks added in v0.22.0

func (id ID) Tasks() ([]fs.DirEntry, error)

Tasks returns the task directory contents for the process.

func (ID) Validate added in v0.22.0

func (id ID) Validate() error

Validate returns nil if id represents a valid running process. Otherwise, an error is returned.

type Info added in v0.22.0

type Info struct {
	ID        ID
	Functions []*binary.Func
	// GoVersion is the semantic version of Go run by the target process.
	//
	// Experimental and build information included in the version is dropped.
	// If a development version of Go is used, the commit hash will be included
	// in the metadata of the version.
	GoVersion *semver.Version
	Modules   map[string]*semver.Version
	// contains filtered or unexported fields
}

Info are the details about a target process.

func NewInfo added in v0.22.0

func NewInfo(id ID, relevantFuncs map[string]interface{}) (*Info, error)

NewInfo returns a new Info with information about the process identified by id. The functions of the returned Info are filtered by relevantFuncs.

A partial Info and error may be returned for dependencies that cannot be parsed.

func (*Info) Alloc added in v0.22.0

func (i *Info) Alloc(logger *slog.Logger) (*Allocation, error)

Alloc allocates memory for the process described by Info i.

The underlying memory allocation is only successfully performed once for the instance i. Meaning, it is safe to call this multiple times. The first successful result will be returned to all subsequent calls. If an error is returned, subsequent calls will re-attempt to perform the allocation.

It is safe to call this method concurrently.

func (*Info) GetFunctionOffset added in v0.22.0

func (i *Info) GetFunctionOffset(name string) (uint64, error)

GetFunctionOffset returns the offset for of the function with name.

func (*Info) GetFunctionReturns added in v0.22.0

func (i *Info) GetFunctionReturns(name string) ([]uint64, error)

GetFunctionReturns returns the return value of the call for the function with name.

Directories

Path Synopsis
Package binary provides types and functionality to handle function definitions within a target Go binary.
Package binary provides types and functionality to handle function definitions within a target Go binary.