proc

package
Version: v0.0.0-...-a6e299d Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const POINTER_SIZE = 8

amd64 pointer size

Variables

This section is empty.

Functions

This section is empty.

Types

type G

type G struct {
	ID         uint64         // goid
	Status     gstatus        // atomicstatus
	WaitReason gwaitReason    // if Status ==Gwaiting
	M          *M             // hold worker thread info
	CurLoc     *gbin.Location // runtime location
	UserLoc    *gbin.Location // location of user code, a subset of CurLoc
	GoLoc      *gbin.Location // location of `go` statement that spawed this goroutine
	StartLoc   *gbin.Location // location of goroutine start function
}

G is runtime.g struct parsed from process memory and binary dwarf

func (*G) Dead

func (g *G) Dead() bool

func (*G) GetLocation

func (g *G) GetLocation(pcType string) *gbin.Location

func (*G) Idle

func (g *G) Idle() bool

func (*G) Running

func (g *G) Running() bool

func (*G) String

func (g *G) String() string

func (*G) Syscall

func (g *G) Syscall() bool

func (*G) ThreadID

func (g *G) ThreadID() uint64

func (*G) Waiting

func (g *G) Waiting() bool

type M

type M struct {
	ID     uint64
	ProcID uint64
}

M is runtime.m struct

type P

type P struct {
	ID          int32
	Status      pstatus
	Schedtick   uint32
	Syscalltick uint32
	M           *M
}

P (processor) is runtime.p struct

func (*P) Dead

func (p *P) Dead() bool

func (*P) Gcstop

func (p *P) Gcstop() bool

func (*P) Idle

func (p *P) Idle() bool

func (*P) Running

func (p *P) Running() bool

func (*P) Syscall

func (p *P) Syscall() bool

type PSummary

type PSummary struct {
	BinPath         string
	Gs              []*G
	Ps              []*P
	Sched           *Sched
	ThreadsTotal    int
	ThreadsSleeping int
	ThreadsStopped  int
	ThreadsRunning  int
	ThreadsZombie   int
	GTotal          int
	GIdle           int
	GRunning        int
	GSyscall        int
	GWaiting        int
	GoVersion       string
	Gomaxprocs      int
}

PSummary holds process summary info

func (PSummary) String

func (s PSummary) String() string

type Process

type Process struct {
	ID int
	// contains filtered or unexported fields
}

Process wrap operations on target process

func New

func New(pid int, bin string) (*Process, error)

New a Process struct for target pid

func (*Process) Attach

func (p *Process) Attach() error

Attach will attach to all threads

func (*Process) Detach

func (p *Process) Detach() error

func (*Process) GetGs

func (p *Process) GetGs(lock bool) ([]*G, error)

GetGs return goroutines

func (*Process) GetPs

func (p *Process) GetPs(lock bool) ([]*P, error)

GetPs return P's in runtime.allp

func (*Process) GetThread

func (p *Process) GetThread(id int) (t *Thread, ok bool)

GetThread will return target thread on id

func (*Process) GoVersion

func (p *Process) GoVersion() (string, error)

func (*Process) Gomaxprocs

func (p *Process) Gomaxprocs() (int, error)

func (*Process) ReadData

func (p *Process) ReadData(data []byte, addr uint64) error

func (*Process) ReadVMA

func (p *Process) ReadVMA(addr uint64) (uint64, error)

ReadVM will read virtual memory at addr TODO handle PIE?

func (*Process) SchedInfo

func (p *Process) SchedInfo() (*Sched, error)

func (*Process) Summary

func (p *Process) Summary(lock bool) (*PSummary, error)

Summary process info

type Sched

type Sched struct {
	Nmidle     int32 // number of idle m's waiting for work
	Nmspinning uint32
	Nmfreed    uint32 // cumulative number of freed m's
	Npidle     int32  // number of idle p's
	Ngsys      uint32 // number of system goroutines
	Runqsize   int32  // global runnable queue size
}

Sched is the global goroutine scheduler

type Thread

type Thread struct {
	ID int
	// contains filtered or unexported fields
}

Thread wrap operations on a system thread

func NewThread

func NewThread(tid int, proc *Process) (*Thread, error)

func (*Thread) Attach

func (t *Thread) Attach() error

func (*Thread) Detach

func (t *Thread) Detach() error

func (*Thread) Registers

func (t *Thread) Registers() (*syscall.PtraceRegs, error)

Registers will return thread register address via syscall PTRACE_GETREGS

func (*Thread) Running

func (t *Thread) Running() bool

func (*Thread) Sleeping

func (t *Thread) Sleeping() bool

func (*Thread) State

func (t *Thread) State() string

func (*Thread) Stopped

func (t *Thread) Stopped() bool

func (*Thread) Zombie

func (t *Thread) Zombie() bool

Jump to

Keyboard shortcuts

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