wip: process management

This commit is contained in:
2023-08-31 08:05:20 +10:00
parent 9cbdbebee5
commit 92f7873f98
11 changed files with 733 additions and 11 deletions

28
debugframes/frames.go Normal file
View 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
}