Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,20 +269,6 @@ func (ctx *Context) SetPanic(fn func(*PanicInfo)) {

type Frame = frame

func (fr *Frame) CallerFrames() (frames []runtime.Frame) {
rpc := make([]uintptr, 64)
n := runtimeCallers(fr, 1, rpc)
fs := runtime.CallersFrames(rpc[:n])
for {
f, more := runtimeFramesNext(fr, fs)
frames = append(frames, f)
if !more {
break
}
}
return
}

type PanicInfo struct {
funcInstr
*Frame
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ go 1.24.0
require (
github.com/goplus/gogen v1.23.3
github.com/goplus/mod v0.20.2
github.com/goplus/reflectx v1.7.0
github.com/goplus/reflectx v1.7.1-0.20260701065815-36c179f3d48f
github.com/goplus/xgo v1.7.3
github.com/peterh/liner v1.2.2
github.com/qiniu/x v1.18.0
github.com/visualfc/funcval v0.1.4
github.com/visualfc/funcval v0.1.5
github.com/visualfc/gid v0.3.1
github.com/visualfc/goembed v0.3.4
github.com/visualfc/xtype v0.3.0
github.com/visualfc/xtype v0.3.1
golang.org/x/mod v0.32.0
golang.org/x/tools v0.41.0
)
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ github.com/goplus/gogen v1.23.3 h1:cyw16r8LYsqIeJUobTy/1mv9abUDxsR+ghh0dEZgaRw=
github.com/goplus/gogen v1.23.3/go.mod h1:Y7ulYW3wonQ3d9er00b0uGFEV/IUZa6okWJZh892ACQ=
github.com/goplus/mod v0.20.2 h1:YX72E6AhhRLvlkVnI9cBK6PZvUwtge2hwROh7w9N6Yk=
github.com/goplus/mod v0.20.2/go.mod h1:lWW62tH7L3Vm42Lr6wlUMYHvsm5w3TkEpE2ulKTgmU8=
github.com/goplus/reflectx v1.7.0 h1:52l0Si+vDc6CvT7Y+h47h2QUs5HQp6qxPlmvLsMzo38=
github.com/goplus/reflectx v1.7.0/go.mod h1:EXX8KSPTmnb2W1PfyVkDC0Qwet0lYX2h2/S06Vhwrhw=
github.com/goplus/reflectx v1.7.1-0.20260701065815-36c179f3d48f h1:4upO/ye5DPg0NT9wp5NDRRdwrRiXnq9EwXSa2wxoOxo=
github.com/goplus/reflectx v1.7.1-0.20260701065815-36c179f3d48f/go.mod h1:EXX8KSPTmnb2W1PfyVkDC0Qwet0lYX2h2/S06Vhwrhw=
github.com/goplus/xgo v1.7.3 h1:rG/dBjbld8r1O94m6qtIOsBvpF1kHPrd4+NtcCVOemU=
github.com/goplus/xgo v1.7.3/go.mod h1:F/+bGBARd1rIyD5pl1BgqGViRKUh5w03pbk0sPHb9a8=
github.com/mattn/go-runewidth v0.0.3 h1:a+kO+98RDGEfo6asOGMmpodZq4FNtnGP54yps8BzLR4=
Expand All @@ -32,14 +32,14 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/timandy/routine v1.1.6 h1:cueNRVPutK8O6387LL7dmYPLNyS6aKlPCPi5qWCLdc8=
github.com/timandy/routine v1.1.6/go.mod h1:kXslgIosdY8LW0byTyPnenDgn4/azt2euufAq9rK51w=
github.com/visualfc/funcval v0.1.4 h1:lAI88zQYfRzmC7mKF4+swXeCZvb8wb1f3lMSDRAY2mQ=
github.com/visualfc/funcval v0.1.4/go.mod h1:3Izv+irhArmrTvy+lmL6pIq16gSOzx73CIka51J9eR0=
github.com/visualfc/funcval v0.1.5 h1:jR21zdx0pFk4nUzmutrFZL6EiRuMYR/ZaD+KOzTwyEk=
github.com/visualfc/funcval v0.1.5/go.mod h1:3Izv+irhArmrTvy+lmL6pIq16gSOzx73CIka51J9eR0=
github.com/visualfc/gid v0.3.1 h1:wWnU17tIBISc7sbbfRxNIg0rdfJUqANZYeX04KbbhlU=
github.com/visualfc/gid v0.3.1/go.mod h1:vpt7mMzO6Mst8v6T4vCSTPKzrNwfVsaDZQ12T4eQT8o=
github.com/visualfc/goembed v0.3.4 h1:foORJ0KT/pKwA23dStPFOtxaW7F96PnNSiLXHVXrfVk=
github.com/visualfc/goembed v0.3.4/go.mod h1:jCVCz/yTJGyslo6Hta+pYxWWBuq9ADCcIVZBTQ0/iVI=
github.com/visualfc/xtype v0.3.0 h1:K0Oo5XMcSjv+ohqn8L6RjgOZ9dNwfzPv3/AIV1SXRfA=
github.com/visualfc/xtype v0.3.0/go.mod h1:VYIH9S2bmdWKlBb7c725ES6yKF9+pyHBU2SFNqGVMGM=
github.com/visualfc/xtype v0.3.1 h1:a6eEoil4AFwDqz403+5jzoVf2mRHycgS5nh4L7dly1w=
github.com/visualfc/xtype v0.3.1/go.mod h1:VYIH9S2bmdWKlBb7c725ES6yKF9+pyHBU2SFNqGVMGM=
golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c=
golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU=
golang.org/x/net v0.50.0 h1:ucWh9eiCGyDR3vtzso0WMQinm2Dnt8cFMuQa9K33J60=
Expand Down
16 changes: 16 additions & 0 deletions runtime.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !llgo

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding //go:build !llgo here excludes the entire file — including its init() — under the llgo tag. That init() registers interpreter-critical externals (os.Exit via interp.chexit, runtime.Goexit, runtime.Caller/Callers/FuncForPC/Stack, runtime/debug.Stack/PrintStack, and the funcval (reflect.Value).Pointer override) that are NOT re-provided by runtime_llgo.go. Under llgo, an interpreted os.Exit(N) would call the real os.Exit and hard-exit the host without returning an exit code. Add a replacement init() in runtime_llgo.go (at least os.Exit/runtime.Goexit) or document why these are intentionally dropped.

Minor: the rest of the repo pairs this with the legacy // +build !llgo line for consistency.


/*
* Copyright (c) 2022 The GoPlus Authors (goplus.org). All rights reserved.
*
Expand Down Expand Up @@ -395,3 +397,17 @@ func inlineFunc(entry uintptr) *funcinl {
func isInlineFunc(f *runtime.Func) bool {
return (*funcinl)(unsafe.Pointer(f)).ones == ^uint32(0)
}

func (fr *Frame) CallerFrames() (frames []runtime.Frame) {
rpc := make([]uintptr, 64)
n := runtimeCallers(fr, 1, rpc)
fs := runtime.CallersFrames(rpc[:n])
for {
f, more := runtimeFramesNext(fr, fs)
frames = append(frames, f)
if !more {
break
}
}
return
}
14 changes: 14 additions & 0 deletions runtime_llgo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//go:build llgo
// +build llgo

package ixgo

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing license header: every other file in the package root carries the GoPlus Authors Apache-2.0 copyright block; this new file has none. Add it for consistency.


import "runtime"

func runtimeGC(fr *frame) {
runtime.GC()
}

func debugStack(fr *frame) []byte {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debugStack silently returns nil under llgo. Its result is stored in PanicError.stack/FatalError.stack (see builtin.go, opblock.go, interp.go), so panic/fatal stack traces will be empty under llgo. Acceptable as a known limitation, but add a brief comment stating that stack introspection is unsupported under llgo and the empty result is intentional.

return nil
}
Comment on lines +5 to +14

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Under the llgo build tag, runtime.go is excluded, which means its init() function is not executed. As a result, debugStack is defined here but never registered with RegisterExternal. Additionally, CallerFrames is an exported method on Frame (defined in context.go), and excluding it entirely under llgo breaks API compatibility for downstream consumers.

To fix these issues, we should:

  1. Add an init() function to register debugStack.
  2. Implement a stub for CallerFrames on Frame to maintain API compatibility.
Suggested change
import "runtime"
func runtimeGC(fr *frame) {
runtime.GC()
}
func debugStack(fr *frame) []byte {
return nil
}
import "runtime"
func init() {
RegisterExternal("runtime/debug.Stack", debugStack)
}
func runtimeGC(fr *frame) {
runtime.GC()
}
func debugStack(fr *frame) []byte {
return nil
}
func (fr *Frame) CallerFrames() (frames []runtime.Frame) {
return nil
}

Loading