Slightly disentangle main().
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2433 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/vg_main.c b/coregrind/vg_main.c
index 6b5f701..929220e 100644
--- a/coregrind/vg_main.c
+++ b/coregrind/vg_main.c
@@ -1045,17 +1045,19 @@
cl_esp = VG_(client_end) - stacksize;
cl_esp = ROUNDDN(cl_esp, 16); /* make stack 16 byte aligned */
- if (0)
- printf("stringsize=%d auxsize=%d stacksize=%d\n",
- stringsize, auxsize, stacksize);
-
-
/* base of the string table (aligned) */
stringbase = strtab = (char *)(VG_(client_trampoline_code) - ROUNDUP(stringsize, sizeof(int)));
VG_(clstk_base) = PGROUNDDN(cl_esp);
VG_(clstk_end) = VG_(client_end);
+ if (0)
+ printf("stringsize=%d auxsize=%d stacksize=%d\n"
+ "clstk_base %x\n"
+ "clstk_end %x\n",
+ stringsize, auxsize, stacksize, VG_(clstk_base), VG_(clstk_end));
+
+
/* ==================== allocate space ==================== */
/* allocate a stack - mmap enough space for the stack */
@@ -1185,6 +1187,10 @@
vg_assert((strtab-stringbase) == stringsize);
+ /* We know the initial ESP is pointing at argc/argv */
+ VG_(client_argc) = *(Int*)cl_esp;
+ VG_(client_argv) = (Char**)(cl_esp + sizeof(Int));
+
return cl_esp;
}
@@ -1633,8 +1639,7 @@
}
}
-static void process_cmd_line_options
- ( UInt* client_auxv, Addr esp_at_startup, const char* toolname )
+static void process_cmd_line_options( UInt* client_auxv, const char* toolname )
{
Int i, eventually_log_fd;
Int *auxp;
@@ -1658,10 +1663,6 @@
}
}
- /* We know the initial ESP is pointing at argc/argv */
- VG_(client_argc) = *(Int *)esp_at_startup;
- VG_(client_argv) = (Char **)(esp_at_startup + sizeof(Int));
-
for (i = 1; i < VG_(vg_argc); i++) {
Char* arg = VG_(vg_argv)[i];
@@ -2749,7 +2750,7 @@
env = fix_environment(environ, preload);
//--------------------------------------------------------------
- // Setup client stack and eip
+ // Setup client stack, eip, and VG_(client_arg[cv])
// p: load_client() [for 'info']
// p: fix_environment() [for 'env']
//--------------------------------------------------------------
@@ -2791,6 +2792,7 @@
// XXX: is that necessary, now that we look for V's segments separately?
// XXX: alternatively, if sk_pre_clo_init does use VG_(malloc)(), is it
// wrong to ignore any segments that might add in parse_procselfmaps?
+ // p: setup_client_stack() [for 'VG_(client_arg[cv]']
//--------------------------------------------------------------
(*toolinfo->sk_pre_clo_init)();
VG_(tool_init_dlsym)(tool_dlhandle);
@@ -2811,7 +2813,7 @@
// p: setup_file_descriptors() [for 'VG_(max_fd)']
// p: sk_pre_clo_init [to set 'command_line_options' need]
//--------------------------------------------------------------
- process_cmd_line_options(client_auxv, esp_at_startup, tool);
+ process_cmd_line_options(client_auxv, tool);
//--------------------------------------------------------------
// Allow GDB attach