aboutsummaryrefslogtreecommitdiff
path: root/src/internal/coverage
AgeCommit message (Collapse)Author
2022-12-01internal/coverage: use io.Seek* constantsTobias Klauser
Use the io.Seek* constants instead of their deprecated os.SEEK_* counterparts. Change-Id: Ie899f9cf286de7304a394d9a2a091a55937542ad Reviewed-on: https://go-review.googlesource.com/c/go/+/453576 Reviewed-by: Than McIntosh <thanm@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Than McIntosh <thanm@google.com>
2022-11-08internal/coverage/slicereader: use unsafe.StringTobias Klauser
Change-Id: Ifd88315626e0ce5b9b8d3c66aa9dd9806f8407dd Reviewed-on: https://go-review.googlesource.com/c/go/+/448555 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Than McIntosh <thanm@google.com> Auto-Submit: Than McIntosh <thanm@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2022-11-05all: fix comment typosDan Kortschak
Change-Id: Ic16824482142d4de4d0b949459e36505ee944ff7 Reviewed-on: https://go-review.googlesource.com/c/go/+/448175 Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Dan Kortschak <dan@kortschak.io> Auto-Submit: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Dan Kortschak <dan@kortschak.io> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-11-01cmd/{go,cover}: fix for -coverprofile path capture with local pkgThan McIntosh
When coverage testing a local package (defined by a relative import path such as "./foo/bar") the convention when "-coverprofile" is used has been to capture source files by full pathname, as opposed to recording the full import path or the invented import path ("command-line-arguments/") created by the go command in the case of building named Go files. Doing this makes it much easier to use collected profiles with "go tool -cover -html=<profile>". The support for this feature/convention wound up being inadvertantly dropped during the GOEXPERIMENT=coverageredesign implementation; this patch restores it. Fixes #56433. Change-Id: Ib9556fdc86011b00c155caa614ab23e5148f3eb4 Reviewed-on: https://go-review.googlesource.com/c/go/+/445917 Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-10-11internal/coverage: minor code cleanupsThan McIntosh
Delete some unused code, various cleanups to fix staticcheck warnings. Change-Id: Ie475d57735a83351a4977f0dd4bc1387ce06a20e Reviewed-on: https://go-review.googlesource.com/c/go/+/441935 Reviewed-by: David Chase <drchase@google.com>
2022-09-30internal: fix a few function names on commentscui fliter
Change-Id: I53169e386b8c789b092de348fa891fe50e11c2ef GitHub-Last-Rev: 75232393b4ba415bddc731f15550d7094ccfd953 GitHub-Pull-Request: golang/go#55965 Reviewed-on: https://go-review.googlesource.com/c/go/+/436883 Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-09-29internal: use io.SeekStart, io.SeekCurrent, and io.SeekEndcuiweixie
Change-Id: I23ab738b73bc33d3b0b10013c3fadd95b5b24681 Reviewed-on: https://go-review.googlesource.com/c/go/+/436719 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-09-28all: fix some typoscui fliter
Change-Id: I8b28aebbb9494b2c877139a4584a5a42253e3bea GitHub-Last-Rev: e3703fd3a50b811785df75751472aa3ab098b3d1 GitHub-Pull-Request: golang/go#55902 Reviewed-on: https://go-review.googlesource.com/c/go/+/435617 Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-09-28runtime/coverage: runtime routines to emit coverage dataThan McIntosh
This patch fleshes out the runtime support for emitting coverage data at the end of a run of an instrumented binary. Data is emitted in the form of a pair of files, a meta-out-file and counter-data-outfile, each written to the dir GOCOVERDIR. The meta-out-file is emitted only if required; no need to emit again if an existing meta-data file with the same hash and length is present. Updates #51430. Change-Id: I59d20a4b8c05910c933ee29527972f8e401b1685 Reviewed-on: https://go-review.googlesource.com/c/go/+/355451 Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Than McIntosh <thanm@google.com>
2022-09-28cmd/covdata: add tools to read/manipulate coverage data filesThan McIntosh
Add a set of helper packages for reading collections of related meta-data and counter-data files ("pods") produced by runs of coverage-instrumented binaries, and a new tool program (cmd/covdata) for dumping and/or manipulating coverage data files. Currently "go tool covdata" subcommands include 'merge', 'intersect', 'percent', 'pkglist', 'subtract', 'debugdump', and 'textfmt' (conversion to the legacy "go tool cover" format). Updates #51430. Change-Id: I44167c578f574b4636ab8726e726388531fd3258 Reviewed-on: https://go-review.googlesource.com/c/go/+/357609 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
2022-09-28internal: use bytes.Clonecuiweixie
Change-Id: Ia96ddd520a7bd2fd53bff55315c6fac04ae96a2f Reviewed-on: https://go-review.googlesource.com/c/go/+/435282 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
2022-09-27cmd/compile: add coverage fixup modeThan McIntosh
Adds a -coveragecfg=<configfile> command line option to the compiler to help support a cooperative "tool and compiler" mode for coverage instrumentation. In this mode the cmd/cover tool generates most of the counter instrumentation via source-to-source rewriting, but the compiler fixes up the result if passed the "-coveragecfg" option. The fixups include: - reclassifying counter variables (special storage class) - marking meta-data variables are read-only - adding in an init call to do registation Updates #51430. Change-Id: Iead72b85209725ee044542374465f118a3ee72e0 Reviewed-on: https://go-review.googlesource.com/c/go/+/395895 Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-26runtime: add hook to register coverage-instrumented packagesThan McIntosh
Add support to the runtime for registering coverage-instrumented packages, using a new hook that can be called from the init function of an instrumented package. The hook records the meta-data symbol for the package (chaining it onto a list), and returns a package ID to be used to identify functions in the package. This new hook is not yet called; that will be added in a subsequent patch. The list of registered meta-data objects will be used (again in a future patch) as part of coverage data file writing. Special handling is required for packages such as "runtime" or "internal/cpu", where functions in the package execute before the package "init" func runs. For these packages hard-code the package ID, then record the position of the package in the overall list so that we can fix things up later on. Updates #51430. Change-Id: I6ca3ddf535197442a2603c6d7a0a9798b8496f40 Reviewed-on: https://go-review.googlesource.com/c/go/+/401234 Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Than McIntosh <thanm@google.com>
2022-09-26internal/coverage: add apis for reading/writing counter dataThan McIntosh
Add utilities for reading and writing of counter data files as part of the new code coverage implementation. Trivia note: currently the contents of counter data files are emitted in little-endian form, which for the counters is somewhat painful in that we need to visit each counter value and properly encode it. It might be better to instead emit counters in native endianity and then teach the tools to decode properly in the case of an endianity mismatch. Updates #51430. Change-Id: I124fdcb40fc339a48b64b35264bf24c3be50ddd4 Reviewed-on: https://go-review.googlesource.com/c/go/+/359403 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Than McIntosh <thanm@google.com>
2022-09-26internal/coverage: add coverage meta-data decoderThan McIntosh
Add a coverage meta-data decoder, which provides APIs for reading encoded coverage meta-data and expanding it usable form. This package is intended to be used in the coverage tooling that reads data files emitted from coverage runs. Along with the new decoding package is a unit test that runs the encode/decode paths together to check to make sure that "decode(encode(X)) == X". Updates #51430. Change-Id: I81d27d8da0b2fcfa5039114a6e35a4b463d19b3c Reviewed-on: https://go-review.googlesource.com/c/go/+/353454 Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-26internal/coverage: add coverage meta-data encoderThan McIntosh
Add a new package with APIs for encoding coverage meta-data. This provides support for accumulating information about each function during the compilation process, and then encoding and emitting a payload for a coverage meta-data symbol. Not yet connected to the rest of the coverage machinery (that will appear in a later patch). Updates #51430. Change-Id: I61054ce87f205b25fb1bfedaa740fd7425c34de4 Reviewed-on: https://go-review.googlesource.com/c/go/+/353453 Run-TryBot: Than McIntosh <thanm@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>