func (s *PySpy) Snapshot(cb func(*spy.Labels, []byte, uint64, error)) {
	r := C.pyspy_snapshot(C.int(s.pid), s.dataPtr, C.int(bufferLength), s.errorPtr, C.int(bufferLength))
	if r < 0 {
		cb(nil, nil, 0, errors.New(string(s.errorBuf[:-r])))
	} else {
		arr := bytes.Split(s.dataBuf[:r], []byte("\n;"))
		for _, s := range arr {
			if len(s) > 0 {
				cb(nil, s, 1, nil)
			}
		}
	}
}
Snapshot calls callback function with stack-trace or error.
package pyspy
import "C"
import (
	"bytes"
	"errors"
	"time"
	"unsafe"
	"github.com/pyroscope-io/pyroscope/pkg/agent/spy"
)
var bufferLength = 1024 * 64
var Blocking bool
type PySpy struct {
	dataPtr unsafe.Pointer
	dataBuf []byte
	errorBuf []byte
	errorPtr unsafe.Pointer
	pid int
}
func Start(pid int, _ spy.ProfileType, _ uint32, _ bool) (spy.Spy, error) {
	dataBuf := make([]byte, bufferLength)
	dataPtr := unsafe.Pointer(&dataBuf[0])
	errorBuf := make([]byte, bufferLength)
	errorPtr := unsafe.Pointer(&errorBuf[0])
	time.Sleep(1 * time.Second)
	blocking := 0
	if Blocking {
		blocking = 1
	}
	r := C.pyspy_init(C.int(pid), C.int(blocking), errorPtr, C.int(bufferLength))
	if r < 0 {
		return nil, errors.New(string(errorBuf[:-r]))
	}
	return &PySpy{
		dataPtr:  dataPtr,
		dataBuf:  dataBuf,
		errorBuf: errorBuf,
		errorPtr: errorPtr,
		pid:      pid,
	}, nil
}
func (s *PySpy) Stop() error {
	r := C.pyspy_cleanup(C.int(s.pid), s.errorPtr, C.int(bufferLength))
	if r < 0 {
		return errors.New(string(s.errorBuf[:-r]))
	}
	return nil
}