runtime: runtime.Callers, runtime.CallersFrames

This commit is contained in:
Li Jie
2025-02-15 00:17:01 +08:00
parent c6462cbcc7
commit 8116d34a60
3 changed files with 85 additions and 3 deletions

View File

@@ -4,10 +4,26 @@
package runtime
import (
"github.com/goplus/llgo/runtime/internal/clite/debug"
)
func Caller(skip int) (pc uintptr, file string, line int, ok bool) {
panic("todo: runtime.Caller")
}
func Callers(skip int, pc []uintptr) int {
panic("todo: runtime.Callers")
if len(pc) == 0 {
return 0
}
n := 0
debug.StackTrace(skip, func(fr *debug.Frame) bool {
if n >= len(pc) {
return false
}
pc[n] = fr.PC
n++
return true
})
return n
}