Commit 14e3a3b8 authored by Vladimir Barsukov's avatar Vladimir Barsukov
Browse files

add trace

parent 8fc95b40
...@@ -3,7 +3,9 @@ package zdebug ...@@ -3,7 +3,9 @@ package zdebug
import ( import (
"fmt" "fmt"
"git.barsukov.pro/barsukov/zgo/zjson" "git.barsukov.pro/barsukov/zgo/zjson"
"git.barsukov.pro/barsukov/zgo/zutils"
"runtime" "runtime"
"strings"
"time" "time"
) )
...@@ -39,3 +41,24 @@ func NewMonitor(secs int) { ...@@ -39,3 +41,24 @@ func NewMonitor(secs int) {
} }
}() }()
} }
func Trace() []string {
var out []string
pc := make([]uintptr, 10)
runtime.Callers(2, pc)
for i := range pc {
if f := runtime.FuncForPC(pc[i]); f != nil {
file, line := f.FileLine(pc[i])
if strings.Contains(file, "go/pkg") {
continue
}
out = append(out, fmt.Sprintf("%s:%d", f.Name(), line))
}
}
return zutils.ArrayUnique(out)
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment