wip: process management
This commit is contained in:
28
debugframes/frames.go
Normal file
28
debugframes/frames.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package debugframes
|
||||
|
||||
import "runtime"
|
||||
|
||||
type Trace struct {
|
||||
Frames []runtime.Frame
|
||||
}
|
||||
|
||||
func (t *Trace) Error() string {
|
||||
return "[debug trace available]"
|
||||
}
|
||||
|
||||
func GetTraces() error {
|
||||
trace := new(Trace)
|
||||
pc := make([]uintptr, 16)
|
||||
|
||||
if n := runtime.Callers(2, pc); n > 0 {
|
||||
frames := runtime.CallersFrames(pc[:n])
|
||||
for {
|
||||
frame, more := frames.Next()
|
||||
trace.Frames = append(trace.Frames, frame)
|
||||
if !more {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return trace
|
||||
}
|
||||
Reference in New Issue
Block a user