mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
[utils] Generate html reports with the code coverage utility script
Instead of extracting raw coverage mappings into an artifact directory, actually generate useful html reports for a given list of binaries with symbol demangling turned on. No tests, but this is actively being used to drive the (still nascent) coverage bot. llvm-svn: 275927
This commit is contained in:
parent
4df0821f1b
commit
271dba4dc2
@ -4,7 +4,7 @@
|
||||
|
||||
- Collate raw profiles into one indexed profile.
|
||||
- Delete the raw profiles.
|
||||
- Copy the coverage mappings in the binaries directory.
|
||||
- Generate html reports for llvm binaries.
|
||||
'''
|
||||
|
||||
import argparse
|
||||
@ -13,7 +13,7 @@ import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
def merge_raw_profiles(host_llvm_profdata, profile_data_dir):
|
||||
def merge_raw_profiles(host_llvm_profdata, profile_data_dir, preserve_profiles):
|
||||
print ':: Merging raw profiles...',
|
||||
sys.stdout.flush()
|
||||
raw_profiles = glob.glob(os.path.join(profile_data_dir, '*.profraw'))
|
||||
@ -23,33 +23,45 @@ def merge_raw_profiles(host_llvm_profdata, profile_data_dir):
|
||||
manifest.write('\n'.join(raw_profiles))
|
||||
subprocess.check_call([host_llvm_profdata, 'merge', '-sparse', '-f',
|
||||
manifest_path, '-o', profdata_path])
|
||||
for raw_profile in raw_profiles:
|
||||
os.remove(raw_profile)
|
||||
if not preserve_profiles:
|
||||
for raw_profile in raw_profiles:
|
||||
os.remove(raw_profile)
|
||||
os.remove(manifest_path)
|
||||
print 'Done!'
|
||||
|
||||
def extract_covmappings(host_llvm_cov, profile_data_dir, llvm_bin_dir):
|
||||
print ':: Extracting covmappings...',
|
||||
def prepare_html_report(host_llvm_cov, profile_data_dir, report_dir, binary):
|
||||
print ':: Preparing html report for {0}...'.format(binary),
|
||||
sys.stdout.flush()
|
||||
for prog in os.listdir(llvm_bin_dir):
|
||||
if prog == 'llvm-lit':
|
||||
continue
|
||||
covmapping_path = os.path.join(profile_data_dir,
|
||||
os.path.basename(prog) + '.covmapping')
|
||||
subprocess.check_call([host_llvm_cov, 'convert-for-testing',
|
||||
os.path.join(llvm_bin_dir, prog), '-o',
|
||||
covmapping_path])
|
||||
binary_report_dir = os.path.join(report_dir, os.path.basename(binary))
|
||||
profile = os.path.join(profile_data_dir, 'Coverage.profdata')
|
||||
subprocess.check_call([host_llvm_cov, 'show', binary, '-format', 'html',
|
||||
'-instr-profile', profile, '-o', binary_report_dir,
|
||||
'-show-line-counts-or-regions',
|
||||
'-Xdemangler', 'c++filt', '-Xdemangler', '-n'])
|
||||
with open(os.path.join(binary_report_dir, 'summary.txt'), 'wb') as Summary:
|
||||
subprocess.check_call([host_llvm_cov, 'report', binary,
|
||||
'-instr-profile', profile], stdout=Summary)
|
||||
print 'Done!'
|
||||
|
||||
def prepare_html_reports(host_llvm_cov, profile_data_dir, report_dir, binaries):
|
||||
for binary in binaries:
|
||||
prepare_html_report(host_llvm_cov, profile_data_dir, report_dir, binary)
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('host_llvm_profdata', help='Path to llvm-profdata')
|
||||
parser.add_argument('host_llvm_cov', help='Path to llvm-cov')
|
||||
parser.add_argument('profile_data_dir',
|
||||
help='Path to the directory containing the raw profiles')
|
||||
parser.add_argument('llvm_bin_dir',
|
||||
help='Path to the directory containing llvm binaries')
|
||||
parser.add_argument('report_dir',
|
||||
help='Path to the output directory for html reports')
|
||||
parser.add_argument('binaries', metavar='B', type=str, nargs='+',
|
||||
help='Path to an instrumented binary')
|
||||
parser.add_argument('--preserve-profiles',
|
||||
help='Do not delete raw profiles', action='store_true')
|
||||
args = parser.parse_args()
|
||||
|
||||
merge_raw_profiles(args.host_llvm_profdata, args.profile_data_dir)
|
||||
extract_covmappings(args.host_llvm_cov, args.profile_data_dir,
|
||||
args.llvm_bin_dir)
|
||||
merge_raw_profiles(args.host_llvm_profdata, args.profile_data_dir,
|
||||
args.preserve_profiles)
|
||||
prepare_html_reports(args.host_llvm_cov, args.profile_data_dir,
|
||||
args.report_dir, args.binaries)
|
||||
|
Loading…
x
Reference in New Issue
Block a user