Merge "Memory mapped coverage (take 2)" am: c8a6487153
am: 079c381504
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2009378 Change-Id: If280e01532aef4a703d0ffc3038ef4773526f8ef
This commit is contained in:
commit
4a759d5b33
4 changed files with 24 additions and 4 deletions
|
@ -1256,6 +1256,10 @@ func (c *deviceConfig) ClangCoverageEnabled() bool {
|
|||
return Bool(c.config.productVariables.ClangCoverage)
|
||||
}
|
||||
|
||||
func (c *deviceConfig) ClangCoverageContinuousMode() bool {
|
||||
return Bool(c.config.productVariables.ClangCoverageContinuousMode)
|
||||
}
|
||||
|
||||
func (c *deviceConfig) GcovCoverageEnabled() bool {
|
||||
return Bool(c.config.productVariables.GcovCoverage)
|
||||
}
|
||||
|
|
|
@ -306,10 +306,11 @@ type productVariables struct {
|
|||
JavaCoveragePaths []string `json:",omitempty"`
|
||||
JavaCoverageExcludePaths []string `json:",omitempty"`
|
||||
|
||||
GcovCoverage *bool `json:",omitempty"`
|
||||
ClangCoverage *bool `json:",omitempty"`
|
||||
NativeCoveragePaths []string `json:",omitempty"`
|
||||
NativeCoverageExcludePaths []string `json:",omitempty"`
|
||||
GcovCoverage *bool `json:",omitempty"`
|
||||
ClangCoverage *bool `json:",omitempty"`
|
||||
NativeCoveragePaths []string `json:",omitempty"`
|
||||
NativeCoverageExcludePaths []string `json:",omitempty"`
|
||||
ClangCoverageContinuousMode *bool `json:",omitempty"`
|
||||
|
||||
// Set by NewConfig
|
||||
Native_coverage *bool `json:",omitempty"`
|
||||
|
|
|
@ -77,6 +77,10 @@ func (cov *coverage) deps(ctx DepsContext, deps Deps) 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) {
|
||||
clangCoverage := ctx.DeviceConfig().ClangCoverageEnabled()
|
||||
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
|
||||
// coverage instrumentation.
|
||||
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")
|
||||
} else if clangCoverage {
|
||||
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)
|
||||
deps.WholeStaticLibs = append(deps.WholeStaticLibs, coverage.OutputFile().Path())
|
||||
|
|
|
@ -22,6 +22,7 @@ import (
|
|||
|
||||
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"
|
||||
|
||||
type coverage struct {
|
||||
|
@ -59,6 +60,10 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags
|
|||
flags.LinkFlags = append(flags.LinkFlags,
|
||||
profileInstrFlag, "-g", coverage.OutputFile().Path().String(), "-Wl,--wrap,open")
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue