|
From: <sv...@va...> - 2005-07-19 11:25:08
|
Author: sewardj
Date: 2005-07-19 12:25:02 +0100 (Tue, 19 Jul 2005)
New Revision: 4180
Log:
New command line option: --log-file-qualifier=3DVAR. When specified,
the contents of environment variable VAR (viz, $VAR) are incorporated
into logfile names. This makes it easy to incorporate environmental
information into logfile names.
Modified:
trunk/README_XML_OUTPUT.txt
trunk/coregrind/m_main.c
trunk/coregrind/m_options.c
trunk/coregrind/pub_core_options.h
Modified: trunk/README_XML_OUTPUT.txt
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/README_XML_OUTPUT.txt 2005-07-19 07:37:51 UTC (rev 4179)
+++ trunk/README_XML_OUTPUT.txt 2005-07-19 11:25:02 UTC (rev 4180)
@@ -134,6 +134,14 @@
=20
<tool>TEXT</tool>
=20
+* OPTIONALLY, if --log-file-qualifier=3DVAR flag was given:
+
+ <logfilequalifier> <var>VAR</var> <value>$VAR</value>
+ </logfilequalifier>
+
+ That is, both the name of the environment variable and its value
+ are given.
+
* The program and args being run.
=20
<argv>
Modified: trunk/coregrind/m_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_main.c 2005-07-19 07:37:51 UTC (rev 4179)
+++ trunk/coregrind/m_main.c 2005-07-19 11:25:02 UTC (rev 4180)
@@ -1275,6 +1275,7 @@
" --log-fd=3D<number> log messages to file descriptor [2=3Dst=
derr]\n"
" --log-file=3D<file> log messages to <file>.pid<pid>\n"
" --log-file-exactly=3D<file> log messages to <file>\n"
+" --log-file-qualifier=3D<VAR> incorporate $VAR in logfile name [none=
]\n"
" --log-socket=3Dipaddr:port log messages to socket ipaddr:port\n"
" --demangle=3Dno|yes automatically demangle C++ names? [yes]=
\n"
" --num-callers=3D<number> show <num> callers in stack traces [12]=
\n"
@@ -1534,6 +1535,15 @@
VG_(clo_log_name) =3D &arg[11];
}
=20
+ else if (VG_CLO_STREQN(11, arg, "--log-file=3D")) {
+ log_to =3D VgLogTo_File;
+ VG_(clo_log_name) =3D &arg[11];
+ }
+
+ else if (VG_CLO_STREQN(21, arg, "--log-file-qualifier=3D")) {
+ VG_(clo_log_file_qualifier) =3D &arg[21];
+ }
+
else if (VG_CLO_STREQN(19, arg, "--log-file-exactly=3D")) {
log_to =3D VgLogTo_FileExactly;
VG_(clo_log_name) =3D &arg[19];
@@ -1696,20 +1706,29 @@
break;
=20
case VgLogTo_File: {
- Char logfilename[1000];
- Int seq =3D 0;
- Int pid =3D VG_(getpid)();
+ HChar logfilename[1000];
+ Int seq =3D 0;
+ Int pid =3D VG_(getpid)();
+ HChar* qual =3D NULL;
=20
vg_assert(VG_(clo_log_name) !=3D NULL);
vg_assert(VG_(strlen)(VG_(clo_log_name)) <=3D 900); /* paranoia=
*/
=20
+ if (VG_(clo_log_file_qualifier)) {
+ qual =3D VG_(getenv)(VG_(clo_log_file_qualifier));
+ }
+
for (;;) {
if (seq =3D=3D 0)
- VG_(sprintf)(logfilename, "%s.pid%d",
- VG_(clo_log_name), pid );
+ VG_(sprintf)( logfilename, "%s%s%s.pid%d",
+ VG_(clo_log_name),=20
+ qual ? "." : "", qual ? qual : "",
+ pid );
else
- VG_(sprintf)(logfilename, "%s.pid%d.%d",
- VG_(clo_log_name), pid, seq );
+ VG_(sprintf)( logfilename, "%s%s%s.pid%d.%d",
+ VG_(clo_log_name),=20
+ qual ? "." : "", qual ? qual : "",
+ pid, seq );
seq++;
=20
// EXCL: it will fail with EEXIST if the file already exists=
.
@@ -1879,6 +1898,13 @@
VG_(message)(Vg_UserMsg, "<pid>%d</pid>", VG_(getpid)());
VG_(message)(Vg_UserMsg, "<ppid>%d</ppid>", VG_(getppid)());
VG_(message)(Vg_UserMsg, "<tool>%s</tool>", toolname);
+ if (VG_(clo_log_file_qualifier)) {
+ HChar* val =3D VG_(getenv)(VG_(clo_log_file_qualifier));
+ VG_(message)(Vg_UserMsg, "<logfilequalifier> <var>%s</var> "
+ "<value>%s</value> </logfilequalifier>=
",
+ VG_(clo_log_file_qualifier),
+ val ? val : "");
+ }
VG_(message)(Vg_UserMsg, "");
VG_(message)(Vg_UserMsg, "<argv>"); =20
for (i =3D 0; i < VG_(client_argc); i++) {
Modified: trunk/coregrind/m_options.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_options.c 2005-07-19 07:37:51 UTC (rev 4179)
+++ trunk/coregrind/m_options.c 2005-07-19 11:25:02 UTC (rev 4180)
@@ -48,6 +48,7 @@
Bool VG_(clo_trace_children) =3D False;
Int VG_(clo_log_fd) =3D 2;
Char* VG_(clo_log_name) =3D NULL;
+Char* VG_(clo_log_file_qualifier) =3D NULL;
Bool VG_(clo_time_stamp) =3D False;
Int VG_(clo_input_fd) =3D 0; /* stdin */
Int VG_(clo_n_suppressions) =3D 0;
Modified: trunk/coregrind/pub_core_options.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/pub_core_options.h 2005-07-19 07:37:51 UTC (rev 4179)
+++ trunk/coregrind/pub_core_options.h 2005-07-19 11:25:02 UTC (rev 4180)
@@ -71,6 +71,12 @@
made to hold the relevant file id, by opening clo_log_name
(concatenated with the process ID) for writing.
=20
+ With --log-file, there is an additional twist: if
+ clo_log_file_qualifier is non-NULL, the contents of the environment
+ variable specified by clo_log_file_qualifier is incorporated into
+ the logfile name. This is useful in that it allows the logfile
+ name to incorporate environmental information.
+
With --log-socket, clo_log_name holds the hostname:portnumber pair,
and is taken from the command line. clo_log_fd is then made to hold
the relevant file handle, by opening a connection to that
@@ -78,8 +84,9 @@
=20
Global default is to set log_to =3D=3D VgLogTo_Fd and log_fd =3D=3D 2
(stderr). */
-extern Int VG_(clo_log_fd);
-extern Char* VG_(clo_log_name);
+extern Int VG_(clo_log_fd);
+extern Char* VG_(clo_log_name);
+extern Char* VG_(clo_log_file_qualifier);
=20
/* Add timestamps to log messages? default: NO */
extern Bool VG_(clo_time_stamp);
|
|
From: Nicholas N. <nj...@cs...> - 2005-07-19 13:38:29
|
On Tue, 19 Jul 2005, sv...@va... wrote: > Log: > New command line option: --log-file-qualifier=VAR. When specified, > the contents of environment variable VAR (viz, $VAR) are incorporated > into logfile names. This makes it easy to incorporate environmental > information into logfile names. How is this used in practice? I'm just curious. N |
|
From: Julian S. <js...@ac...> - 2005-07-19 13:58:24
|
> > New command line option: --log-file-qualifier=VAR. When specified, > How is this used in practice? I'm just curious. Intended use is to specify (eg) --log-file-qualifier=MPI_RANK. A parallel job launcher (eg mpirun) typically sets this env var differently for each task in a parallel run (since the client instances need to know their identities) and this allows V to extract that info too and name log files accordingly. J |
|
From: Ashley P. <as...@qu...> - 2005-07-19 17:56:07
|
On Tue, 2005-07-19 at 14:58 +0100, Julian Seward wrote: > > > New command line option: --log-file-qualifier=VAR. When specified, > > How is this used in practice? I'm just curious. > > Intended use is to specify (eg) --log-file-qualifier=MPI_RANK. A parallel > job launcher (eg mpirun) typically sets this env var differently for each > task in a parallel run (since the client instances need to know their > identities) and this allows V to extract that info too and name log files > accordingly. Ooh that will be useful, I was wondering about this very problem this morning. Ashley, |