runtime: clean demo

This commit is contained in:
Li Jie
2025-01-09 09:05:45 +08:00
parent 3d2c014801
commit 68018d8d04
9 changed files with 0 additions and 354 deletions

View File

@@ -1,27 +0,0 @@
package main
import (
c "github.com/goplus/llgo/runtime/internal/clite"
"github.com/goplus/llgo/runtime/internal/clite/debug"
)
type T struct {
n int
}
func (t *T) Demo() {
println(t.n)
addr := debug.Address()
c.Printf(c.Str("addr:0x%x\n"), addr)
var info debug.Info
r := debug.Addrinfo(addr, &info)
if r == 0 {
panic("not found info")
}
c.Printf(c.Str("func file:%s name:%s base:0x%x addr:0x%x\n"), info.Fname, info.Sname, info.Fbase, info.Saddr)
}
func main() {
t := &T{100}
t.Demo()
}

View File

@@ -1,26 +0,0 @@
package main
import (
"unsafe"
"github.com/goplus/llgo/runtime/internal/clite/debug"
)
type T struct {
n int
}
func (t *T) Demo() {
println(t.n)
debug.StackTrace(0, func(fr *debug.Frame) bool {
var info debug.Info
debug.Addrinfo(unsafe.Pointer(fr.PC), &info)
println("[", fr.PC, "]", fr.Name, "+", fr.Offset, ", SP =", fr.SP)
return true
})
}
func main() {
t := &T{100}
t.Demo()
}