Added a --mod-funcname option to cg_diff.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11488 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/NEWS b/NEWS
index d5b42dd..7c83312 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,10 @@
+Release 3.7.0 (???)
+~~~~~~~~~~~~~~~~~~~
+- Added the --mod-funcname option to cg_diff.
+
+
+
Release 3.6.0 (21 October 2010)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3.6.0 is a feature release with many significant improvements and the
diff --git a/cachegrind/cg_diff.in b/cachegrind/cg_diff.in
index 951066e..bcbe7d6 100755
--- a/cachegrind/cg_diff.in
+++ b/cachegrind/cg_diff.in
@@ -50,6 +50,7 @@
-v --version show version
--mod-filename=<expr> a Perl search-and-replace expression that is applied
to filenames, eg. --mod-filename='s/prog[0-9]/projN/'
+ --mod-funcname=<expr> like --mod-filename, but applied to function names
cg_diff is Copyright (C) 2010-2010 Nicholas Nethercote.
and licensed under the GNU General Public License, version 2.
@@ -61,6 +62,9 @@
# --mod-filename expression
my $mod_filename = undef;
+# --mod-funcname expression
+my $mod_funcname = undef;
+
#-----------------------------------------------------------------------------
# Argument and option handling
#-----------------------------------------------------------------------------
@@ -78,6 +82,9 @@
} elsif ($arg =~ /^--mod-filename=(.*)/) {
$mod_filename = $1;
+ } elsif ($arg =~ /^--mod-funcname=(.*)/) {
+ $mod_funcname = $1;
+
} else { # -h and --help fall under this case
die($usage);
}
@@ -201,7 +208,11 @@
} elsif (s/^fn=(.*)$//) {
defined($currFileName) || die;
- $currFileFuncName = "$currFileName#$1";
+ my $tmpFuncName = $1;
+ if (defined $mod_funcname) {
+ eval "\$tmpFuncName =~ $mod_funcname";
+ }
+ $currFileFuncName = "$currFileName#$tmpFuncName";
$currCC = $CCs{$currFileFuncName};
if (not defined $currCC) {
$currCC = [];
diff --git a/cachegrind/docs/cg-manual.xml b/cachegrind/docs/cg-manual.xml
index b5a820b..f48f2b4 100644
--- a/cachegrind/docs/cg-manual.xml
+++ b/cachegrind/docs/cg-manual.xml
@@ -787,6 +787,14 @@
<option>--mod-filename='s/version[0-9]/versionN/'</option> will suffice for
this case.</para>
+<para>
+Similarly, sometimes compilers auto-generate certain functions and give them
+randomized names. For example, GCC sometimes auto-generates functions with
+names like <function>T.1234</function>, and the suffixes vary from build to
+build. You can use the <option>--mod-funcname</option> option to remove
+small differences like these; it works in the same way as
+<option>--mod-filename</option>.</para>
+
</sect2>
@@ -1029,6 +1037,17 @@
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>
+ <option><![CDATA[--mod-funcname=<expr> [default: none]]]></option>
+ </term>
+ <listitem>
+ <para>Like <option>--mod-filename</option>, but for filenames.
+ Useful for removing minor differences in randomized names of
+ auto-generated functions generated by some compilers.</para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
<!-- end of xi:include in the manpage -->