Implementing Code Coverage with -toolexec
summary
Explains how Go’s coverage works by recreating it with -toolexec, showing the actual instrumentation format (legacy text), the runtime limitation that forces a deferred dump in main instead of the internal coverage hook, and how the build graph and linker importcfg (about 47 packages in the example) drive ordering. Implements per-compile instrumentation, a cache keyed from object IDs, generates a helper package and rebuilds main with export and patched importcfg; admits the result is kludgy and “mostly works.”
AI-written summary · about
chapters (4)
- 0:00Understanding code coverage
- 2:03Analyzing the action graph
- 3:57Implementing custom coverage
- 5:59Challenges and solutions
related talks
59mUnleashing the Go Toolchain
01h 00mHow to write a programming language and shell in Go with 92% test coverage and instant CI/CD
44mJava Code Coverage Mechanics
43mDebugging Code Generation in Go
24mFunction Inlining
06mProfile-Guided Optimization in the Go Compiler
46mKotlin, Java 4..18, Code Coverage and their best friend — bytecode: ...
56mJava 4..21, Kotlin, Code Coverage, bytecode: scandals, intrigues, investigations
