summaryrefslogtreecommitdiff
path: root/src/runtime/coverage/apis.go
Commit message (Collapse)AuthorAgeFilesLines
* all: remove repeated definite articlescui fliter2023-04-271-1/+1
| | | | | | | | | | | Change-Id: Idea3e6ca6e62bd5a5ff6e6d5c3f39efb7628f0ec Reviewed-on: https://go-review.googlesource.com/c/go/+/489635 Run-TryBot: Michael Pratt <mpratt@google.com> Run-TryBot: shuang cui <imcusg@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Michael Pratt <mpratt@google.com>
* runtime/coverage: restrict use of all counter-related APIs to atomic modeThan McIntosh2023-03-011-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The existing runtime/coverage API set includes a "ClearCounters()" function that zeros out the counter values in a running process so as enable capturing of a coverage profile from a specific execution time segment. Calling this function is only permitted if the program is built with "-covermode=atomic", due (in part) to concerns about processors with relaxed memory models in which normal stores can be reordered. In the bug in question, a test that stresses a different set of counter-related APIs was hitting an invalid counter segment when running on a machine (ppc64) which does indeed have a relaxed memory consistency model. From a post-mortem examination of the counter array for the harness from the ppc64 test run, it was clear that the thread reading values from the counter array was seeing the sort of inconsistency that could result from stores being reordered (specifically the prolog "packageID" and "number-of-counters" stores). To preclude the possibility of future similar problems, this patch extends the "atomic mode only" restriction from ClearCounters to the other APIs that deal with counters (WriteCounters, WriteCountersDir). Fixes #56197. Change-Id: Idb85d67a84d69ead508e0902ab46ab4dc82af466 Reviewed-on: https://go-review.googlesource.com/c/go/+/463695 Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* runtime/coverage: revise/shorten function namesThan McIntosh2022-10-051-37/+37
| | | | | | | | | | | | | | Use shorter more Go-like names for the new APIs being added in the runtime/coverage package for writing coverage data under user control from server programs. Old names were a bit too clunky/verbose. Updates #51430. Change-Id: Ifdd5b882a88613c7c4342b40ed93b58547483c77 Reviewed-on: https://go-review.googlesource.com/c/go/+/438503 Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* runtime/coverage: use atomic access for counter readsThan McIntosh2022-10-041-4/+6
| | | | | | | | | | | | | | | | | Read counters using atomic ops so as to avoid problems with the race detector if a goroutine happens to still be executing at the end of a test run when we're writing out counter data. In theory we could guard the atomic use on the counter mode, but it's better just to do it in all cases, leaves us with a simpler implementation. Fixes #56006. Change-Id: I81c2234b5a1c3b00cff6c77daf2c2315451b7f6c Reviewed-on: https://go-review.googlesource.com/c/go/+/438256 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Than McIntosh <thanm@google.com>
* runtime/coverage: apis to emit counter data under user controlThan McIntosh2022-09-291-0/+176
Add hooks/apis to support writing of coverage counter data and meta-data under user control (from within an executing "-cover" binary), so as to provide a way to obtain coverage data from programs that do not terminate. This patch also adds a hook for clearing the coverage counter data for a running program, something that can be helpful when the intent is to capture coverage info from a specific window of program execution. Updates #51430. Change-Id: I34ee6cee52e5597fa3698b8b04f1b34a2a2a418f Reviewed-on: https://go-review.googlesource.com/c/go/+/401236 Reviewed-by: David Chase <drchase@google.com>