From 176cc5a19639ab29dfb502402c9f124909b3d966 Mon Sep 17 00:00:00 2001 From: Yutetsu TAKATSUKASA Date: Wed, 16 Dec 2020 07:33:26 +0900 Subject: [PATCH] Add --asan option that enables address sanitizer to the test driver (#2700) * Experimentally add --vltasan which enables address sanitizer Co-authored-by: Wilson Snyder --- test_regress/driver.pl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test_regress/driver.pl b/test_regress/driver.pl index c96bf4fef..21835ed9a 100755 --- a/test_regress/driver.pl +++ b/test_regress/driver.pl @@ -69,6 +69,7 @@ our $Vltmt_threads = 3; $Debug = 0; my $opt_benchmark; my @opt_tests; +my $opt_asan; my $opt_dist; my $opt_gdb; my $opt_rr; @@ -92,6 +93,7 @@ our @Opt_Driver_Verilator_Flags; Getopt::Long::config("pass_through"); if (! GetOptions( + "asan!" => \$opt_asan, "benchmark:i" => sub { $opt_benchmark = $_[1] ? $_[1] : 1; }, "debug" => \&debug, #debugi see parameter() @@ -878,6 +880,7 @@ sub compile_vlt_flags { unshift @verilator_flags, "--trace-threads 1" if $param{vltmt} && $checkflags =~ /-trace /; unshift @verilator_flags, "--trace-threads 2" if $param{vltmt} && $checkflags =~ /-trace-fst /; unshift @verilator_flags, "--debug-partition" if $param{vltmt}; + unshift @verilator_flags, "-CFLAGS -fsanitize=address -LDFLAGS -fsanitize=address" if $opt_asan; unshift @verilator_flags, "--make gmake" if $param{verilator_make_gmake}; unshift @verilator_flags, "--make cmake" if $param{verilator_make_cmake}; unshift @verilator_flags, "--exe" if @@ -2599,6 +2602,12 @@ output. =over 4 +=item --asan + +Enable address sanitizer to compile Verilated C++ code. +This may detect misuses of memory, such as out-of-bound accesses, use-after-free, +and memory leaks. + =item --benchmark [] Show execution times of each step. If an optional number is given,