mirror of
https://github.com/burrowers/garble.git
synced 2025-12-24 12:58:05 +08:00
stop ignoring GODEBUG when -tiny is used
GODEBUG started being used for configuring the behavior of the Go toolchain and standard library, for the sake of smoother transitions in terms of backwards and forwards compatibility. See: https://go.dev/doc/godebug As such, it is not right to have `garble build -tiny` ignore all GODEBUG settings, because many GODEBUG keys nowadays do not actually involve debugging what a Go binary is doing. Moreover, the mechanism we were using broke with Go 1.25.2, which refactored `func parsedebugvars()` into `func parseRuntimeDebugVars(godebug string)`, so our test started breaking as our runtime patching was broken.
This commit is contained in:
committed by
Paul Scheduikat
parent
37e582d581
commit
65ffaa0efb
@@ -96,8 +96,7 @@ Many symbol names are also omitted from binary sections at link time.
|
||||
All in all, this can make binaries about 15% smaller.
|
||||
|
||||
With this flag, no panics or fatal runtime errors will ever be printed, but they
|
||||
can still be handled internally with `recover` as normal. In addition, the
|
||||
`GODEBUG` environmental variable will be ignored.
|
||||
can still be handled internally with `recover` as normal.
|
||||
|
||||
Note that this flag can make debugging crashes harder, as a panic will simply
|
||||
exit the entire program without printing a stack trace, and source code
|
||||
|
||||
@@ -200,27 +200,7 @@ func stripRuntime(basename string, file *ast.File) {
|
||||
funcDecl.Body.List = nil
|
||||
}
|
||||
case "runtime1.go":
|
||||
usesEnv := func(node ast.Node) bool {
|
||||
for node := range ast.Preorder(node) {
|
||||
ident, ok := node.(*ast.Ident)
|
||||
if ok && ident.Name == "gogetenv" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
filenames:
|
||||
switch funcDecl.Name.Name {
|
||||
case "parsedebugvars":
|
||||
// keep defaults for GODEBUG cgocheck and invalidptr,
|
||||
// remove code that reads GODEBUG via gogetenv
|
||||
for i, stmt := range funcDecl.Body.List {
|
||||
if usesEnv(stmt) {
|
||||
funcDecl.Body.List = funcDecl.Body.List[:i]
|
||||
break filenames
|
||||
}
|
||||
}
|
||||
panic("did not see any gogetenv call in parsedebugvars")
|
||||
case "setTraceback":
|
||||
// tracebacks are completely hidden, no
|
||||
// sense keeping this function
|
||||
|
||||
3
testdata/script/tiny.txtar
vendored
3
testdata/script/tiny.txtar
vendored
@@ -1,15 +1,12 @@
|
||||
# Tiny mode
|
||||
exec garble -tiny build
|
||||
! binsubstr main$exe 'garble_main.go' 'fmt/print.go'
|
||||
env GODEBUG='allocfreetrace=1,gcpacertrace=1,gctrace=1,inittrace=1,scavenge=1,scavtrace=1,scheddetail=1,schedtrace=10'
|
||||
! exec ./main$exe
|
||||
env GODEBUG='' # Ensure further commands don't have weirdness due to GODEBUG.
|
||||
stderr '^\(0x[[:xdigit:]]+,0x[[:xdigit:]]+\)' # interfaces/pointers print correctly
|
||||
# With -tiny, all line numbers are reset to 1.
|
||||
# Unfortunately, line comment directives don't allow erasing line numbers entirely.
|
||||
stderr '^caller: \?\? 1$' # position info is removed
|
||||
stderr '^recovered: ya like jazz?'
|
||||
! stderr '^init runtime' # GODEBUG prints are hidden, like inittrace=1
|
||||
! stderr 'panic: oh noes' # panics are hidden
|
||||
stderr 'funcExported false funcUnexported true'
|
||||
stderr 'funcStructExported false funcStructUnexported true'
|
||||
|
||||
Reference in New Issue
Block a user