From: Florian Krohm Date: Wed, 20 Aug 2014 21:04:14 +0000 (+0000) Subject: Clean up confusion about VG_(args_the_exename) which was believed to X-Git-Tag: svn/VALGRIND_3_10_0~162 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=75e1c18929c7375b4d5abbd9064fc293d247bebc;p=thirdparty%2Fvalgrind.git 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 --- diff --git a/cachegrind/cg_main.c b/cachegrind/cg_main.c index a486997255..4bb465e9e0 100644 --- a/cachegrind/cg_main.c +++ b/cachegrind/cg_main.c @@ -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) { diff --git a/callgrind/dump.c b/callgrind/dump.c index aa1ecb65d5..5cc1d27296 100644 --- a/callgrind/dump.c +++ b/callgrind/dump.c @@ -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 ); diff --git a/coregrind/m_initimg/initimg-darwin.c b/coregrind/m_initimg/initimg-darwin.c index 60f74b95ea..89d858477f 100644 --- a/coregrind/m_initimg/initimg-darwin.c +++ b/coregrind/m_initimg/initimg-darwin.c @@ -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( diff --git a/coregrind/m_initimg/initimg-linux.c b/coregrind/m_initimg/initimg-linux.c index 400fa1bb2c..2d942c16ce 100644 --- a/coregrind/m_initimg/initimg-linux.c +++ b/coregrind/m_initimg/initimg-linux.c @@ -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( diff --git a/coregrind/m_main.c b/coregrind/m_main.c index fc0c8c994b..d0093f1c31 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -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)(" \n"); VG_(printf_xml)(" \n"); - if (VG_(args_the_exename)) - VG_(printf_xml)(" %pS\n", + VG_(printf_xml)(" %pS\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); diff --git a/massif/ms_main.c b/massif/ms_main.c index c594b32385..0770f3dd46 100644 --- a/massif/ms_main.c +++ b/massif/ms_main.c @@ -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");