[telemetry] cmd/stacks: show build info tuple using go command syntax

4 views
Skip to first unread message

Alan Donovan (Gerrit)

unread,
Sep 30, 2025, 4:22:20 PM (yesterday) Sep 30
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Alan Donovan has uploaded the change for review

Commit message

cmd/stacks: show build info tuple using go command syntax

Also provide a hint to help reproduce and disassemble the
executable.
Change-Id: I4afd6368181aeb41a4a08526bb1d8bb1fe69e7c7

Change diff

diff --git a/cmd/stacks/stacks.go b/cmd/stacks/stacks.go
index b2f261c..4567e15 100644
--- a/cmd/stacks/stacks.go
+++ b/cmd/stacks/stacks.go
@@ -316,11 +316,15 @@
}

func (info Info) String() string {
- s := fmt.Sprintf("%s@%s %s %s/%s",
- info.Program, info.ProgramVersion,
- info.GoVersion, info.GOOS, info.GOARCH)
+ // Emit the info tuple in a convenient form for reproducing the build.
+ s := fmt.Sprintf(
+ "GOOS=%s GOARCH=%s GOTOOLCHAIN=%s go install %s@%s",
+ info.GOOS,
+ info.GOARCH,
+ info.GoVersion,
+ info.Program, info.ProgramVersion)
if info.GoplsClient != "" {
- s += " " + info.GoplsClient
+ s += " gopls.client=" + info.GoplsClient
}
return s
}
@@ -830,7 +834,7 @@
}

// Parse the stack and get the symbol names out.
- for _, frame := range strings.Split(stack, "\n") {
+ for frame := range strings.SplitSeq(stack, "\n") {
if url := frameURL(pclntab, info, frame); url != "" {
fmt.Fprintf(body, "- [`%s`](%s)\n", frame, url)
} else {
@@ -845,6 +849,12 @@
fmt.Fprintf(body, "%s (%d)\n", info, count)
}
fmt.Fprintf(body, "```\n\n")
+
+ // Give hints for disassembling the right executable.
+ // Beware that go install behaves differently for cross-compiles;
+ // the command below was chosen to work for simple and cross builds.
+ fmt.Fprintf(body, "To reproducibly build: `(HOME=$(mktemp -d); GOOS=...etc... go install module@version && find $HOME/go/bin -type f)`\n")
+ fmt.Fprintf(body, "To disassemble: `go tool objdump exe | less`\n\n")
}

// frameURL returns the CodeSearch URL for the stack frame, if known.

Change information

Files:
  • M cmd/stacks/stacks.go
Change size: S
Delta: 1 file changed, 15 insertions(+), 5 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: telemetry
Gerrit-Branch: master
Gerrit-Change-Id: I4afd6368181aeb41a4a08526bb1d8bb1fe69e7c7
Gerrit-Change-Number: 708115
Gerrit-PatchSet: 1
Gerrit-Owner: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Alan Donovan (Gerrit)

unread,
Sep 30, 2025, 4:22:31 PM (yesterday) Sep 30
to goph...@pubsubhelper.golang.org, Michael Pratt, Go LUCI, golang-co...@googlegroups.com
Attention needed from Michael Pratt

Alan Donovan voted Auto-Submit+1

Auto-Submit+1
Open in Gerrit

Related details

Attention is currently required from:
  • Michael Pratt
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: telemetry
Gerrit-Branch: master
Gerrit-Change-Id: I4afd6368181aeb41a4a08526bb1d8bb1fe69e7c7
Gerrit-Change-Number: 708115
Gerrit-PatchSet: 1
Gerrit-Owner: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
Gerrit-Attention: Michael Pratt <mpr...@google.com>
Gerrit-Comment-Date: Tue, 30 Sep 2025 20:22:28 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Michael Pratt (Gerrit)

unread,
10:48 AM (12 hours ago) 10:48 AM
to Alan Donovan, goph...@pubsubhelper.golang.org, Go LUCI, Michael Pratt, golang-co...@googlegroups.com
Attention needed from Alan Donovan

Michael Pratt added 1 comment

File cmd/stacks/stacks.go
Line 856, Patchset 1 (Latest): fmt.Fprintf(body, "To reproducibly build: `(HOME=$(mktemp -d); GOOS=...etc... go install module@version && find $HOME/go/bin -type f)`\n")
Michael Pratt . unresolved
```suggestion
fmt.Fprintf(body, "To reproducibly build: `(GOPATH=$(mktemp -d); GOOS=...etc... go install module@version && find $GOPATH/bin -type f)`\n")
```

Using GOPATH is slightly more clear, IMO, but this is still really ugly. There's got to be a better way...

Open in Gerrit

Related details

Attention is currently required from:
  • Alan Donovan
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: telemetry
    Gerrit-Branch: master
    Gerrit-Change-Id: I4afd6368181aeb41a4a08526bb1d8bb1fe69e7c7
    Gerrit-Change-Number: 708115
    Gerrit-PatchSet: 1
    Gerrit-Owner: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
    Gerrit-Attention: Alan Donovan <adon...@google.com>
    Gerrit-Comment-Date: Wed, 01 Oct 2025 14:48:07 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Michael Pratt (Gerrit)

    unread,
    10:58 AM (12 hours ago) 10:58 AM
    to Alan Donovan, goph...@pubsubhelper.golang.org, Go LUCI, Michael Pratt, golang-co...@googlegroups.com
    Attention needed from Alan Donovan

    Michael Pratt added 1 comment

    File cmd/stacks/stacks.go
    Line 856, Patchset 1 (Latest): fmt.Fprintf(body, "To reproducibly build: `(HOME=$(mktemp -d); GOOS=...etc... go install module@version && find $HOME/go/bin -type f)`\n")
    Michael Pratt . unresolved
    ```suggestion
    fmt.Fprintf(body, "To reproducibly build: `(GOPATH=$(mktemp -d); GOOS=...etc... go install module@version && find $GOPATH/bin -type f)`\n")
    ```

    Using GOPATH is slightly more clear, IMO, but this is still really ugly. There's got to be a better way...

    Michael Pratt

    My alternative proposal:

    ```
    WORK=$(mktemp -d); go -C ${WORK?} mod init build && go -C ${WORK?} get golang.org/x/tools/go...@v0.20.0 && go -C ${WORK?} build -o ${PWD?}/exe golang.org/x/tools/gopls && rm -r ${WORK?}
    ```

    This has the advantage of putting the binary in the current directory instead of just printing the path.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Alan Donovan
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: telemetry
    Gerrit-Branch: master
    Gerrit-Change-Id: I4afd6368181aeb41a4a08526bb1d8bb1fe69e7c7
    Gerrit-Change-Number: 708115
    Gerrit-PatchSet: 1
    Gerrit-Owner: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
    Gerrit-Attention: Alan Donovan <adon...@google.com>
    Gerrit-Comment-Date: Wed, 01 Oct 2025 14:58:34 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Michael Pratt <mpr...@google.com>
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Alan Donovan (Gerrit)

    unread,
    11:12 AM (11 hours ago) 11:12 AM
    to goph...@pubsubhelper.golang.org, Go LUCI, Michael Pratt, golang-co...@googlegroups.com
    Attention needed from Michael Pratt

    Alan Donovan added 2 comments

    File cmd/stacks/stacks.go
    Line 856, Patchset 1 (Latest): fmt.Fprintf(body, "To reproducibly build: `(HOME=$(mktemp -d); GOOS=...etc... go install module@version && find $HOME/go/bin -type f)`\n")
    Alan Donovan . unresolved

    program

    Line 856, Patchset 1 (Latest): fmt.Fprintf(body, "To reproducibly build: `(HOME=$(mktemp -d); GOOS=...etc... go install module@version && find $HOME/go/bin -type f)`\n")
    Michael Pratt . unresolved
    ```suggestion
    fmt.Fprintf(body, "To reproducibly build: `(GOPATH=$(mktemp -d); GOOS=...etc... go install module@version && find $GOPATH/bin -type f)`\n")
    ```

    Using GOPATH is slightly more clear, IMO, but this is still really ugly. There's got to be a better way...

    Michael Pratt

    My alternative proposal:

    ```
    WORK=$(mktemp -d); go -C ${WORK?} mod init build && go -C ${WORK?} get golang.org/x/tools/go...@v0.20.0 && go -C ${WORK?} build -o ${PWD?}/exe golang.org/x/tools/gopls && rm -r ${WORK?}
    ```

    This has the advantage of putting the binary in the current directory instead of just printing the path.

    Alan Donovan

    How about `find $HOME/go/bin -type f -exec cp -f {} exe \;`? ;-)

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Michael Pratt
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: telemetry
    Gerrit-Branch: master
    Gerrit-Change-Id: I4afd6368181aeb41a4a08526bb1d8bb1fe69e7c7
    Gerrit-Change-Number: 708115
    Gerrit-PatchSet: 1
    Gerrit-Owner: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
    Gerrit-Attention: Michael Pratt <mpr...@google.com>
    Gerrit-Comment-Date: Wed, 01 Oct 2025 15:12:45 +0000
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Michael Pratt (Gerrit)

    unread,
    2:09 PM (8 hours ago) 2:09 PM
    to Alan Donovan, goph...@pubsubhelper.golang.org, Michael Pratt, Go LUCI, golang-co...@googlegroups.com
    Attention needed from Alan Donovan

    Michael Pratt voted and added 1 comment

    Votes added by Michael Pratt

    Code-Review+2

    1 comment

    File cmd/stacks/stacks.go
    Line 856, Patchset 1 (Latest): fmt.Fprintf(body, "To reproducibly build: `(HOME=$(mktemp -d); GOOS=...etc... go install module@version && find $HOME/go/bin -type f)`\n")
    Michael Pratt . unresolved
    ```suggestion
    fmt.Fprintf(body, "To reproducibly build: `(GOPATH=$(mktemp -d); GOOS=...etc... go install module@version && find $GOPATH/bin -type f)`\n")
    ```

    Using GOPATH is slightly more clear, IMO, but this is still really ugly. There's got to be a better way...

    Michael Pratt

    My alternative proposal:

    ```
    WORK=$(mktemp -d); go -C ${WORK?} mod init build && go -C ${WORK?} get golang.org/x/tools/go...@v0.20.0 && go -C ${WORK?} build -o ${PWD?}/exe golang.org/x/tools/gopls && rm -r ${WORK?}
    ```

    This has the advantage of putting the binary in the current directory instead of just printing the path.

    Alan Donovan

    How about `find $HOME/go/bin -type f -exec cp -f {} exe \;`? ;-)

    Michael Pratt

    They all make me sad (including my suggestion), so you may pick whichever you like. 😊

    I do think it would be nice to fill in GOOS, GOARCH, etc in this hint, as we do in info.String, so it is copyable.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Alan Donovan
    Submit Requirements:
    • requirement satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: telemetry
    Gerrit-Branch: master
    Gerrit-Change-Id: I4afd6368181aeb41a4a08526bb1d8bb1fe69e7c7
    Gerrit-Change-Number: 708115
    Gerrit-PatchSet: 1
    Gerrit-Owner: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
    Gerrit-Attention: Alan Donovan <adon...@google.com>
    Gerrit-Comment-Date: Wed, 01 Oct 2025 18:09:50 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Michael Pratt <mpr...@google.com>
    Comment-In-Reply-To: Alan Donovan <adon...@google.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Alan Donovan (Gerrit)

    unread,
    2:31 PM (8 hours ago) 2:31 PM
    to goph...@pubsubhelper.golang.org, Michael Pratt, Go LUCI, golang-co...@googlegroups.com
    Attention needed from Michael Pratt

    Alan Donovan voted and added 1 comment

    Votes added by Alan Donovan

    Auto-Submit+0

    1 comment

    File cmd/stacks/stacks.go
    Line 856, Patchset 1 (Latest): fmt.Fprintf(body, "To reproducibly build: `(HOME=$(mktemp -d); GOOS=...etc... go install module@version && find $HOME/go/bin -type f)`\n")
    Michael Pratt . unresolved
    ```suggestion
    fmt.Fprintf(body, "To reproducibly build: `(GOPATH=$(mktemp -d); GOOS=...etc... go install module@version && find $GOPATH/bin -type f)`\n")
    ```

    Using GOPATH is slightly more clear, IMO, but this is still really ugly. There's got to be a better way...

    Michael Pratt

    My alternative proposal:

    ```
    WORK=$(mktemp -d); go -C ${WORK?} mod init build && go -C ${WORK?} get golang.org/x/tools/go...@v0.20.0 && go -C ${WORK?} build -o ${PWD?}/exe golang.org/x/tools/gopls && rm -r ${WORK?}
    ```

    This has the advantage of putting the binary in the current directory instead of just printing the path.

    Alan Donovan

    How about `find $HOME/go/bin -type f -exec cp -f {} exe \;`? ;-)

    Michael Pratt

    They all make me sad (including my suggestion), so you may pick whichever you like. 😊

    I do think it would be nice to fill in GOOS, GOARCH, etc in this hint, as we do in info.String, so it is copyable.

    Alan Donovan

    They all make me sad (including my suggestion), so you may pick whichever you like. 😊

    I agree.

    I do think it would be nice to fill in GOOS, GOARCH, etc in this hint, as we do in info.String, so it is copyable.

    The problem is that the GOOS=... information is actually a table (it's the key in a histogram of counts), and I don't want to print this ugly command for every row of the table. If the command were as simple as `GOOS=... go install pkg@version` then it would be a no-brainer.

    I suppose I could just show a runnable command for the first entry in the table.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Michael Pratt
    Submit Requirements:
    • requirement satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: telemetry
    Gerrit-Branch: master
    Gerrit-Change-Id: I4afd6368181aeb41a4a08526bb1d8bb1fe69e7c7
    Gerrit-Change-Number: 708115
    Gerrit-PatchSet: 1
    Gerrit-Owner: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
    Gerrit-Attention: Michael Pratt <mpr...@google.com>
    Gerrit-Comment-Date: Wed, 01 Oct 2025 18:31:04 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages