funcgraph

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxParaLen      = funcgraphTraceConstantPARA_LEN
	MaxLenPerTrace  = int(funcgraphTraceConstantMAX_TRACE_DATA)
	MaxTraceDataLen = int(funcgraphTraceConstantMAX_TRACE_BUF)
	MaxTraceCount   = int(funcgraphTraceConstantMAX_TRACES)
)
View Source
const (
	MaxRegParas = 6
)

Variables

View Source
var RegToStr = []string{"rdi", "rsi", "rdx", "rcx", "r8", "r9"}
View Source
var RetReg = "rax"

Functions

func ByteSliceToString

func ByteSliceToString(s []byte) string

func FuncsFromFile

func FuncsFromFile(pattern string) map[Symbol]struct{}

func LoadbtfSpec

func LoadbtfSpec(mod string) (*btf.Spec, error)

func NewDumpOption

func NewDumpOption() (*dumpOption, error)

func ShowBtfFunc

func ShowBtfFunc(fn *btf.Func) (s string)

Types

type Addr

type Addr struct {
	Base  uint32 `parser:"@Number"`
	Index uint32 `parser:"Separator @Number"`
	Scale int32  `parser:"Separator @Number"`
	Imm   int32  `parser:"Separator @Number"`
}

type Arg added in v0.1.0

type Arg struct {
	Name   string
	Kind   ArgKind
	IdxOff uint32
	Size   int
	Typ    btf.Type
}

type ArgKind added in v0.1.0

type ArgKind = funcgraphArgKind
const (
	REG       ArgKind = funcgraphArgKindREG
	STACK     ArgKind = funcgraphArgKindSTACK
	ADDR      ArgKind = funcgraphArgKindADDR
	RET_REG   ArgKind = funcgraphArgKindRET_REG
	RET_STACK ArgKind = funcgraphArgKindRET_STACK
	REG_PTR   ArgKind = funcgraphArgKindREG_PTR
	STACK_PTR ArgKind = funcgraphArgKindSTACK_PTR
)

type CastType added in v0.0.7

type CastType struct {
	Moudle string `parser:"(@Ident Colon)?"`
	Name   string `parser:"@Ident"`
}

type Compare

type Compare struct {
	Operator  string `parser:"Whitespace@Operator"`
	Threshold Value  `parser:"Whitespace@(String|Number)"`
}

type DataExpr

type DataExpr struct {
	Dereference bool     `parser:"@DereferenceOperator?"`
	Typ         CastType `parser:"(LeftEdge Struct Whitespace @@ Whitespace DereferenceOperator RightEdge)?"`
	First       Primary  `parser:"@@"`
	Fields      []Field  `parser:"@@*"`
	ShowString  bool     `parser:"@ShowString?"`
	CompareInfo Compare  `parser:"@@?"`
}

func (DataExpr) String added in v0.1.0

func (d DataExpr) String() string

type Event

type Event uint8
const (
	CallEvent Event = iota
	StartEvent
	EntryEvent
	RetEvent
)

type EventStat

type EventStat uint8
const (
	CallSucess EventStat = iota
	CallDrop
	StartSucess
	StartDrop
	EntrySucess
	EntryDrop
	RetSucess
	RetDrop
)

type Field

type Field struct {
	Name string `parser:"ArrowOperator@(Ident (Period Ident)*)"`
}

type FuncEvent

type FuncEvent struct {
	Type     uint8
	Task     uint64
	CpuId    uint32
	Depth    uint64
	SeqId    uint64
	Ip       uint64
	Id       uint32
	Time     uint64
	Para     [funcgraphTraceConstantPARA_LEN]uint64
	DataLen  uint16
	DataOff  [MaxTraceCount]int16
	Data     *[MaxTraceDataLen]uint8
	Duration uint64
	Ret      [funcgraphTraceConstantPARA_LEN]uint64
}

type FuncEvents

type FuncEvents []FuncEvent

func (*FuncEvents) Add

func (es *FuncEvents) Add(e FuncEvent)

func (*FuncEvents) Reset

func (es *FuncEvents) Reset()

type FuncExpr

type FuncExpr struct {
	Module string     `parser:"(@Ident Colon)?"`
	Name   string     `parser:"@Ident"`
	Datas  []DataExpr `parser:"(LeftEdge@@(Whitespace? Separator Whitespace? @@)*RightEdge)?"`
}

func ParseFuncWithPara

func ParseFuncWithPara(s string) (*FuncExpr, error)

type FuncGraph

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

func NewFuncGraph

func NewFuncGraph(opt *Option) (*FuncGraph, error)

func (*FuncGraph) Init

func (fg *FuncGraph) Init() error

func (*FuncGraph) Run

func (fg *FuncGraph) Run() error

type FuncInfo

type FuncInfo struct {
	IsEntry bool
	Symbol

	Btfinfo *btf.Func
	// contains filtered or unexported fields
}

func (*FuncInfo) GenTraceData added in v0.1.0

func (f *FuncInfo) GenTraceData(dataExpr DataExpr) error

func (*FuncInfo) InitArgsRet added in v0.1.0

func (f *FuncInfo) InitArgsRet()

func (*FuncInfo) ShowPara added in v0.1.0

func (f *FuncInfo) ShowPara(e *FuncEvent, opt *dumpOption, dst *bytes.Buffer)

func (*FuncInfo) ShowRet added in v0.1.0

func (f *FuncInfo) ShowRet(e *FuncEvent, opt *dumpOption, dst *bytes.Buffer)

func (*FuncInfo) ShowRetTrace added in v0.1.0

func (f *FuncInfo) ShowRetTrace(e *FuncEvent, opt *dumpOption, dst *bytes.Buffer)

func (*FuncInfo) ShowTrace added in v0.1.0

func (f *FuncInfo) ShowTrace(e *FuncEvent, opt *dumpOption, dst *bytes.Buffer)

func (*FuncInfo) String added in v0.1.0

func (f *FuncInfo) String() string

type KSymCache

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

func NewKSymCache

func NewKSymCache() (*KSymCache, error)

func (*KSymCache) Iterate

func (k *KSymCache) Iterate() *SymsIterator

func (*KSymCache) SymbolByAddr

func (k *KSymCache) SymbolByAddr(addr uint64) Symbol

type Option

type Option struct {
	EntryFuncs        []string
	AllowFuncs        []string
	DenyFuncs         []string
	EntryFuncsOfDwarf map[Symbol]struct{}
	AllowFuncsOfDwarf map[Symbol]struct{}
	EntryFuncExprs    []*FuncExpr
	AllowFuncExprs    []*FuncExpr
	AllowPids         []int
	DenyPids          []int
	AllowComms        []string
	DenyComms         []string
	Verbose           bool
	BpfLog            bool
	DryRun            bool
	MaxEntries        uint32
	Mode              string
	Target            string
	InheritChild      bool
	Duration          uint64
	Depth             uint64
}

type Primary

type Primary struct {
	Name string `parser:"@Ident"`
	Addr Addr   `parser:"| LeftEdge @@ RightEdge"`
}

type Symbol

type Symbol struct {
	Addr   uint64
	Type   SymbolType
	Name   string
	Module string
}

type SymbolType

type SymbolType int
const (
	FuncType SymbolType = iota
	NonFuncType
)

type SymsIterator

type SymsIterator struct {
	Symbol
	// contains filtered or unexported fields
}

func (*SymsIterator) Next

func (iter *SymsIterator) Next() bool

type TraceData

type TraceData struct {
	IdxOff uint32

	CmpOperator uint8
	Target      uint64
	// contains filtered or unexported fields
}

type Value

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

func (*Value) Capture added in v0.0.8

func (v *Value) Capture(values []string) error

func (Value) ShowSignNumber added in v0.0.8

func (v Value) ShowSignNumber() (int64, error)

func (Value) ShowString added in v0.0.8

func (v Value) ShowString() (string, error)

func (Value) ShowUnsignNumber added in v0.0.8

func (v Value) ShowUnsignNumber() (uint64, error)

func (Value) String

func (v Value) String() string

Jump to

Keyboard shortcuts

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