aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/debug/mod.go
AgeCommit message (Collapse)Author
2022-12-02runtime/debug: add missing periodRuss Cox
Pointed out in review of CL 453602, but it looks like I forgot to re-upload before submitting. Change-Id: I8f4fac52ea0f904f6f9b06e13fc8ed2e778f2360 Reviewed-on: https://go-review.googlesource.com/c/go/+/454835 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Julie Qiu <julieqiu@google.com>
2022-12-02runtime/debug: more complete BuildInfo documentationRuss Cox
A potential user did not realize Deps included all transitive dependencies, not just direct dependencies of the main module. Clarify that and add various other useful information. Change-Id: I5b8e1314bb26092edbcc090ba8eb9859f0a70662 Reviewed-on: https://go-review.googlesource.com/c/go/+/453602 Run-TryBot: Russ Cox <rsc@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Julie Qiu <julieqiu@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
2022-11-18all: add missing periods in commentscui fliter
Change-Id: I69065f8adf101fdb28682c55997f503013a50e29 Reviewed-on: https://go-review.googlesource.com/c/go/+/449757 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Joedian Reid <joedian@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Joedian Reid <joedian@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-02-09runtime/debug: replace (*BuildInfo).Marshal methods with Parse and StringBryan C. Mills
Since a String method cannot return an error, escape fields that may contain unsanitized values, and unescape them during parsing. Add a fuzz test to verify that calling the String method on any BuildInfo returned by Parse produces a string that parses to the same BuildInfo. (Note that this doesn't ensure that String always produces a parseable input: we assume that a user constructing a BuildInfo provides valid paths and versions, so we don't bother to escape those. It also doesn't ensure that ParseBuildInfo accepts all inputs that ought to be valid.) Fixes #51026 Change-Id: Ida18010ce47622cfedb1494060f32bd7705df014 Reviewed-on: https://go-review.googlesource.com/c/go/+/384154 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org>
2021-11-30cmd/go: adjust BuildInfo.SettingsRuss Cox
Make Settings more closely align with command-line flags and environment variables. - Change command-line flags to begin with - - Change syntax of build lines to use Key=Value instead of Key<tab>Value. - Change CGO_ENABLED to 0/1, matching environment variable, instead of false/true. - Add GOOS and GOARCH. These are technically redundant, in that they can be extracted from the binary in other ways most of the time, but not always: GOOS=ios and GOOS=darwin may produce binaries that are difficult to tell apart. In any case, it's a lot easier to have them directly in the settings list than derive them from other parts of the binary. - Add GOEXPERIMENT. These could be inferred from the tags list, but the experiments are being removed from the tags list. - Change the tags list to match the -tags command-line argument. - Add msan and race, echoing the -msan and -race arguments (always 'true' when present, omitted when false). - Add GO$GOARCH when set. Change-Id: Icb59ef4faa5c22407eadd94147b7e53cf4344ce6 Reviewed-on: https://go-review.googlesource.com/c/go/+/358539 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-10-14cmd/go: stamp VCS revision and uncommitted status into binariesJay Conrod
When the go command builds a binary, it will now stamp the current revision from the local Git or Mercurial repository, and it will also stamp whether there are uncommitted edited or untracked files. Only Git and Mercurial are supported for now. If no repository is found containing the current working directory (where the go command was started), or if either the main package directory or the containing module's root directory is outside the repository, no VCS information will be stamped. If the VCS tool is missing or returns an error, that error is reported on the main package (hinting that -buildvcs may be disabled). This change introduces the -buildvcs flag, which is enabled by default. When disabled, VCS information won't be stamped when it would be otherwise. Stamped information may be read using 'go version -m file' or debug.ReadBuildInfo. For #37475 Change-Id: I4e7d3159e1c270d85869ad99f10502e546e7582d Reviewed-on: https://go-review.googlesource.com/c/go/+/353930 Trust: Jay Conrod <jayconrod@google.com> Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-10-14runtime/debug: add GoVersion to BuildInfoJay Conrod
BuildInfo now includes the version of Go used to build a binary, as reported by runtime.Version() or 'go version'. For #37475 Change-Id: Id07dda357dc70599d64a9202dab894c7288de1de Reviewed-on: https://go-review.googlesource.com/c/go/+/353888 Trust: Jay Conrod <jayconrod@google.com> Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-10-14debug/buildinfo: new package with Read and ReadFileJay Conrod
These functions provide access to module information stamped into Go binaries. In the future, they'll provide access to other information (like VCS info). These functions are added in a new package instead of runtime/debug since they use binary parsing packages like debug/elf, which would make runtime/debug an unacceptably heavy dependency. The types in runtime/debug are still used; debug/buildinfo uses them via type aliases. This information is already available for the running binary through debug.ReadBuildInfo and for other binaries with 'go version -m', but until now, there hasn't been a way to get it for other binaries without installing cmd/go. This change copies most of the code in cmd/go/internal/version. A later CL will migrate 'go version -m' to use this package. For #37475 Fixes #39301 Change-Id: I0fbe0896e04f12ef81c6d79fb61b20daede86159 Reviewed-on: https://go-review.googlesource.com/c/go/+/353887 Trust: Jay Conrod <jayconrod@google.com> Run-TryBot: Jay Conrod <jayconrod@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-10-14cmd/go: move module build info formatting into runtime/debugJay Conrod
Previously, modload.PackageBuildInfo returned a string containing information about modules used to build an executable. This string is embedded in the binary and can be read with debug.ReadBuildInfo or 'go version -m'. With this change, debug.BuildInfo now has a MarshalText method that returns a string in the same format as modload.PackageBuildInfo. Package.load now calls Package.setBuildInfo, which constructs a debug.BuildInfo, formats it with MarshalText, then sets Package.Internal.BuildInfo. This is equivalent to what modload.PackageBuildInfo did. modload.PackageBuildInfo is deleted, since it's no longer used. For #37475 Change-Id: I5875a98cb64737637fec2a450ab2ffa7f1805707 Reviewed-on: https://go-review.googlesource.com/c/go/+/353886 Trust: Jay Conrod <jayconrod@google.com> Run-TryBot: Jay Conrod <jayconrod@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-10-06all: use bytes.Cut, strings.CutRuss Cox
Many uses of Index/IndexByte/IndexRune/Split/SplitN can be written more clearly using the new Cut functions. Do that. Also rewrite to other functions if that's clearer. For #46336. Change-Id: I68d024716ace41a57a8bf74455c62279bde0f448 Reviewed-on: https://go-review.googlesource.com/c/go/+/351711 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-02-25Revert "Revert "cmd/go/internal/modload: record the replacement for the ↵Bryan C. Mills
module containing package main in BuildInfo"" This reverts CL 220722. Reason for revert: rolling forward with fix. Fixes #37392 Change-Id: Iba8b0c645267777fbb7019976292d691a10b906a Reviewed-on: https://go-review.googlesource.com/c/go/+/220898 Run-TryBot: Bryan C. Mills <bcmills@google.com> Reviewed-by: Jay Conrod <jayconrod@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-02-24Revert "cmd/go/internal/modload: record the replacement for the module ↵Andrew Bonventre
containing package main in BuildInfo" This reverts CL 220645 (commit e092fc352ad393a4d2f1f7fa641df2d23572ccff). Reason for revert: Seems to have broken windows/amd64 longtest Change-Id: Iffa8c882524250e5845514bc827fcd8927645a44 Reviewed-on: https://go-review.googlesource.com/c/go/+/220722 Run-TryBot: Andrew Bonventre <andybons@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-02-24cmd/go/internal/modload: record the replacement for the module containing ↵Bryan C. Mills
package main in BuildInfo Fixes #37392 Change-Id: I2cb051e6f556b0af95e059611dda3f62e7c1f21a Reviewed-on: https://go-review.googlesource.com/c/go/+/220645 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-09-20runtime/debug: correct BuildInfo.Main documentationHana Kim
The term "main module" has a special meaning [1] and is not what we intended to refer to with BuildInfo.Main. [1] https://golang.org/cmd/go/#hdr-The_main_module_and_the_build_list Updates #33975 Change-Id: Ieaba5fcacee2e87c5c15fa7425527bbd64ada5d5 Reviewed-on: https://go-review.googlesource.com/c/go/+/196522 Reviewed-by: Bryan C. Mills <bcmills@google.com> Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-23cmd/go: move runtime/debug.modinfo to runtime.modinfoRuss Cox
It is easier to ensure that the symbol is always present if we move it to package runtime. Avoids init-time work. Also moves it next to buildVersion, the other similar symbol. Setting up for "go version <binary>". For #31624. Change-Id: I943724469ce6992153e701257eb6f12da88c8e4e Reviewed-on: https://go-review.googlesource.com/c/go/+/173341 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-11-13runtime/debug: add API to read module info in binaryHana Kim
When module is enabled, the go tool embeds build information related to the module in the binary including the dependencies and the replace information (See src/cmd/go/internal/modload.PackageBuildInfo). The newly introduced ReadBuildInfo reads the information and makes it accessible programmatically. Update #26404 Change-Id: Ide37022d609b4a8fb6b5ce02afabb73f04fbb532 Reviewed-on: https://go-review.googlesource.com/c/144220 Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>