|
From: <sv...@va...> - 2009-07-29 23:34:57
|
Author: njn
Date: 2009-07-30 00:34:49 +0100 (Thu, 30 Jul 2009)
New Revision: 10657
Log:
Print the command being run at startup. It wraps to avoid going over 80
chars wide whenever possible. Finishes off bug 197933.
Added:
trunk/none/tests/filter_long_command
trunk/none/tests/long-command.stderr.exp
trunk/none/tests/long-command.vgtest
Modified:
trunk/NEWS
trunk/coregrind/m_main.c
trunk/docs/xml/manual-writing-tools.xml
trunk/none/tests/Makefile.am
trunk/none/tests/filter_timestamp
trunk/tests/filter_stderr_basic
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2009-07-29 11:09:01 UTC (rev 10656)
+++ trunk/NEWS 2009-07-29 23:34:49 UTC (rev 10657)
@@ -31,6 +31,16 @@
* XXX: exp-bbv has been added...
+* Valgrind's start-up message has changed. It is shorter but also includes
+ the command being run, which makes it easier to use --trace-children=yes.
+ An example:
+
+==3050== Memcheck, a memory error detector.
+==3050== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
+==3050== Using Valgrind-3.5.0.SVN and LibVEX; rerun with -h for copyright info
+==3050== Command: ls -l
+==3050==
+
* A new Memcheck client request VALGRIND_COUNT_LEAK_BLOCKS has been added.
It is similar to VALGRIND_COUNT_LEAKS but counts blocks instead of bytes.
[XXX: consider adding VALGRIND_COUNT_LEAK_BYTES as a synonym and
Modified: trunk/coregrind/m_main.c
===================================================================
--- trunk/coregrind/m_main.c 2009-07-29 11:09:01 UTC (rev 10656)
+++ trunk/coregrind/m_main.c 2009-07-29 23:34:49 UTC (rev 10657)
@@ -967,6 +967,7 @@
const HChar* toolname )
{
Int i;
+ SizeT n;
HChar* xpre = VG_(clo_xml) ? " <line>" : "";
HChar* xpost = VG_(clo_xml) ? "</line>" : "";
UInt (*umsg_or_xml)( const HChar*, ... )
@@ -1017,6 +1018,35 @@
xpre, VERSION, xpost
);
+ /* Print the command line, wrapping near 80-chars wide. An example of a
+ command line with many args, some of them very long:
+
+==9717== Command: date 11 23 4a \
+==9717== aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
+==9717== aaa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 \
+==9717== 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 \
+==9717== fffffffffffffffffffffffffffff 1 2 3 \
+==9717== bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+ */
+ VG_(umsg)("Command: ");
+ if (VG_(args_the_exename))
+ VG_(umsg)("%s", VG_(args_the_exename));
+ n = 0;
+ for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
+ HChar* s = *(HChar**)VG_(indexXA)( VG_(args_for_client), i );
+ SizeT slen = VG_(strlen)(s);
+ n += slen + 1; // +1 for the space char between each argument
+ // With a PID of up to 5 digits, 58 puts the line-ending '\' in
+ // column 79 at the most, always leaving column 80 empty.
+ if (n > 58) {
+ VG_(umsg)(" \\");
+ VG_(umsg)("\n ");
+ n = slen;
+ }
+ VG_(umsg)(" %s", s);
+ }
+ VG_(umsg)("\n");
+
if (VG_(clo_xml))
VG_(printf_xml)("</preamble>\n");
}
@@ -1091,15 +1121,7 @@
VexArchInfo vex_archinfo;
if (!logging_to_fd)
VG_(message)(Vg_DebugMsg, "\n");
- VG_(message)(Vg_DebugMsg, "Command line\n");
- if (VG_(args_the_exename))
- VG_(message)(Vg_DebugMsg, " %s\n", VG_(args_the_exename));
- for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++)
- VG_(message)(Vg_DebugMsg,
- " %s\n",
- * (HChar**) VG_(indexXA)( VG_(args_for_client), i ));
-
- VG_(message)(Vg_DebugMsg, "Startup, with flags:\n");
+ VG_(message)(Vg_DebugMsg, "Valgrind flags:\n");
for (i = 0; i < VG_(sizeXA)( VG_(args_for_valgrind) ); i++) {
VG_(message)(Vg_DebugMsg,
" %s\n",
@@ -1113,10 +1135,10 @@
} else {
# define BUF_LEN 256
Char version_buf[BUF_LEN];
- Int n = VG_(read) ( sr_Res(fd), version_buf, BUF_LEN );
- vg_assert(n <= BUF_LEN);
- if (n > 0) {
- version_buf[n-1] = '\0';
+ Int nn = VG_(read) ( sr_Res(fd), version_buf, BUF_LEN );
+ vg_assert(nn <= BUF_LEN);
+ if (nn > 0) {
+ version_buf[nn-1] = '\0';
VG_(message)(Vg_DebugMsg, " %s\n", version_buf);
} else {
VG_(message)(Vg_DebugMsg, " (empty?)\n");
Modified: trunk/docs/xml/manual-writing-tools.xml
===================================================================
--- trunk/docs/xml/manual-writing-tools.xml 2009-07-29 11:09:01 UTC (rev 10656)
+++ trunk/docs/xml/manual-writing-tools.xml 2009-07-29 23:34:49 UTC (rev 10657)
@@ -153,13 +153,10 @@
<computeroutput>date</computeroutput> is just an example).
The output should be something like this:</para>
<programlisting><![CDATA[
- ==738== foobar-0.0.1, a foobarring tool for x86-linux.
- ==738== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
- ==738== Using LibVEX rev 1791, a library for dynamic binary translation.
- ==738== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
- ==738== Using valgrind-3.3.0, a dynamic binary instrumentation framework.
- ==738== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
- ==738== For more details, rerun with: -v
+ ==738== foobar-0.0.1, a foobarring tool.
+ ==738== Copyright (C) 2002-2009, and GNU GPL'd, by J. Programmer.
+ ==738== Using Valgrind-3.5.0.SVN and LibVEX; rerun with -h for copyright info
+ ==738== Command: date
==738==
Tue Nov 27 12:40:49 EST 2007
==738==]]></programlisting>
Modified: trunk/none/tests/Makefile.am
===================================================================
--- trunk/none/tests/Makefile.am 2009-07-29 11:09:01 UTC (rev 10656)
+++ trunk/none/tests/Makefile.am 2009-07-29 23:34:49 UTC (rev 10657)
@@ -34,8 +34,9 @@
dist_noinst_SCRIPTS = \
filter_cmdline0 \
+ filter_fdleak \
filter_linenos \
- filter_fdleak \
+ filter_long_command \
filter_none_discards \
filter_stderr \
filter_timestamp
@@ -79,6 +80,7 @@
fork.stderr.exp fork.stdout.exp fork.vgtest \
fucomip.stderr.exp fucomip.vgtest \
gxx304.stderr.exp gxx304.vgtest \
+ long-command.stderr.exp long-command.vgtest \
manythreads.stdout.exp manythreads.stderr.exp manythreads.vgtest \
map_unaligned.stderr.exp map_unaligned.vgtest \
map_unmap.stderr.exp map_unmap.stdout.exp map_unmap.vgtest \
Added: trunk/none/tests/filter_long_command
===================================================================
--- trunk/none/tests/filter_long_command (rev 0)
+++ trunk/none/tests/filter_long_command 2009-07-29 23:34:49 UTC (rev 10657)
@@ -0,0 +1,9 @@
+#! /bin/sh
+
+dir=`dirname $0`
+
+# We change the "Command:" so it doesn't get stripped out by the standard
+# filters.
+sed "s/Command:/COMMAND:/" |
+
+./filter_stderr
Property changes on: trunk/none/tests/filter_long_command
___________________________________________________________________
Name: svn:executable
+ *
Modified: trunk/none/tests/filter_timestamp
===================================================================
--- trunk/none/tests/filter_timestamp 2009-07-29 11:09:01 UTC (rev 10656)
+++ trunk/none/tests/filter_timestamp 2009-07-29 23:34:49 UTC (rev 10657)
@@ -11,6 +11,7 @@
sed "/ Nulgrind.*$/ d" |
sed "/ Copyright.*$/ d" |
sed "/ Using Valgrind.*$/ d" |
+sed "/ Command:.*$/ d" |
$dir/filter_stderr |
Added: trunk/none/tests/long-command.stderr.exp
===================================================================
--- trunk/none/tests/long-command.stderr.exp (rev 0)
+++ trunk/none/tests/long-command.stderr.exp 2009-07-29 23:34:49 UTC (rev 10657)
@@ -0,0 +1,10 @@
+COMMAND: ./../../tests/true 11 23 4a \
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
+ aaa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 \
+ 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 \
+ fffffffffffffffffffffffffffff 1 2 3 \
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 1 2 3 4 1 \
+ 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 \
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+
+
Added: trunk/none/tests/long-command.vgtest
===================================================================
--- trunk/none/tests/long-command.vgtest (rev 0)
+++ trunk/none/tests/long-command.vgtest 2009-07-29 23:34:49 UTC (rev 10657)
@@ -0,0 +1,2 @@
+prog: ../../tests/true 11 23 4a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 fffffffffffffffffffffffffffff 1 2 3 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+stderr_filter: filter_long_command
Modified: trunk/tests/filter_stderr_basic
===================================================================
--- trunk/tests/filter_stderr_basic 2009-07-29 11:09:01 UTC (rev 10656)
+++ trunk/tests/filter_stderr_basic 2009-07-29 23:34:49 UTC (rev 10657)
@@ -15,6 +15,10 @@
# Remove any --pid:0: strings (debuglog level zero output)
sed "/^--[0-9]\{1,7\}:0:*/d" |
+# Remove "Command: line". (If wrapping occurs, it won't remove the
+# subsequent lines...)
+sed "/^Command: .*$/d" |
+
# Remove "WARNING: assuming toc 0x.." strings
sed "/^WARNING: assuming toc 0x*/d" |
|