]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Get rid of the type XArrayStrings in m_clientstate and use new generic
authorJulian Seward <jseward@acm.org>
Sun, 25 Feb 2007 15:08:24 +0000 (15:08 +0000)
committerJulian Seward <jseward@acm.org>
Sun, 25 Feb 2007 15:08:24 +0000 (15:08 +0000)
equivalents in module m_xarray instead.  A suprisingly pervasive
change.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6616

20 files changed:
cachegrind/cg_main.c
callgrind/command.c
callgrind/dump.c
callgrind/global.h
coregrind/m_clientstate.c
coregrind/m_commandline.c
coregrind/m_coredump/coredump-elf.c
coregrind/m_debugger.c
coregrind/m_initimg/initimg-linux.c
coregrind/m_libcfile.c
coregrind/m_libcproc.c
coregrind/m_main.c
coregrind/m_redir.c
coregrind/m_signals.c
coregrind/m_stacktrace.c
coregrind/m_syswrap/syswrap-generic.c
coregrind/m_syswrap/syswrap-linux.c
include/Makefile.am
include/pub_tool_clientstate.h
massif/ms_main.c

index 5f713e055439265e3ada3508176c0f922c06eacd..b0768f77309ec43cd50f9b5737b2816f47a90c5e 100644 (file)
@@ -42,6 +42,7 @@
 #include "pub_tool_options.h"
 #include "pub_tool_oset.h"
 #include "pub_tool_tooliface.h"
+#include "pub_tool_xarray.h"
 #include "pub_tool_clientstate.h"
 #include "pub_tool_machine.h"      // VG_(fnptr_to_fnentry)
 
@@ -1026,11 +1027,11 @@ static void fprint_CC_table_and_calc_totals(void)
       VG_(write)(fd, VG_(args_the_exename), 
                      VG_(strlen)( VG_(args_the_exename) ));
    }
-   for (i = 0; i < VG_(args_for_client).used; i++) {
-      if (VG_(args_for_client).strs[i]) {
+   for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
+      HChar* arg = * (HChar**) VG_(indexXA)( VG_(args_for_client), i );
+      if (arg) {
          VG_(write)(fd, " ", 1);
-         VG_(write)(fd, VG_(args_for_client).strs[i], 
-                        VG_(strlen)(VG_(args_for_client).strs[i]));
+         VG_(write)(fd, arg, VG_(strlen)( arg ));
       }
    }
    // "events:" line
index 1e4376265b4fd216aad5bae6b206be15ed7bd31f..bc4ae5521825022c51e9d28e72ca59eb0bb9a2d2 100644 (file)
@@ -157,9 +157,11 @@ static void setup_control(void)
     VG_(write)(fd, (void*)buf, VG_(strlen)(buf));
     VG_(sprintf)(buf, " %s", VG_(args_the_exename));
     VG_(write)(fd, (void*)buf, VG_(strlen)(buf));
-    for (i = 0; i < VG_(args_for_client).used; i++) {
-       if (!VG_(args_for_client).strs[i]) continue;
-       VG_(sprintf)(buf, " %s", VG_(args_for_client).strs[i]);
+    for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
+        HChar* arg = * (HChar**)VG_(indexXA)( VG_(args_for_client), i );
+       if (!arg) continue;
+        tl_assert( VG_(strlen)(arg) < 512-4 ); /* see [512] above */
+       VG_(sprintf)(buf, " %s", arg);
        VG_(write)(fd, (void*)buf, VG_(strlen)(buf));
     }
     VG_(write)(fd, "\n", 1);
@@ -230,9 +232,10 @@ static Int dump_info(Int fd)
     VG_(write)(fd, (void*)buf, VG_(strlen)(buf));
     VG_(sprintf)(buf, " %s", VG_(args_the_exename));
     VG_(write)(fd, (void*)buf, VG_(strlen)(buf));
-    for (i = 0; i < VG_(args_for_client).used; i++) {
-       if (!VG_(args_for_client).strs[i]) continue;
-       VG_(sprintf)(buf, " %s", VG_(args_for_client).strs[i]);
+    for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
+        HChar* arg = * (HChar**)VG_(indexXA)( VG_(args_for_client), i );
+       if (!arg) continue;
+       VG_(sprintf)(buf, " %s", arg);
        VG_(write)(fd, (void*)buf, VG_(strlen)(buf));
     }
     VG_(write)(fd, "\n", 1);
index 76a5999e04a7e3d5b3dd6b1257a9b3cbfb6b6b93..2904e96366b4635d4753da5db90dde63826d4634 100644 (file)
@@ -1625,8 +1625,8 @@ void init_cmdbuf(void)
   if (VG_(args_the_exename))
       size = VG_(sprintf)(cmdbuf, " %s", VG_(args_the_exename));
 
-  for(i = 0; i < VG_(args_for_client).used; i++) {
-      argv = VG_(args_for_client).strs[i];
+  for(i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
+      argv = * (HChar**) VG_(indexXA)( VG_(args_for_client), i );
       if (!argv) continue;
       if ((size>0) && (size < BUF_LEN)) cmdbuf[size++] = ' ';
       for(j=0;argv[j]!=0;j++)
@@ -1634,7 +1634,7 @@ void init_cmdbuf(void)
   }
 #else
   for(i = 0; i < VG_(client_argc); i++) {
-    argv = VG_(client_argv[i]);
+    argv = VG_(client_argv)[i];
     if (!argv) continue;
     if ((size>0) && (size < BUF_LEN)) cmdbuf[size++] = ' ';
     for(j=0;argv[j]!=0;j++)
index 810a5d09aff78fefd76d835bc3784b9f4a4d221a..bb85bc6760ca6bec97cb45cccc8b9d85e442be16 100644 (file)
@@ -19,6 +19,7 @@
 #include "pub_tool_mallocfree.h"
 #include "pub_tool_options.h"
 #include "pub_tool_tooliface.h"
+#include "pub_tool_xarray.h"
 #include "pub_tool_clientstate.h"
 #include "pub_tool_machine.h"      // VG_(fnptr_to_fnentry)
 
index 966b96c27e6d944843372c6c65207ae385919e89..6aa3a425ab0b608ea79df01d48bc99fcd54e8c97 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "pub_core_basics.h"
 #include "pub_core_vki.h"
+#include "pub_core_xarray.h"
 #include "pub_core_clientstate.h"
 
 /*-----------------------------------------------------------------*/
@@ -64,10 +65,10 @@ Int VG_(cl_cmdline_fd) = -1;
 // (the default arena).  They are never freed.
 
 /* Args for the client. */
-XArrayStrings VG_(args_for_client) = {0,0,NULL};
+XArray* /* of HChar* */ VG_(args_for_client) = NULL;
 
 /* Args for V (augments, then those from the launcher). */
-XArrayStrings VG_(args_for_valgrind) = {0,0,NULL};
+XArray* /* of HChar* */ VG_(args_for_valgrind) = NULL;
 
 /* How many of the above not to pass on at execve time? */
 Int VG_(args_for_valgrind_noexecpass) = 0;
index 45e7b532a6813342db5cf53f44160d9398a4ceb4..aa62a1ae1a0c86e5296f323e04d38347c8a6cc47 100644 (file)
 #include "pub_core_libcprint.h"
 #include "pub_core_libcproc.h"
 #include "pub_core_mallocfree.h"
+#include "pub_core_xarray.h"
 #include "pub_core_clientstate.h"
-#include "pub_core_commandline.h"
+#include "pub_core_commandline.h" /* self */
 
 
 /* Add a string to an expandable array of strings. */
 
-static void add_string ( XArrayStrings* xa, HChar* str )
+static void add_string ( XArray* /* of HChar* */xa, HChar* str )
 {
-   Int     i;
-   HChar** strs2;
-   vg_assert(xa->used >= 0);
-   vg_assert(xa->size >= 0);
-   vg_assert(xa->used <= xa->size);
-   if (xa->strs == NULL) vg_assert(xa->size == 0);
-
-   if (xa->used == xa->size) {
-      xa->size = xa->size==0 ? 2 : 2*xa->size;
-      strs2 = VG_(malloc)( xa->size * sizeof(HChar*) );
-      for (i = 0; i < xa->used; i++)
-         strs2[i] = xa->strs[i];
-      if (xa->strs) 
-         VG_(free)(xa->strs);
-      xa->strs = strs2;
-   }
-   vg_assert(xa->used < xa->size);
-   xa->strs[xa->used++] = str;
+   VG_(addToXA)( xa, (void*)(&str) );
 }
 
 
@@ -112,7 +96,7 @@ static void add_args_from_string ( HChar* s )
       tmp = cp;
       while ( !VG_(isspace)(*cp) && *cp != 0 ) cp++;
       if ( *cp != 0 ) *cp++ = '\0';       // terminate if not the last
-      add_string( &VG_(args_for_valgrind), tmp );
+      add_string( VG_(args_for_valgrind), tmp );
    }
 }
 
@@ -163,13 +147,26 @@ void VG_(split_up_argv)( Int argc, HChar** argv )
           Bool augment = True;
    static Bool already_called = False;
 
-   XArrayStrings tmp_xarray = {0,0,NULL};
+   XArray* /* of HChar* */ tmp_xarray;
 
    /* This function should be called once, at startup, and then never
       again. */
    vg_assert(!already_called);
    already_called = True;
 
+   tmp_xarray = VG_(newXA)( VG_(malloc), VG_(free), sizeof(HChar*) );
+   vg_assert(tmp_xarray);
+
+   vg_assert( ! VG_(args_for_valgrind) );
+   VG_(args_for_valgrind)
+      = VG_(newXA)( VG_(malloc), VG_(free), sizeof(HChar*) );
+   vg_assert( VG_(args_for_valgrind) );
+
+   vg_assert( ! VG_(args_for_client) );
+   VG_(args_for_client)
+      = VG_(newXA)( VG_(malloc), VG_(free), sizeof(HChar*) );
+   vg_assert( VG_(args_for_client) );
+
    /* Collect up the args-for-V. */
    i = 1; /* skip the exe (stage2) name. */
    for (; i < argc; i++) {
@@ -182,7 +179,7 @@ void VG_(split_up_argv)( Int argc, HChar** argv )
          augment = False;
       if (argv[i][0] != '-')
        break;
-      add_string( &tmp_xarray, argv[i] );
+      add_string( tmp_xarray, argv[i] );
    }
 
    /* Should now be looking at the exe name. */
@@ -195,13 +192,9 @@ void VG_(split_up_argv)( Int argc, HChar** argv )
    /* The rest are args for the client. */
    for (; i < argc; i++) {
       vg_assert(argv[i]);
-      add_string( &VG_(args_for_client), argv[i] );
+      add_string( VG_(args_for_client), argv[i] );
    }
 
-   VG_(args_for_valgrind).size = 0;
-   VG_(args_for_valgrind).used = 0;
-   VG_(args_for_valgrind).strs = NULL;
-
    /* Get extra args from ~/.valgrindrc, $VALGRIND_OPTS and
       ./.valgrindrc into VG_(args_for_valgrind). */
    if (augment) {
@@ -219,14 +212,15 @@ void VG_(split_up_argv)( Int argc, HChar** argv )
    }
 
    /* .. and record how many extras we got. */
-   VG_(args_for_valgrind_noexecpass) = VG_(args_for_valgrind).used;
+   VG_(args_for_valgrind_noexecpass) 
+      = VG_(sizeXA)( VG_(args_for_valgrind) );
 
    /* Finally, copy tmp_xarray onto the end. */
-   for (i = 0; i < tmp_xarray.used; i++)
-      add_string( &VG_(args_for_valgrind), tmp_xarray.strs[i] );
+   for (i = 0; i < VG_(sizeXA)( tmp_xarray ); i++)
+      add_string( VG_(args_for_valgrind), 
+                  * (HChar**)VG_(indexXA)( tmp_xarray, i ) );
 
-   if (tmp_xarray.strs)
-      VG_(free)(tmp_xarray.strs);
+   VG_(deleteXA)( tmp_xarray );
 }
 
 /*--------------------------------------------------------------------*/
index 16e0c158c6d43cf29ccde2b0e3f7f2f8f96b888e..7106f1ac9ae2fb83cc3dbf1a1088e7f3062d10fe 100644 (file)
@@ -40,6 +40,7 @@
 #include "pub_core_libcassert.h"  // VG_(exit), vg_assert
 #include "pub_core_mallocfree.h"  // VG_(malloc), VG_(free)
 #include "pub_core_threadstate.h"
+#include "pub_core_xarray.h"
 #include "pub_core_clientstate.h"
 #include "pub_core_options.h"
 
index 7379252feade3bd1e0e41c5a8d57e21dd389302b..577d03bae52383c6c42e54039db4c58509b79077 100644 (file)
@@ -31,6 +31,7 @@
 #include "pub_core_basics.h"
 #include "pub_core_vki.h"
 #include "pub_core_threadstate.h"
+#include "pub_core_xarray.h"
 #include "pub_core_clientstate.h"
 #include "pub_core_debugger.h"
 #include "pub_core_libcbase.h"
index 96b46f592c01d36bf7bcd55d08f68a0e35c3b727..d6705524f54e83f05fb52a46f1a5a693979f7583 100644 (file)
@@ -37,6 +37,7 @@
 #include "pub_core_libcfile.h"
 #include "pub_core_libcproc.h"
 #include "pub_core_libcprint.h"
+#include "pub_core_xarray.h"
 #include "pub_core_clientstate.h"
 #include "pub_core_aspacemgr.h"
 #include "pub_core_mallocfree.h"
@@ -438,6 +439,7 @@ Addr setup_client_stack( void*  init_sp,
    Bool have_exename;
 
    vg_assert(VG_IS_PAGE_ALIGNED(clstack_end+1));
+   vg_assert( VG_(args_for_client) );
 
    /* use our own auxv as a prototype */
    orig_auxv = VG_(find_auxv)(init_sp);
@@ -464,9 +466,11 @@ Addr setup_client_stack( void*  init_sp,
    if (have_exename)
       stringsize += VG_(strlen)( VG_(args_the_exename) ) + 1;
 
-   for (i = 0; i < VG_(args_for_client).used; i++) {
+   for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
       argc++;
-      stringsize += VG_(strlen)( VG_(args_for_client).strs[i] ) + 1;
+      stringsize += VG_(strlen)( * (HChar**) 
+                                   VG_(indexXA)( VG_(args_for_client), i ))
+                    + 1;
    }
 
    /* ...and the environment */
@@ -604,8 +608,11 @@ Addr setup_client_stack( void*  init_sp,
    if (have_exename)
       *ptr++ = (Addr)copy_str(&strtab, VG_(args_the_exename));
 
-   for (i = 0; i < VG_(args_for_client).used; i++) {
-      *ptr++ = (Addr)copy_str(&strtab, VG_(args_for_client).strs[i]);
+   for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
+      *ptr++ = (Addr)copy_str(
+                       &strtab, 
+                       * (HChar**) VG_(indexXA)( VG_(args_for_client), i )
+                     );
    }
    *ptr++ = 0;
 
index adf54917f99b3ced7e1a8485c96d3314e931d9a3..2038ee46c1fb66d4e489d3de73a2cc3ae192cd23 100644 (file)
@@ -37,6 +37,7 @@
 #include "pub_core_libcfile.h"
 #include "pub_core_libcprint.h"     // VG_(sprintf)
 #include "pub_core_libcproc.h"      // VG_(getpid), VG_(getppid)
+#include "pub_core_xarray.h"
 #include "pub_core_clientstate.h"   // VG_(fd_hard_limit)
 #include "pub_core_syscall.h"
 
index f607611b2217b97d67eb04476cba7afa173add66..1dc748e94fd949db0eba142214fd903e12bac46a 100644 (file)
@@ -38,6 +38,7 @@
 #include "pub_core_libcsignal.h"
 #include "pub_core_mallocfree.h"
 #include "pub_core_syscall.h"
+#include "pub_core_xarray.h"
 #include "pub_core_clientstate.h"
 
 /* ---------------------------------------------------------------------
index b54b757fd4d0ec1e9feca70bd3e6be3c01e1469c..57a3ca0793398e7b3a6bc180af56a0726f212b3d 100644 (file)
@@ -32,6 +32,7 @@
 #include "pub_core_vki.h"
 #include "pub_core_vkiscnums.h"
 #include "pub_core_threadstate.h"
+#include "pub_core_xarray.h"
 #include "pub_core_clientstate.h"
 #include "pub_core_aspacemgr.h"
 #include "pub_core_commandline.h"
@@ -245,10 +246,12 @@ static void get_helprequest_and_toolname ( Int* need_help, HChar** tool )
    UInt   i;
    HChar* str;
 
+   vg_assert( VG_(args_for_valgrind) );
+
    /* parse the options we have (only the options we care about now) */
-   for (i = 0; i < VG_(args_for_valgrind).used; i++) {
+   for (i = 0; i < VG_(sizeXA)( VG_(args_for_valgrind) ); i++) {
 
-      str = VG_(args_for_valgrind).strs[i];
+      str = * (HChar**) VG_(indexXA)( VG_(args_for_valgrind), i );
       vg_assert(str);
 
       if (VG_STREQ(str, "--version")) {
@@ -295,9 +298,11 @@ static Bool process_cmd_line_options( UInt* client_auxv, const char* toolname )
       VG_(err_config_error)("Please use absolute paths in "
                             "./configure --prefix=... or --libdir=...");
 
-   for (i = 0; i < VG_(args_for_valgrind).used; i++) {
+   vg_assert( VG_(args_for_valgrind) );
+
+   for (i = 0; i < VG_(sizeXA)( VG_(args_for_valgrind) ); i++) {
 
-      HChar* arg   = VG_(args_for_valgrind).strs[i];
+      HChar* arg   = * (HChar**) VG_(indexXA)( VG_(args_for_valgrind), i );
       HChar* colon = arg;
 
       /* Look for a colon in the switch name */
@@ -494,7 +499,7 @@ static Bool process_cmd_line_options( UInt* client_auxv, const char* toolname )
          VG_(err_bad_option)(arg);
       }
     skip_arg:
-      if (arg != VG_(args_for_valgrind).strs[i]) {
+      if (arg != * (HChar**) VG_(indexXA)( VG_(args_for_valgrind), i )) {
          VG_(free)(arg);
       }
    }
@@ -744,6 +749,9 @@ static void print_preamble(Bool logging_to_fd, const char* toolname)
    HChar* xpost = VG_(clo_xml) ? "</line>" : "";
    Int    i;
 
+   vg_assert( VG_(args_for_client) );
+   vg_assert( VG_(args_for_valgrind) );
+
    if (VG_(clo_xml)) {
       VG_(message)(Vg_UserMsg, "<?xml version=\"1.0\"?>");
       VG_(message)(Vg_UserMsg, "");
@@ -798,8 +806,10 @@ static void print_preamble(Bool logging_to_fd, const char* toolname)
          VG_(getpid)(), VG_(getppid)() );
       if (VG_(args_the_exename))
          VG_(message)(Vg_UserMsg, "   %s", VG_(args_the_exename));
-      for (i = 0; i < VG_(args_for_client).used; i++) 
-         VG_(message)(Vg_UserMsg, "   %s", VG_(args_for_client).strs[i]);
+      for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) 
+       VG_(message)(Vg_UserMsg, 
+                     "   %s", 
+                     * (HChar**) VG_(indexXA)( VG_(args_for_client), i ));
       if (VG_(clo_log_file_qualifier)) {
          HChar* val = VG_(getenv)(VG_(clo_log_file_qualifier));
          VG_(message)(Vg_UserMsg, "");
@@ -835,10 +845,10 @@ static void print_preamble(Bool logging_to_fd, const char* toolname)
       if (VG_(name_of_launcher))
          VG_(message)(Vg_UserMsg, "    <exe>%t</exe>", 
                                   VG_(name_of_launcher));
-      for (i = 0; i < VG_(args_for_valgrind).used; i++) {
+      for (i = 0; i < VG_(sizeXA)( VG_(args_for_valgrind) ); i++) {
          VG_(message)(Vg_UserMsg, 
                       "    <arg>%t</arg>", 
-                      VG_(args_for_valgrind).strs[i]);
+                      * (HChar**) VG_(indexXA)( VG_(args_for_valgrind), i ));
       }
       VG_(message)(Vg_UserMsg, "  </vargv>");
 
@@ -846,9 +856,10 @@ static void print_preamble(Bool logging_to_fd, const char* toolname)
       if (VG_(args_the_exename))
          VG_(message)(Vg_UserMsg, "    <exe>%t</exe>", 
                                   VG_(args_the_exename));
-      for (i = 0; i < VG_(args_for_client).used; i++) {
-         VG_(message)(Vg_UserMsg, "    <arg>%t</arg>", 
-                                  VG_(args_for_client).strs[i]);
+      for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
+         VG_(message)(Vg_UserMsg,
+                      "    <arg>%t</arg>", 
+                      * (HChar**) VG_(indexXA)( VG_(args_for_client), i ));
       }
       VG_(message)(Vg_UserMsg, "  </argv>");
 
@@ -868,12 +879,16 @@ static void print_preamble(Bool logging_to_fd, const char* toolname)
       VG_(message)(Vg_DebugMsg, "Command line");
       if (VG_(args_the_exename))
          VG_(message)(Vg_DebugMsg, "   %s", VG_(args_the_exename));
-      for (i = 0; i < VG_(args_for_client).used; i++)
-         VG_(message)(Vg_DebugMsg, "   %s", VG_(args_for_client).strs[i]);
+      for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++)
+         VG_(message)(Vg_DebugMsg, 
+                     "   %s", 
+                     * (HChar**) VG_(indexXA)( VG_(args_for_client), i ));
 
       VG_(message)(Vg_DebugMsg, "Startup, with flags:");
-      for (i = 0; i < VG_(args_for_valgrind).used; i++) {
-         VG_(message)(Vg_DebugMsg, "   %s", VG_(args_for_valgrind).strs[i]);
+      for (i = 0; i < VG_(sizeXA)( VG_(args_for_valgrind) ); i++) {
+         VG_(message)(Vg_DebugMsg, 
+                     "   %s", 
+                     * (HChar**) VG_(indexXA)( VG_(args_for_valgrind), i ));
       }
 
       VG_(message)(Vg_DebugMsg, "Contents of /proc/version:");
@@ -1365,12 +1380,20 @@ Int valgrind_main ( Int argc, HChar **argv, HChar **envp )
    //--------------------------------------------------------------
    VG_(debugLog)(1, "main", "Split up command line\n");
    VG_(split_up_argv)( argc, argv );
+   vg_assert( VG_(args_for_valgrind) );
+   vg_assert( VG_(args_for_client) );
    if (0) {
-      for (i = 0; i < VG_(args_for_valgrind).used; i++)
-         VG_(printf)("varg %s\n", VG_(args_for_valgrind).strs[i]);
+      for (i = 0; i < VG_(sizeXA)( VG_(args_for_valgrind) ); i++)
+         VG_(printf)(
+            "varg %s\n", 
+            * (HChar**) VG_(indexXA)( VG_(args_for_valgrind), i )
+         );
       VG_(printf)(" exe %s\n", VG_(args_the_exename));
-      for (i = 0; i < VG_(args_for_client).used; i++)
-         VG_(printf)("carg %s\n", VG_(args_for_client).strs[i]);
+      for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++)
+         VG_(printf)(
+            "carg %s\n", 
+            * (HChar**) VG_(indexXA)( VG_(args_for_client), i )
+         );
    }
 
    //--------------------------------------------------------------
@@ -1482,9 +1505,9 @@ Int valgrind_main ( Int argc, HChar **argv, HChar **envp )
                      VG_(strlen)( VG_(args_the_exename) ));
       VG_(write)(fd, nul, 1);
 
-      for (i = 0; i < VG_(args_for_client).used; i++) {
-         VG_(write)(fd, VG_(args_for_client).strs[i],
-                        VG_(strlen)( VG_(args_for_client).strs[i] ));
+      for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
+         HChar* arg = * (HChar**) VG_(indexXA)( VG_(args_for_client), i );
+         VG_(write)(fd, arg, VG_(strlen)( arg ));
          VG_(write)(fd, nul, 1);
       }
 
index 1f929ffcd69f92c7d18712cf750a4d06f70415b0..057924dbbe09fa73d3df612d9443c7faed6925ad 100644 (file)
@@ -45,6 +45,7 @@
 #include "pub_core_tooliface.h"    // VG_(needs).malloc_replacement
 #include "pub_core_machine.h"      // VG_(fnptr_to_fnentry)
 #include "pub_core_aspacemgr.h"    // VG_(am_find_nsegment)
+#include "pub_core_xarray.h"
 #include "pub_core_clientstate.h"  // VG_(client___libc_freeres_wrapper)
 #include "pub_core_demangle.h"     // VG_(maybe_Z_demangle)
 
index 4f265cdf1743fcb8774367ce3f6876c76649362c..6af368f256c3183697eb781b5ae415c90c17792b 100644 (file)
@@ -84,6 +84,7 @@
 #include "pub_core_vkiscnums.h"
 #include "pub_core_debuglog.h"
 #include "pub_core_threadstate.h"
+#include "pub_core_xarray.h"
 #include "pub_core_clientstate.h"
 #include "pub_core_aspacemgr.h"
 #include "pub_core_debugger.h"      // For VG_(start_debugger)
index 2669cc38a399e77d434feb5f564d50ad8725ef7c..b8c28523b4396696fca75f5149613b15fe6867c0 100644 (file)
@@ -39,6 +39,7 @@
 #include "pub_core_machine.h"
 #include "pub_core_options.h"
 #include "pub_core_stacktrace.h"
+#include "pub_core_xarray.h"
 #include "pub_core_clientstate.h"   // VG_(client__dl_sysinfo_int80)
 #include "pub_core_trampoline.h"
 
index c3a10a08e6e28baebebabe085d45815cadfdbe50..3e4df0e9bc76b76c55151bb2c810ba0f2fb2daab 100644 (file)
@@ -35,6 +35,7 @@
 #include "pub_core_debuginfo.h"     // VG_(di_notify_*)
 #include "pub_core_aspacemgr.h"
 #include "pub_core_transtab.h"      // VG_(discard_translations)
+#include "pub_core_xarray.h"
 #include "pub_core_clientstate.h"   // VG_(brk_base), VG_(brk_limit)
 #include "pub_core_debuglog.h"
 #include "pub_core_errormgr.h"
@@ -2469,14 +2470,15 @@ PRE(sys_execve)
    if (!VG_(clo_trace_children)) {
       argv = (Char**)ARG2;
    } else {
+      vg_assert( VG_(args_for_valgrind) );
       vg_assert( VG_(args_for_valgrind_noexecpass) >= 0 );
       vg_assert( VG_(args_for_valgrind_noexecpass) 
-                   <= VG_(args_for_valgrind).used );
+                   <= VG_(sizeXA)( VG_(args_for_valgrind) ) );
       /* how many args in total will there be? */
       // launcher basename
       tot_args = 1;
       // V's args
-      tot_args += VG_(args_for_valgrind).used;
+      tot_args += VG_(sizeXA)( VG_(args_for_valgrind) );
       tot_args -= VG_(args_for_valgrind_noexecpass);
       // name of client exe
       tot_args++;
@@ -2492,10 +2494,10 @@ PRE(sys_execve)
       // copy
       j = 0;
       argv[j++] = launcher_basename;
-      for (i = 0; i < VG_(args_for_valgrind).used; i++) {
+      for (i = 0; i < VG_(sizeXA)( VG_(args_for_valgrind) ); i++) {
          if (i < VG_(args_for_valgrind_noexecpass))
             continue;
-         argv[j++] = VG_(args_for_valgrind).strs[i];
+         argv[j++] = * (HChar**) VG_(indexXA)( VG_(args_for_valgrind), i );
       }
       argv[j++] = (Char*)ARG1;
       if (arg2copy && arg2copy[0])
index c34ca68f3691e176671dd018c71975a00cd8e1f3..bdf12f017792c84f5c7f0d51449e1495f6575610 100644 (file)
@@ -35,6 +35,7 @@
 #include "pub_core_aspacemgr.h"
 #include "pub_core_debuginfo.h"    // VG_(di_notify_*)
 #include "pub_core_transtab.h"     // VG_(discard_translations)
+#include "pub_core_xarray.h"
 #include "pub_core_clientstate.h"
 #include "pub_core_debuglog.h"
 #include "pub_core_libcbase.h"
index 4c854e6501e6ec2151242661e66df5cec06d84c1..f3f3ce7238afae459590d1459492fe1b03550255 100644 (file)
@@ -32,4 +32,5 @@ incinc_HEADERS = \
        pub_tool_tooliface.h            \
        pub_tool_vki.h                  \
        pub_tool_vkiscnums.h            \
+       pub_tool_xarray.h               \
        valgrind.h
index 64012820ca733864220a1150a5cee75be2a4b6a2..83a830d86cc4a84f4d99b94dea298b288ee630d5 100644 (file)
 #ifndef __PUB_TOOL_CLIENTSTATE_H
 #define __PUB_TOOL_CLIENTSTATE_H
 
+/* Note, this header requires pub_{core,tool}_xarray.h to be
+   included ahead of it. */
 
 // Command line pieces, after they have been extracted from argv in
 // m_main.main().  These are all NULL-terminated vectors.
 
-/* Expandable arrays of strings. */
-typedef
-   struct {
-      Int     size;
-      Int     used;
-      HChar** strs;
-   }
-   XArrayStrings;
-
 /* Args for the client. */
-extern XArrayStrings VG_(args_for_client);
+extern XArray* /* of HChar* */ VG_(args_for_client);
 
 /* Args for V.  This is the concatenation of the following:
    - contents of ~/.valgrindrc
@@ -59,7 +52,7 @@ extern XArrayStrings VG_(args_for_client);
    categories for themselves.  Therefore we also record the number of
    these no-pass-at-execve arguments -- that is what
    VG_(args_for_valgrind_noexecpass) is. */
-extern XArrayStrings VG_(args_for_valgrind);
+extern XArray* /* of HChar* */ VG_(args_for_valgrind);
 
 /* Number of leading args in VG_(args_for_valgrind) not to pass on at
    exec time. */
index 0a3037cbc61e9b4f286cfb667aaf4b64e5cac4fa..dda642f875200f2584010f08997d954c2c5ea73b 100644 (file)
@@ -50,6 +50,7 @@
 #include "pub_tool_replacemalloc.h"
 #include "pub_tool_stacktrace.h"
 #include "pub_tool_tooliface.h"
+#include "pub_tool_xarray.h"
 #include "pub_tool_clientstate.h"
 
 #include "valgrind.h"           // For {MALLOC,FREE}LIKE_BLOCK
@@ -1296,9 +1297,10 @@ static void write_hp_file(void)
    if (VG_(args_the_exename)) {
       SPRINTF(buf, "%s", VG_(args_the_exename));
    }
-   for (i = 0; i < VG_(args_for_client).used; i++) {
-      if (VG_(args_for_client).strs[i])
-         SPRINTF(buf, " %s", VG_(args_for_client).strs[i]);
+   for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
+       HChar* arg = * (HChar**) VG_(indexXA)( VG_(args_for_client), i );
+      if (arg)
+         SPRINTF(buf, " %s", arg);
    }
    SPRINTF(buf, /*" (%d ms/sample)\"\n"*/ "\"\n"
                 "DATE        \"\"\n"
@@ -1619,9 +1621,10 @@ write_text_file(ULong total_ST, ULong heap_ST)
    if (VG_(args_the_exename)) {
       SPRINTF(buf, " %s", VG_(args_the_exename));
    }
-   for (i = 0; i < VG_(args_for_client).used; i++) {
-      if (VG_(args_for_client).strs[i])
-         SPRINTF(buf, " %s", VG_(args_for_client).strs[i]);
+   for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
+      HChar* arg = * (HChar**) VG_(indexXA)( VG_(args_for_client), i );
+      if (arg)
+         SPRINTF(buf, " %s", arg);
    }
    SPRINTF(buf, "\n%s\n", maybe_p);