Memory mapped coverage (take 2)
Add a build variable, CLANG_COVERAGE_CONTINUOUS_MODE, instead of selecting based on paths. Test: CLANG_COVERAGE_CONTINUOUS_MODE=true m and verify continuous mode works Change-Id: I731172fc1f00e1cabff8efcf8b99f9a48210b446
This commit is contained in:
@@ -1256,6 +1256,10 @@ func (c *deviceConfig) ClangCoverageEnabled() bool {
|
|||||||
return Bool(c.config.productVariables.ClangCoverage)
|
return Bool(c.config.productVariables.ClangCoverage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *deviceConfig) ClangCoverageContinuousMode() bool {
|
||||||
|
return Bool(c.config.productVariables.ClangCoverageContinuousMode)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *deviceConfig) GcovCoverageEnabled() bool {
|
func (c *deviceConfig) GcovCoverageEnabled() bool {
|
||||||
return Bool(c.config.productVariables.GcovCoverage)
|
return Bool(c.config.productVariables.GcovCoverage)
|
||||||
}
|
}
|
||||||
|
@@ -306,10 +306,11 @@ type productVariables struct {
|
|||||||
JavaCoveragePaths []string `json:",omitempty"`
|
JavaCoveragePaths []string `json:",omitempty"`
|
||||||
JavaCoverageExcludePaths []string `json:",omitempty"`
|
JavaCoverageExcludePaths []string `json:",omitempty"`
|
||||||
|
|
||||||
GcovCoverage *bool `json:",omitempty"`
|
GcovCoverage *bool `json:",omitempty"`
|
||||||
ClangCoverage *bool `json:",omitempty"`
|
ClangCoverage *bool `json:",omitempty"`
|
||||||
NativeCoveragePaths []string `json:",omitempty"`
|
NativeCoveragePaths []string `json:",omitempty"`
|
||||||
NativeCoverageExcludePaths []string `json:",omitempty"`
|
NativeCoverageExcludePaths []string `json:",omitempty"`
|
||||||
|
ClangCoverageContinuousMode *bool `json:",omitempty"`
|
||||||
|
|
||||||
// Set by NewConfig
|
// Set by NewConfig
|
||||||
Native_coverage *bool `json:",omitempty"`
|
Native_coverage *bool `json:",omitempty"`
|
||||||
|
@@ -77,6 +77,10 @@ func (cov *coverage) deps(ctx DepsContext, deps Deps) Deps {
|
|||||||
return deps
|
return deps
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func EnableContinuousCoverage(ctx android.BaseModuleContext) bool {
|
||||||
|
return ctx.DeviceConfig().ClangCoverageContinuousMode()
|
||||||
|
}
|
||||||
|
|
||||||
func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags, PathDeps) {
|
func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags, PathDeps) {
|
||||||
clangCoverage := ctx.DeviceConfig().ClangCoverageEnabled()
|
clangCoverage := ctx.DeviceConfig().ClangCoverageEnabled()
|
||||||
gcovCoverage := ctx.DeviceConfig().GcovCoverageEnabled()
|
gcovCoverage := ctx.DeviceConfig().GcovCoverageEnabled()
|
||||||
@@ -101,6 +105,9 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags
|
|||||||
// Override -Wframe-larger-than. We can expect frame size increase after
|
// Override -Wframe-larger-than. We can expect frame size increase after
|
||||||
// coverage instrumentation.
|
// coverage instrumentation.
|
||||||
flags.Local.CFlags = append(flags.Local.CFlags, "-Wno-frame-larger-than=")
|
flags.Local.CFlags = append(flags.Local.CFlags, "-Wno-frame-larger-than=")
|
||||||
|
if EnableContinuousCoverage(ctx) {
|
||||||
|
flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-mllvm", "-runtime-counter-relocation")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,6 +159,9 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags
|
|||||||
flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--wrap,getenv")
|
flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--wrap,getenv")
|
||||||
} else if clangCoverage {
|
} else if clangCoverage {
|
||||||
flags.Local.LdFlags = append(flags.Local.LdFlags, profileInstrFlag)
|
flags.Local.LdFlags = append(flags.Local.LdFlags, profileInstrFlag)
|
||||||
|
if EnableContinuousCoverage(ctx) {
|
||||||
|
flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,-mllvm=-runtime-counter-relocation")
|
||||||
|
}
|
||||||
|
|
||||||
coverage := ctx.GetDirectDepWithTag(getClangProfileLibraryName(ctx), CoverageDepTag).(*Module)
|
coverage := ctx.GetDirectDepWithTag(getClangProfileLibraryName(ctx), CoverageDepTag).(*Module)
|
||||||
deps.WholeStaticLibs = append(deps.WholeStaticLibs, coverage.OutputFile().Path())
|
deps.WholeStaticLibs = append(deps.WholeStaticLibs, coverage.OutputFile().Path())
|
||||||
|
@@ -22,6 +22,7 @@ import (
|
|||||||
|
|
||||||
var CovLibraryName = "libprofile-clang-extras"
|
var CovLibraryName = "libprofile-clang-extras"
|
||||||
|
|
||||||
|
// Add '%c' to default specifier after we resolve http://b/210012154
|
||||||
const profileInstrFlag = "-fprofile-instr-generate=/data/misc/trace/clang-%p-%m.profraw"
|
const profileInstrFlag = "-fprofile-instr-generate=/data/misc/trace/clang-%p-%m.profraw"
|
||||||
|
|
||||||
type coverage struct {
|
type coverage struct {
|
||||||
@@ -59,6 +60,10 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags
|
|||||||
flags.LinkFlags = append(flags.LinkFlags,
|
flags.LinkFlags = append(flags.LinkFlags,
|
||||||
profileInstrFlag, "-g", coverage.OutputFile().Path().String(), "-Wl,--wrap,open")
|
profileInstrFlag, "-g", coverage.OutputFile().Path().String(), "-Wl,--wrap,open")
|
||||||
deps.StaticLibs = append(deps.StaticLibs, coverage.OutputFile().Path())
|
deps.StaticLibs = append(deps.StaticLibs, coverage.OutputFile().Path())
|
||||||
|
if cc.EnableContinuousCoverage(ctx) {
|
||||||
|
flags.RustFlags = append(flags.RustFlags, "-C llvm-args=--runtime-counter-relocation")
|
||||||
|
flags.LinkFlags = append(flags.LinkFlags, "-Wl,-mllvm,-runtime-counter-relocation")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return flags, deps
|
return flags, deps
|
||||||
|
Reference in New Issue
Block a user