From a46aa2d62b78e50050191f16d1b6e24520cae149 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Tue, 10 Apr 2018 22:05:17 -0400 Subject: [PATCH] Fix verilator_profcfunc on old gprofs. --- bin/verilator | 2 +- bin/verilator_profcfunc | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bin/verilator b/bin/verilator index 7cbe723f9..901a9f0e3 100755 --- a/bin/verilator +++ b/bin/verilator @@ -1062,7 +1062,7 @@ block or wire statement. (Note this will slow down the executable by ~5%.) Furthermore, the function name will be suffixed with the basename of the Verilog module and line number the statement came from. This allows gprof or oprofile reports to be correlated with the original Verilog source -statements. +statements. See also L. =item --private diff --git a/bin/verilator_profcfunc b/bin/verilator_profcfunc index 808b36d7d..3856c2401 100755 --- a/bin/verilator_profcfunc +++ b/bin/verilator_profcfunc @@ -73,6 +73,14 @@ sub profcfunc { $funcs{$func}{sec} += $sec; $funcs{$func}{calls} += $calls; } + # Older gprofs have no call column for single-call functions + # %time cumesec selfsec {stuff} name + elsif ($line =~ /^\s*([0-9.]+)\s+[0-9.]+\s+([0-9.]+)\s+[^a-zA-Z_]*([a-zA-Z_].*)$/) { + my $pct=$1; my $sec=$2; my $calls=1; my $func=$3; + $funcs{$func}{pct} += $pct; + $funcs{$func}{sec} += $sec; + $funcs{$func}{calls} += $calls; + } } $fh->close;