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");
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);
// 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"
// 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)