Initial commit

This commit is contained in:
Trevor Slocum 2024-09-21 11:42:30 -07:00
commit 0fb5bbfd18
3 changed files with 85 additions and 0 deletions

50
edebug.go Normal file
View file

@ -0,0 +1,50 @@
package edebug
import (
"fmt"
"image"
"log"
"runtime/debug"
"bou.ke/monkey"
"github.com/hajimehoshi/ebiten/v2"
)
var verbose bool
func printCall(message string) {
log.Println(message)
if !verbose {
return
}
debug.PrintStack()
}
func SetVerbose(v bool) {
verbose = v
}
func Start() {
{
var g *monkey.PatchGuard
g = monkey.Patch(ebiten.NewImage, func(width, height int) *ebiten.Image {
g.Unpatch()
defer g.Restore()
printCall(fmt.Sprintf("NewImage(%d,%d)", width, height))
return ebiten.NewImage(width, height)
})
}
{
var g *monkey.PatchGuard
g = monkey.Patch(ebiten.NewImageWithOptions, func(bounds image.Rectangle, options *ebiten.NewImageOptions) *ebiten.Image {
g.Unpatch()
defer g.Restore()
printCall(fmt.Sprintf("NewImageWithOptions(%s,%p)", bounds, options))
return ebiten.NewImageWithOptions(bounds, options)
})
}
}
func Stop() {
monkey.UnpatchAll()
}

17
go.mod Normal file
View file

@ -0,0 +1,17 @@
module code.rocket9labs.com/tslocum/edebug
go 1.23.1
require (
bou.ke/monkey v1.0.2
github.com/hajimehoshi/ebiten/v2 v2.7.10
)
require (
github.com/ebitengine/gomobile v0.0.0-20240518074828-e86332849895 // indirect
github.com/ebitengine/hideconsole v1.0.0 // indirect
github.com/ebitengine/purego v0.7.0 // indirect
github.com/jezek/xgb v1.1.1 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.20.0 // indirect
)

18
go.sum Normal file
View file

@ -0,0 +1,18 @@
bou.ke/monkey v1.0.2 h1:kWcnsrCNUatbxncxR/ThdYqbytgOIArtYWqcQLQzKLI=
bou.ke/monkey v1.0.2/go.mod h1:OqickVX3tNx6t33n1xvtTtu85YN5s6cKwVug+oHMaIA=
github.com/ebitengine/gomobile v0.0.0-20240518074828-e86332849895 h1:48bCqKTuD7Z0UovDfvpCn7wZ0GUZ+yosIteNDthn3FU=
github.com/ebitengine/gomobile v0.0.0-20240518074828-e86332849895/go.mod h1:XZdLv05c5hOZm3fM2NlJ92FyEZjnslcMcNRrhxs8+8M=
github.com/ebitengine/hideconsole v1.0.0 h1:5J4U0kXF+pv/DhiXt5/lTz0eO5ogJ1iXb8Yj1yReDqE=
github.com/ebitengine/hideconsole v1.0.0/go.mod h1:hTTBTvVYWKBuxPr7peweneWdkUwEuHuB3C1R/ielR1A=
github.com/ebitengine/purego v0.7.0 h1:HPZpl61edMGCEW6XK2nsR6+7AnJ3unUxpTZBkkIXnMc=
github.com/ebitengine/purego v0.7.0/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ=
github.com/hajimehoshi/ebiten/v2 v2.7.10 h1:fsVukQdPDUlalSSpFkuszTy0cK2DL0fxFoSnTVdlmAM=
github.com/hajimehoshi/ebiten/v2 v2.7.10/go.mod h1:Ulbq5xDmdx47P24EJ+Mb31Zps7vQq+guieG9mghQUaA=
github.com/jezek/xgb v1.1.1 h1:bE/r8ZZtSv7l9gk6nU0mYx51aXrvnyb44892TwSaqS4=
github.com/jezek/xgb v1.1.1/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFlk=
golang.org/x/image v0.18.0 h1:jGzIakQa/ZXI1I0Fxvaa9W7yP25TqT6cHIHn+6CqvSQ=
golang.org/x/image v0.18.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=