func CgoPprof() { runtime.SetCgoTraceback(0, unsafe.Pointer(C.pprofCgoTraceback), nil, nil) f, err := ioutil.TempFile("", "prof") if err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(2) } if err := pprof.StartCPUProfile(f); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(2) } t0 := time.Now() for C.getCpuHogCount() < 2 && time.Since(t0) < time.Second { C.cpuHog() } pprof.StopCPUProfile() name := f.Name() if err := f.Close(); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(2) } fmt.Println(name) }
func CgoRaceprof() { runtime.SetCgoTraceback(0, unsafe.Pointer(C.raceprofTraceback), nil, nil) var buf bytes.Buffer pprof.StartCPUProfile(&buf) C.runRaceprofThread() fmt.Println("OK") }
func TracebackContext() { runtime.SetCgoTraceback(0, unsafe.Pointer(C.tcTraceback), unsafe.Pointer(C.tcContext), unsafe.Pointer(C.tcSymbolizer)) C.C1() if got := C.getContextCount(); got != 0 { fmt.Printf("at end contextCount == %d, expected 0\n", got) tracebackOK = false } if tracebackOK { fmt.Println("OK") } }
func CgoPprofThread() { runtime.SetCgoTraceback(0, unsafe.Pointer(C.pprofCgoThreadTraceback), nil, nil) pprofThread() }
func CrashTraceback() { runtime.SetCgoTraceback(0, unsafe.Pointer(C.cgoTraceback), nil, unsafe.Pointer(C.cgoSymbolizer)) C.f1() }