obey build flags in `garble reverse`

Fixes an unintentional regression in 6ac80db02c.
pull/970/head
bobo liu 2 months ago committed by GitHub
parent 59eee83beb
commit 1b9c305df2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -35,7 +35,7 @@ One can reverse a captured panic stack trace as follows:
pkg, args := args[0], args[1:]
// We don't actually run `go list -toolexec=garble`; we only use toolexecCmd
// to ensure that sharedCache.ListedPackages is filled.
_, err := toolexecCmd("list", []string{pkg})
_, err := toolexecCmd("list", append(flags, pkg))
defer os.RemoveAll(os.Getenv("GARBLE_SHARED"))
if err != nil {
return err

@ -43,6 +43,17 @@ cmp stdout reverse.stdout
stdin main-literals.stderr
! exec garble reverse .
cmp stdout main-literals.stderr
# https://github.com/burrowers/garble/pull/967
# Ensure that we can reverse a package with build tag required.
exec garble build -o tag.bin -tags sometag ./case/tag
exec ./tag.bin
cp stderr tag.stderr
! grep "main.CallerFuncName" tag.stderr
stdin tag.stderr
exec garble reverse -tags sometag ./case/tag
stdout main\.CallerFuncName
-- go.mod --
module test/main
@ -120,6 +131,23 @@ func printStackTrace(w io.Writer) error {
return err
}
-- case/tag/main.go --
//go:build sometag
package main
import "runtime"
func main() {
println(CallerFuncName())
}
func CallerFuncName() string {
pc, _, _, _ := runtime.Caller(0)
fn := runtime.FuncForPC(pc)
return fn.Name()
}
-- reverse.stdout --
lib filename: test/main/lib/long_lib.go

Loading…
Cancel
Save