|
From: <sv...@va...> - 2010-08-31 15:24:45
|
Author: bart
Date: 2010-08-31 16:18:32 +0100 (Tue, 31 Aug 2010)
New Revision: 11312
Log:
Added command-line option --prefix-to-strip=... Closes #245535.
Added:
trunk/memcheck/tests/badfree3.stderr.exp
trunk/memcheck/tests/badfree3.vgtest
Modified:
trunk/coregrind/m_debuginfo/debuginfo.c
trunk/coregrind/m_main.c
trunk/coregrind/m_options.c
trunk/coregrind/pub_core_options.h
trunk/docs/xml/manual-core.xml
trunk/memcheck/tests/Makefile.am
trunk/none/tests/cmdline1.stdout.exp
trunk/none/tests/cmdline2.stdout.exp
Modified: trunk/coregrind/m_debuginfo/debuginfo.c
===================================================================
--- trunk/coregrind/m_debuginfo/debuginfo.c 2010-08-31 15:15:35 UTC (rev 11311)
+++ trunk/coregrind/m_debuginfo/debuginfo.c 2010-08-31 15:18:32 UTC (rev 11312)
@@ -1854,7 +1854,21 @@
APPEND("???");
}
if (know_srcloc) {
+ const Char* const pfx = VG_(clo_prefix_to_strip);
APPEND(" (");
+ if (pfx) {
+ const int pfxlen = VG_(strlen)(pfx);
+ const int matchlen = VG_(strncmp)(pfx, buf_dirname, pfxlen) == 0
+ ? pfxlen : 0;
+ if (matchlen && buf_dirname[matchlen] == '/'
+ && buf_dirname[matchlen + 1]) {
+ APPEND(buf_dirname + matchlen + 1);
+ APPEND("/");
+ } else if (buf_dirname[matchlen]) {
+ APPEND(buf_dirname + matchlen);
+ APPEND("/");
+ }
+ }
APPEND(buf_srcloc);
APPEND(":");
VG_(sprintf)(ibuf,"%d",lineno);
Modified: trunk/coregrind/m_main.c
===================================================================
--- trunk/coregrind/m_main.c 2010-08-31 15:15:35 UTC (rev 11311)
+++ trunk/coregrind/m_main.c 2010-08-31 15:18:32 UTC (rev 11312)
@@ -163,6 +163,9 @@
" and use it to print better error messages in\n"
" tools that make use of it (Memcheck, Helgrind,\n"
" DRD) [no]\n"
+" --prefix-to-strip=<pfx> If not empty, specifies that full source file\n"
+" paths must be printed in call stacks and also\n" " that <pfx> must be stripped from these paths.\n"
+" [""].\n"
" --run-libc-freeres=no|yes free up glibc memory at exit on Linux? [yes]\n"
" --sim-hints=hint1,hint2,... known hints:\n"
" lax-ioctls, enable-outer [none]\n"
@@ -479,6 +482,13 @@
else if VG_STR_CLO (arg, "--sim-hints", VG_(clo_sim_hints)) {}
else if VG_BOOL_CLO(arg, "--sym-offsets", VG_(clo_sym_offsets)) {}
else if VG_BOOL_CLO(arg, "--read-var-info", VG_(clo_read_var_info)) {}
+ else if VG_STR_CLO (arg, "--prefix-to-strip", VG_(clo_prefix_to_strip)) {
+ Char *const pfx = VG_(clo_prefix_to_strip);
+ Char *const pfx_end = pfx + VG_(strlen)(pfx);
+ Char *const last_slash = VG_(strrchr)(pfx, '/');
+ if (last_slash == pfx_end - 1)
+ *last_slash = '\0';
+ }
else if VG_INT_CLO (arg, "--dump-error", VG_(clo_dump_error)) {}
else if VG_INT_CLO (arg, "--input-fd", VG_(clo_input_fd)) {}
Modified: trunk/coregrind/m_options.c
===================================================================
--- trunk/coregrind/m_options.c 2010-08-31 15:15:35 UTC (rev 11311)
+++ trunk/coregrind/m_options.c 2010-08-31 15:18:32 UTC (rev 11312)
@@ -83,6 +83,7 @@
Char* VG_(clo_sim_hints) = NULL;
Bool VG_(clo_sym_offsets) = False;
Bool VG_(clo_read_var_info) = False;
+Char* VG_(clo_prefix_to_strip) = NULL;
Int VG_(clo_n_req_tsyms) = 0;
HChar* VG_(clo_req_tsyms)[VG_CLO_MAX_REQ_TSYMS];
HChar* VG_(clo_require_text_symbol) = NULL;
Modified: trunk/coregrind/pub_core_options.h
===================================================================
--- trunk/coregrind/pub_core_options.h 2010-08-31 15:15:35 UTC (rev 11311)
+++ trunk/coregrind/pub_core_options.h 2010-08-31 15:18:32 UTC (rev 11312)
@@ -128,6 +128,8 @@
extern Bool VG_(clo_sym_offsets);
/* Read DWARF3 variable info even if tool doesn't ask for it? */
extern Bool VG_(clo_read_var_info);
+/* Which prefix to strip from full source file paths, if any. */
+extern Char* VG_(clo_prefix_to_strip);
/* An array of strings harvested from --require-text-symbol=
flags.
Modified: trunk/docs/xml/manual-core.xml
===================================================================
--- trunk/docs/xml/manual-core.xml 2010-08-31 15:15:35 UTC (rev 11311)
+++ trunk/docs/xml/manual-core.xml 2010-08-31 15:18:32 UTC (rev 11312)
@@ -997,6 +997,20 @@
</listitem>
</varlistentry>
+ <varlistentry id="opt.prefix-to-strip" xreflabel="--prefix-to-strip">
+ <term>
+ <option><![CDATA[--prefix-to-strip=<prefix> [default: off] ]]></option>
+ </term>
+ <listitem>
+ <para>By default Valgrind only shows the filename in stack traces and
+ not the full path of the source file. When using
+ <option>--prefix-to-strip</option>, Valgrind will include the full
+ path of source files in stack traces. If a path starts with the
+ specified prefix, the prefix will be left out from the printed path.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry id="opt.suppressions" xreflabel="--suppressions">
<term>
<option><![CDATA[--suppressions=<filename> [default: $PREFIX/lib/valgrind/default.supp] ]]></option>
Modified: trunk/memcheck/tests/Makefile.am
===================================================================
--- trunk/memcheck/tests/Makefile.am 2010-08-31 15:15:35 UTC (rev 11311)
+++ trunk/memcheck/tests/Makefile.am 2010-08-31 15:18:32 UTC (rev 11312)
@@ -46,6 +46,7 @@
badaddrvalue.stdout.exp badaddrvalue.vgtest \
badfree-2trace.stderr.exp badfree-2trace.vgtest \
badfree.stderr.exp badfree.vgtest \
+ badfree3.stderr.exp badfree3.vgtest \
badjump.stderr.exp badjump.vgtest \
badjump2.stderr.exp badjump2.vgtest \
badloop.stderr.exp badloop.vgtest \
Added: trunk/memcheck/tests/badfree3.stderr.exp
===================================================================
--- trunk/memcheck/tests/badfree3.stderr.exp (rev 0)
+++ trunk/memcheck/tests/badfree3.stderr.exp 2010-08-31 15:18:32 UTC (rev 11312)
@@ -0,0 +1,10 @@
+Invalid free() / delete / delete[]
+ at 0x........: free (coregrind/vg_replace_malloc.c:...)
+ by 0x........: main (memcheck/tests/badfree.c:12)
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+Invalid free() / delete / delete[]
+ at 0x........: free (coregrind/vg_replace_malloc.c:...)
+ by 0x........: main (memcheck/tests/badfree.c:15)
+ Address 0x........ is on thread 1's stack
+
Added: trunk/memcheck/tests/badfree3.vgtest
===================================================================
--- trunk/memcheck/tests/badfree3.vgtest (rev 0)
+++ trunk/memcheck/tests/badfree3.vgtest 2010-08-31 15:18:32 UTC (rev 11312)
@@ -0,0 +1,2 @@
+prog: badfree
+vgopts: -q --prefix-to-strip=${PWD}
Modified: trunk/none/tests/cmdline1.stdout.exp
===================================================================
--- trunk/none/tests/cmdline1.stdout.exp 2010-08-31 15:15:35 UTC (rev 11311)
+++ trunk/none/tests/cmdline1.stdout.exp 2010-08-31 15:18:32 UTC (rev 11312)
@@ -51,6 +51,10 @@
and use it to print better error messages in
tools that make use of it (Memcheck, Helgrind,
DRD) [no]
+ --prefix-to-strip=<pfx> If not empty, specifies that full source file
+ paths must be printed in call stacks and also
+ that <pfx> must be stripped from these paths.
+ [].
--run-libc-freeres=no|yes free up glibc memory at exit on Linux? [yes]
--sim-hints=hint1,hint2,... known hints:
lax-ioctls, enable-outer [none]
Modified: trunk/none/tests/cmdline2.stdout.exp
===================================================================
--- trunk/none/tests/cmdline2.stdout.exp 2010-08-31 15:15:35 UTC (rev 11311)
+++ trunk/none/tests/cmdline2.stdout.exp 2010-08-31 15:18:32 UTC (rev 11312)
@@ -51,6 +51,10 @@
and use it to print better error messages in
tools that make use of it (Memcheck, Helgrind,
DRD) [no]
+ --prefix-to-strip=<pfx> If not empty, specifies that full source file
+ paths must be printed in call stacks and also
+ that <pfx> must be stripped from these paths.
+ [].
--run-libc-freeres=no|yes free up glibc memory at exit on Linux? [yes]
--sim-hints=hint1,hint2,... known hints:
lax-ioctls, enable-outer [none]
|