Skip to content
Merged
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
2 changes: 1 addition & 1 deletion reverse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions testdata/script/reverse.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
Loading