Documentation
¶
Index ¶
- Constants
- Variables
- func Inspect(f interface{}) (recvPtr interface{}, funcInfo *core.FuncInfo, funcPC uintptr, ...)
- func PushInterceptor(pre PreInterceptor, post PostInterceptor) func()
- func PushMockByName(pkgPath string, funcName string, interceptor Interceptor) func()
- func PushMockInterceptor(fn interface{}, interceptor Interceptor) func()
- func PushMockMethodByName(instance interface{}, method string, interceptor Interceptor) func()
- func PushMockReplacer(fn interface{}, replacer interface{}) func()
- func PushMockReplacerByName(pkgPath string, funcName string, replacer interface{}) func()
- func PushMockReplacerMethodByName(instance interface{}, method string, replacer interface{}) func()
- func PushRecordHandler(pc uintptr, recvPtr interface{}, ...) func()
- func PushRecorder(fn interface{}, pre interface{}, post interface{}) func()
- func PushRecorderInterceptor(fn interface{}, preInterceptor PreInterceptor, postInterceptor PostInterceptor) func()
- func PushVarPtrRecordHandler(varAddr uintptr, ...) func()
- func PushVarRecordHandler(varAddr uintptr, ...) func()
- type Interceptor
- type PostInterceptor
- type PreInterceptor
- type StackData
- type StackDataExportImpl
Constants ¶
const SKIP = 2
skip 2: <user func> -> runtime.XgoTrap -> trap
Variables ¶
var ErrMocked = errors.New("func mocked by xgo")
ErrMocked indicates the target function is mocked
var ErrNotInstrumented = errors.New("not instrumented by xgo, see https://github.com/xhd2015/xgo/tree/master/doc/ERR_NOT_INSTRUMENTED.md")
ErrNotInstrumented is the error returned when a function or variable is not instrumented by xgo. when this error happened, user should check if `--trap` was correctly passed to the xgo compiler for variable, only variables within main module are available, and the variable should be declared with type specified:
var SomeVar int = 10 // good var SomeVar = 10 // bad: xgo cannot generate trap function for untyped variables
and when used as method receiver, should wrap the variable in type conversion:
MyInt(SomeVar).String() // good SomeVar.String() // bad: xgo cannot determine if it is a pointer receiver
check https://github.com/xhd2015/xgo/tree/master/doc/ERR_NOT_INSTRUMENTED.md for more details
Functions ¶
func Inspect ¶
func Inspect(f interface{}) (recvPtr interface{}, funcInfo *core.FuncInfo, funcPC uintptr, trappingPC uintptr)
Inspect inspects the function and returns the receiver pointer, function PC and trapping PC. for ordinary function, `funcPC` is the same with `trappingPC` for method,`funcPC` and `trappingPC` are different, `funcPC` is the PC of the method, which binds a special pointer to its receiver, and `trappingPC` is the PC of the general type method
func PushInterceptor ¶
func PushInterceptor(pre PreInterceptor, post PostInterceptor) func()
func PushMockByName ¶
func PushMockByName(pkgPath string, funcName string, interceptor Interceptor) func()
func PushMockInterceptor ¶
func PushMockInterceptor(fn interface{}, interceptor Interceptor) func()
func PushMockMethodByName ¶
func PushMockMethodByName(instance interface{}, method string, interceptor Interceptor) func()
func PushMockReplacer ¶
func PushMockReplacer(fn interface{}, replacer interface{}) func()
func PushMockReplacerByName ¶
func PushMockReplacerMethodByName ¶
func PushMockReplacerMethodByName(instance interface{}, method string, replacer interface{}) func()
func PushRecordHandler ¶
func PushRecorder ¶
func PushRecorder(fn interface{}, pre interface{}, post interface{}) func()
func PushRecorderInterceptor ¶
func PushRecorderInterceptor(fn interface{}, preInterceptor PreInterceptor, postInterceptor PostInterceptor) func()
func PushVarPtrRecordHandler ¶
Types ¶
type Interceptor ¶
type PostInterceptor ¶
type PreInterceptor ¶
type StackDataExportImpl ¶
type StackDataExportImpl struct {
// contains filtered or unexported fields
}
func (*StackDataExportImpl) Data ¶
func (c *StackDataExportImpl) Data() *stack_model.Stack
func (*StackDataExportImpl) JSON ¶
func (c *StackDataExportImpl) JSON() ([]byte, error)