示例#1
0
文件: pprof.go 项目: yhtsnda/go
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)
}
示例#2
0
文件: raceprof.go 项目: achanda/go
func CgoRaceprof() {
	runtime.SetCgoTraceback(0, unsafe.Pointer(C.raceprofTraceback), nil, nil)

	var buf bytes.Buffer
	pprof.StartCPUProfile(&buf)

	C.runRaceprofThread()
	fmt.Println("OK")
}
示例#3
0
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")
	}
}
示例#4
0
func CgoPprofThread() {
	runtime.SetCgoTraceback(0, unsafe.Pointer(C.pprofCgoThreadTraceback), nil, nil)
	pprofThread()
}
示例#5
0
文件: traceback.go 项目: yhtsnda/go
func CrashTraceback() {
	runtime.SetCgoTraceback(0, unsafe.Pointer(C.cgoTraceback), nil, unsafe.Pointer(C.cgoSymbolizer))
	C.f1()
}