Skip to content

Commit

Permalink
Bug 1751707 - Add configuration option to enable source-based coverag…
Browse files Browse the repository at this point in the history
…e sanitizer r=nss-reviewers,mt

Differential Revision: https://phabricator.services.mozilla.com/D135764
  • Loading branch information
iaroslav-gridin committed Dec 12, 2022
1 parent afe8aa1 commit a9e3ae0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ while [ $# -gt 0 ]; do
--pprof) gyp_params+=(-Duse_pprof=1) ;;
--asan) enable_sanitizer asan ;;
--msan) enable_sanitizer msan ;;
--sourcecov) enable_sourcecov ;;
--ubsan) enable_ubsan ;;
--ubsan=?*) enable_ubsan "${1#*=}" ;;
--fuzz) fuzz=1 ;;
Expand Down
7 changes: 5 additions & 2 deletions coreconf/sanitizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def main():
if len(sys.argv) < 2:
raise Exception('Specify either "asan", "msan", "sancov" or "ubsan" as argument.')
raise Exception('Specify either "asan", "msan", "sancov", "sourcecov" or "ubsan" as argument.')

sanitizer = sys.argv[1]
if sanitizer == "ubsan":
Expand All @@ -26,8 +26,11 @@ def main():
raise Exception('sancov requires another argument (edge|bb|func).')
print('-fsanitize-coverage='+sys.argv[2]+' ', end='')
return
if sanitizer == "sourcecov":
print('-fprofile-instr-generate -fcoverage-mapping', end='')
return

raise Exception('Specify either "asan", "msan", "sancov" or "ubsan" as argument.')
raise Exception('Specify either "asan", "msan", "sancov", "sourcecov" or "ubsan" as argument.')

if __name__ == '__main__':
main()
5 changes: 5 additions & 0 deletions coreconf/sanitizers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ enable_sancov()
enable_sanitizer sancov "$sancov"
}

enable_sourcecov()
{
enable_sanitizer sourcecov
}

enable_ubsan()
{
local ubsan
Expand Down
1 change: 1 addition & 0 deletions help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ NSS build tool options:
--msan enable memory sanitizer
--ubsan enable undefined behavior sanitizer
--ubsan=bool,shift,... sets specific UB sanitizers
--sourcecov enable source-based coverage sanitizer
--fuzz build fuzzing targets (this always enables static builds)
--fuzz=tls to enable TLS fuzzing mode
--fuzz=oss to build for OSS-Fuzz
Expand Down

0 comments on commit a9e3ae0

Please sign in to comment.