]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Clean up confusion about VG_(args_the_exename) which was believed to
authorFlorian Krohm <florian@eich-krohm.de>
Wed, 20 Aug 2014 21:04:14 +0000 (21:04 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Wed, 20 Aug 2014 21:04:14 +0000 (21:04 +0000)
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

cachegrind/cg_main.c
callgrind/dump.c
coregrind/m_initimg/initimg-darwin.c
coregrind/m_initimg/initimg-linux.c
coregrind/m_main.c
massif/ms_main.c

index a4869972550ad536f2603f3fc959a36836e9794a..4bb465e9e0ba3afb75edd81d14aa490c0e1d78a5 100644 (file)
@@ -1421,11 +1421,9 @@ static void fprint_CC_table_and_calc_totals(void)
    // "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) {
index aa1ecb65d54959f7aa8ee76489c647e416675f86..5cc1d27296026dade33408c2913c91f983b6f3e1 100644 (file)
@@ -1623,10 +1623,8 @@ void init_cmdbuf(void)
   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 );
index 60f74b95ea431dddb40485d0915fabb51e3412ce..89d858477f9c9951f6b054416a6b415a218d1e36 100644 (file)
@@ -333,7 +333,6 @@ Addr setup_client_stack( void*  init_sp,
    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 @@ Addr setup_client_stack( void*  init_sp,
    /* 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 @@ Addr setup_client_stack( void*  init_sp,
    }
 
    /* 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 @@ Addr setup_client_stack( void*  init_sp,
    /* 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 @@ Addr setup_client_stack( void*  init_sp,
    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 @@ Addr setup_client_stack( void*  init_sp,
       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(
index 400fa1bb2c05552a3684622533cfeb3d9c5c7704..2d942c16cef0c63cce574cfb9bbd152be7405f59 100644 (file)
@@ -400,7 +400,6 @@ Addr setup_client_stack( void*  init_sp,
    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 @@ Addr setup_client_stack( void*  init_sp,
 
    /* 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 @@ Addr setup_client_stack( void*  init_sp,
    }
 
    /* 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 @@ Addr setup_client_stack( void*  init_sp,
         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 @@ Addr setup_client_stack( void*  init_sp,
    /* 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 @@ Addr setup_client_stack( void*  init_sp,
    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 @@ Addr setup_client_stack( void*  init_sp,
       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(
index fc0c8c994bcfdd1a28328d142bb6f607b995b675..d0093f1c31dc794b13f099a81f560a83b8e2f769 100644 (file)
@@ -1275,8 +1275,7 @@ static void print_preamble ( Bool logging_to_fd,
       // 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 @@ static void print_preamble ( Bool logging_to_fd,
       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 @@ Int valgrind_main ( Int argc, HChar **argv, HChar **envp )
          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);
 
index c594b323856bb03408b3f0b231f5018860b885be..0770f3dd46522f9067259ca149c41ac5d082267e 100644 (file)
@@ -2331,15 +2331,11 @@ static void write_snapshots_to_file(const HChar* massif_out_file,
 
    // 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");