mirror of
https://github.com/burrowers/garble.git
synced 2025-12-24 12:58:05 +08:00
obey build flags in garble reverse
Fixes an unintentional regression in 6ac80db02c.
This commit is contained in:
@@ -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
|
||||
|
||||
28
testdata/script/reverse.txtar
vendored
28
testdata/script/reverse.txtar
vendored
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user