Don't print the client's argv[i] if it's null, and related changes.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4629
This commit is contained in:
Nicholas Nethercote 2005-09-13 00:46:27 +00:00
parent 7310d60c12
commit ca38159b2d
3 changed files with 15 additions and 9 deletions

View File

@ -896,10 +896,10 @@ static void fprint_CC_table_and_calc_totals(void)
VG_(strcpy)(buf, "cmd:");
VG_(write)(fd, (void*)buf, VG_(strlen)(buf));
for (i = 0; i < VG_(client_argc); i++) {
if (VG_(client_argv)[i] == NULL)
continue;
VG_(write)(fd, " ", 1);
VG_(write)(fd, VG_(client_argv)[i], VG_(strlen)(VG_(client_argv)[i]));
if (VG_(client_argv)[i]) {
VG_(write)(fd, " ", 1);
VG_(write)(fd, VG_(client_argv)[i], VG_(strlen)(VG_(client_argv)[i]));
}
}
// "events:" line
VG_(sprintf)(buf, "\nevents: Ir I1mr I2mr Dr D1mr D2mr Dw D1mw D2mw\n");

View File

@ -35,7 +35,9 @@
Command-line and environment stuff
------------------------------------------------------------------ */
/* Client args and environment (which can be inspected with VG_(getenv)(). */
/* Client args and environment. Note that VG_(client_argv)[] can be written
to by the client, so you should check each entry is non-NULL before
printing. VG_(client_envp) can be inspected with VG_(getenv)(). */
extern Int VG_(client_argc);
extern Char** VG_(client_argv);
extern Char** VG_(client_envp);

View File

@ -1341,8 +1341,10 @@ static void write_hp_file(void)
// File header, including command line
SPRINTF(buf, "JOB \"");
for (i = 0; i < VG_(client_argc); i++)
SPRINTF(buf, "%s ", VG_(client_argv)[i]);
for (i = 0; i < VG_(client_argc); i++) {
if (VG_(client_argv)[i])
SPRINTF(buf, "%s ", VG_(client_argv)[i]);
}
SPRINTF(buf, /*" (%d ms/sample)\"\n"*/ "\"\n"
"DATE \"\"\n"
"SAMPLE_UNIT \"ms\"\n"
@ -1664,8 +1666,10 @@ write_text_file(ULong total_ST, ULong heap_ST)
// Command line
SPRINTF(buf, "Command: ");
for (i = 0; i < VG_(client_argc); i++)
SPRINTF(buf, "%s ", VG_(client_argv)[i]);
for (i = 0; i < VG_(client_argc); i++) {
if (VG_(client_argv)[i])
SPRINTF(buf, "%s ", VG_(client_argv)[i]);
}
SPRINTF(buf, "\n%s\n", maybe_p);
if (clo_heap)