Clean up confusion about VG_(args_the_exename) which was believed to
possibly be NULL in several places. Nowadays, VG_(ii_create_image) will
terminate the process if VG_(args_the_exename) is NULL.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14323 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/cachegrind/cg_main.c b/cachegrind/cg_main.c
index a486997..4bb465e 100644
--- a/cachegrind/cg_main.c
+++ b/cachegrind/cg_main.c
@@ -1421,11 +1421,9 @@
    // "cmd:" line
    VG_(strcpy)(buf, "cmd:");
    VG_(write)(fd, (void*)buf, VG_(strlen)(buf));
-   if (VG_(args_the_exename)) {
-      VG_(write)(fd, " ", 1);
-      VG_(write)(fd, VG_(args_the_exename), 
-                     VG_(strlen)( VG_(args_the_exename) ));
-   }
+   VG_(write)(fd, " ", 1);
+   VG_(write)(fd, VG_(args_the_exename), 
+              VG_(strlen)( VG_(args_the_exename) ));
    for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
       HChar* arg = * (HChar**) VG_(indexXA)( VG_(args_for_client), i );
       if (arg) {
diff --git a/callgrind/dump.c b/callgrind/dump.c
index aa1ecb6..5cc1d27 100644
--- a/callgrind/dump.c
+++ b/callgrind/dump.c
@@ -1623,10 +1623,8 @@
   Int i,j,size = 0;
   HChar* argv;
 
-  if (VG_(args_the_exename)) {
-      CLG_ASSERT( VG_(strlen)( VG_(args_the_exename) ) < BUF_LEN-1);
-      size = VG_(sprintf)(cmdbuf, " %s", VG_(args_the_exename));
-  }
+  CLG_ASSERT( VG_(strlen)( VG_(args_the_exename) ) < BUF_LEN-1);
+  size = VG_(sprintf)(cmdbuf, " %s", VG_(args_the_exename));
 
   for(i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
       argv = * (HChar**) VG_(indexXA)( VG_(args_for_client), i );
diff --git a/coregrind/m_initimg/initimg-darwin.c b/coregrind/m_initimg/initimg-darwin.c
index 60f74b9..89d8584 100644
--- a/coregrind/m_initimg/initimg-darwin.c
+++ b/coregrind/m_initimg/initimg-darwin.c
@@ -333,7 +333,6 @@
    Addr client_SP;	        /* client stack base (initial SP) */
    Addr clstack_start;
    Int i;
-   Bool have_exename;
 
    vg_assert(VG_IS_PAGE_ALIGNED(clstack_end+1));
    vg_assert( VG_(args_for_client) );
@@ -343,7 +342,6 @@
    /* first of all, work out how big the client stack will be */
    stringsize   = 0;
    auxsize = 0;
-   have_exename = VG_(args_the_exename) != NULL;
 
    /* paste on the extra args if the loader needs them (ie, the #! 
       interpreter and its argument) */
@@ -358,8 +356,7 @@
    }
 
    /* now scan the args we're given... */
-   if (have_exename)
-      stringsize += VG_(strlen)( VG_(args_the_exename) ) + 1;
+   stringsize += VG_(strlen)( VG_(args_the_exename) ) + 1;
 
    for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
       argc++;
@@ -387,7 +384,7 @@
    /* OK, now we know how big the client stack is */
    stacksize =
       sizeof(Word) +                          /* argc */
-      (have_exename ? sizeof(HChar **) : 0) + /* argc[0] == exename */
+      sizeof(HChar **) +                      /* argc[0] == exename */
       sizeof(HChar **)*argc +                 /* argv */
       sizeof(HChar **) +                      /* terminal NULL */
       sizeof(HChar **)*envc +                 /* envp */
@@ -435,7 +432,7 @@
    if (info->dynamic) *ptr++ = info->text;
 
    /* --- client argc --- */
-   *ptr++ = (Addr)(argc + (have_exename ? 1 : 0));
+   *ptr++ = (Addr)(argc + 1);
 
    /* --- client argv --- */
    if (info->interp_name) {
@@ -447,8 +444,7 @@
       VG_(free)(info->interp_args);
    }
 
-   if (have_exename)
-      *ptr++ = (Addr)copy_str(&strtab, VG_(args_the_exename));
+   *ptr++ = (Addr)copy_str(&strtab, VG_(args_the_exename));
 
    for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
       *ptr++ = (Addr)copy_str(
diff --git a/coregrind/m_initimg/initimg-linux.c b/coregrind/m_initimg/initimg-linux.c
index 400fa1b..2d942c1 100644
--- a/coregrind/m_initimg/initimg-linux.c
+++ b/coregrind/m_initimg/initimg-linux.c
@@ -400,7 +400,6 @@
    Addr client_SP;	        /* client stack base (initial SP) */
    Addr clstack_start;
    Int i;
-   Bool have_exename;
 
    vg_assert(VG_IS_PAGE_ALIGNED(clstack_end+1));
    vg_assert( VG_(args_for_client) );
@@ -412,7 +411,6 @@
 
    /* first of all, work out how big the client stack will be */
    stringsize   = 0;
-   have_exename = VG_(args_the_exename) != NULL;
 
    /* paste on the extra args if the loader needs them (ie, the #! 
       interpreter and its argument) */
@@ -427,8 +425,7 @@
    }
 
    /* now scan the args we're given... */
-   if (have_exename)
-      stringsize += VG_(strlen)( VG_(args_the_exename) ) + 1;
+   stringsize += VG_(strlen)( VG_(args_the_exename) ) + 1;
 
    for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
       argc++;
@@ -452,7 +449,7 @@
 	 stringsize += VG_(strlen)(cauxv->u.a_ptr) + 1;
       else if (cauxv->a_type == AT_RANDOM)
 	 stringsize += 16;
-      else if (cauxv->a_type == AT_EXECFN && have_exename)
+      else if (cauxv->a_type == AT_EXECFN)
 	 stringsize += VG_(strlen)(VG_(args_the_exename)) + 1;
       auxsize += sizeof(*cauxv);
    }
@@ -465,7 +462,7 @@
    /* OK, now we know how big the client stack is */
    stacksize =
       sizeof(Word) +                          /* argc */
-      (have_exename ? sizeof(HChar **) : 0) + /* argc[0] == exename */
+      sizeof(HChar **) +                      /* argc[0] == exename */
       sizeof(HChar **)*argc +                 /* argv */
       sizeof(HChar **) +                      /* terminal NULL */
       sizeof(HChar **)*envc +                 /* envp */
@@ -577,7 +574,7 @@
    ptr = (Addr*)client_SP;
 
    /* --- client argc --- */
-   *ptr++ = argc + (have_exename ? 1 : 0);
+   *ptr++ = argc + 1;
 
    /* --- client argv --- */
    if (info->interp_name) {
@@ -589,8 +586,7 @@
       VG_(free)(info->interp_args);
    }
 
-   if (have_exename)
-      *ptr++ = (Addr)copy_str(&strtab, VG_(args_the_exename));
+   *ptr++ = (Addr)copy_str(&strtab, VG_(args_the_exename));
 
    for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
       *ptr++ = (Addr)copy_str(
diff --git a/coregrind/m_main.c b/coregrind/m_main.c
index fc0c8c9..d0093f1 100644
--- a/coregrind/m_main.c
+++ b/coregrind/m_main.c
@@ -1275,8 +1275,7 @@
       // paste the command line (because of the "==pid==" prefixes), so we now
       // favour utility and simplicity over aesthetics.
       umsg_or_xml("%sCommand: ", xpre);
-      if (VG_(args_the_exename))
-         umsg_or_xml_arg(VG_(args_the_exename));
+      umsg_or_xml_arg(VG_(args_the_exename));
           
       for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
          HChar* s = *(HChar**)VG_(indexXA)( VG_(args_for_client), i );
@@ -1327,8 +1326,7 @@
       VG_(printf_xml)("  </vargv>\n");
 
       VG_(printf_xml)("  <argv>\n");
-      if (VG_(args_the_exename))
-         VG_(printf_xml)("    <exe>%pS</exe>\n",
+      VG_(printf_xml)("    <exe>%pS</exe>\n",
                                 VG_(args_the_exename));
       for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
          VG_(printf_xml)(
@@ -1876,8 +1874,7 @@
          VG_(err_config_error)("Can't create client cmdline file in %s\n", buf2);
 
       nul[0] = 0;
-      exename = VG_(args_the_exename) ? VG_(args_the_exename)
-                                      : "unknown_exename";
+      exename = VG_(args_the_exename);
       VG_(write)(fd, exename, VG_(strlen)( exename ));
       VG_(write)(fd, nul, 1);
 
diff --git a/massif/ms_main.c b/massif/ms_main.c
index c594b32..0770f3d 100644
--- a/massif/ms_main.c
+++ b/massif/ms_main.c
@@ -2331,15 +2331,11 @@
 
    // Print "cmd:" line.
    FP("cmd: ");
-   if (VG_(args_the_exename)) {
-      FP("%s", VG_(args_the_exename));
-      for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
-         HChar* arg = * (HChar**) VG_(indexXA)( VG_(args_for_client), i );
-         if (arg)
-            FP(" %s", arg);
-      }
-   } else {
-      FP(" ???");
+   FP("%s", VG_(args_the_exename));
+   for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
+      HChar* arg = * (HChar**) VG_(indexXA)( VG_(args_for_client), i );
+      if (arg)
+         FP(" %s", arg);
    }
    FP("\n");