runtime: runtime.Callers, runtime.CallersFrames
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user