synchronization
This commit is contained in:
30
gpushare-device-plugin/pkg/gpu/nvidia/coredump.go
Normal file
30
gpushare-device-plugin/pkg/gpu/nvidia/coredump.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package nvidia
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"runtime"
|
||||
|
||||
log "github.com/golang/glog"
|
||||
)
|
||||
|
||||
func StackTrace(all bool) string {
|
||||
buf := make([]byte, 10240)
|
||||
|
||||
for {
|
||||
size := runtime.Stack(buf, all)
|
||||
|
||||
if size == len(buf) {
|
||||
buf = make([]byte, len(buf)<<1)
|
||||
continue
|
||||
}
|
||||
break
|
||||
|
||||
}
|
||||
|
||||
return string(buf)
|
||||
}
|
||||
|
||||
func coredump(fileName string) {
|
||||
log.Infoln("Dump stacktrace to ", fileName)
|
||||
ioutil.WriteFile(fileName, []byte(StackTrace(true)), 0644)
|
||||
}
|
Reference in New Issue
Block a user