build the segment skip-list.
*/
-static int prmap(char *start, char *end, const char *perm, off_t off,
- int maj, int min, int ino, void* dummy) {
- printf("mapping %10p-%10p %s %02x:%02x %d\n",
- start, end, perm, maj, min, ino);
- return True;
-}
/* This may be needed before m_mylibc is OK to run. */
static Int local_strcmp ( const HChar* s1, const HChar* s2 )
// Check we were launched by stage1
// p: none
//--------------------------------------------------------------
+ VG_(debugLog)(1, "main", "Doing scan_auxv()\n");
{
- void* init_sp = argv - 1;
- padfile = scan_auxv(init_sp);
- }
- if (0) {
- printf("========== main() ==========\n");
- foreach_map(prmap, /*dummy*/NULL);
+ void* init_sp = argv - 1;
+ padfile = scan_auxv(init_sp);
}
//--------------------------------------------------------------
// Pre-process the command line.
// p: none
//--------------------------------------------------------------
+ VG_(debugLog)(1, "main", "Preprocess command line opts\n");
get_command_line(argc, argv, &vg_argc, &vg_argv, &cl_argv);
pre_process_cmd_line_options(&need_help, &tool, &exec);
// p: set-libdir [for VG_(libdir)]
// p: pre_process_cmd_line_options() [for 'tool']
//--------------------------------------------------------------
+ VG_(debugLog)(1, "main", "Loading tool\n");
load_tool(tool, &toolinfo, &preload);
//==============================================================
// Finalise address space layout
// p: load_tool() [for 'toolinfo']
//--------------------------------------------------------------
+ VG_(debugLog)(1, "main", "Laying out remaining space\n");
layout_remaining_space( (Addr) & argc, toolinfo->shadow_ratio );
//--------------------------------------------------------------
// p: pre_process_cmd_line_options() [for 'exec', 'need_help']
// p: layout_remaining_space [so there's space]
//--------------------------------------------------------------
+ VG_(debugLog)(1, "main", "Loading client\n");
load_client(cl_argv, exec, need_help, &info, &client_eip);
//--------------------------------------------------------------
// p: set-libdir [for VG_(libdir)]
// p: load_tool() [for 'preload']
//--------------------------------------------------------------
+ VG_(debugLog)(1, "main", "Setup client env\n");
env = fix_environment(envp, preload);
//--------------------------------------------------------------
// p: load_client() [for 'info']
// p: fix_environment() [for 'env']
//--------------------------------------------------------------
+ VG_(debugLog)(1, "main", "Setup client stack\n");
{
- void* init_sp = argv - 1;
+ void* init_sp = argv - 1;
- sp_at_startup = setup_client_stack(init_sp, cl_argv, env, &info,
- &client_auxv);
- free(env);
+ sp_at_startup = setup_client_stack(init_sp, cl_argv, env, &info,
+ &client_auxv);
+ free(env);
}
- if (0)
- printf("entry=%p client esp=%p vg_argc=%d brkbase=%p\n",
- (void*)client_eip, (void*)sp_at_startup, vg_argc,
- (void*)VG_(brk_base));
+ VG_(debugLog)(2, "main",
+ "Client info: "
+ "entry=%p client esp=%p vg_argc=%d brkbase=%p\n",
+ (void*)client_eip, (void*)sp_at_startup, vg_argc,
+ (void*)VG_(brk_base) );
//==============================================================
// Finished setting up operating environment. Now initialise
// setup file descriptors
// p: n/a
//--------------------------------------------------------------
+ VG_(debugLog)(1, "main", "Setup file descriptors\n");
setup_file_descriptors();
//--------------------------------------------------------------
// Build segment map (Valgrind segments only)
// p: tl_pre_clo_init() [to setup new_mem_startup tracker]
//--------------------------------------------------------------
+ VG_(debugLog)(1, "main", "Parse /proc/self/maps (round 1)\n");
VG_(parse_procselfmaps) ( build_valgrind_map_callback );
//==============================================================
// p: parse_procselfmaps [so VG segments are setup so tool can
// call VG_(malloc)]
//--------------------------------------------------------------
+ VG_(debugLog)(1, "main", "Initialise the tool\n");
(*toolinfo->tl_pre_clo_init)();
VG_(sanity_check_needs)();
// Determine CPU architecture and subarchitecture
// p: none
//--------------------------------------------------------------
+ VG_(debugLog)(1, "main", "Check CPU arch/subarch\n");
{ Bool ok = VGA_(getArchAndSubArch)(
& VG_(vex_arch), & VG_(vex_subarch) );
if (!ok) {
// p: setup_client_stack() [for 'sp_at_startup']
// p: init tool [for 'new_mem_startup']
//--------------------------------------------------------------
+ VG_(debugLog)(1, "main", "Parse /proc/self/maps (round 2)\n");
sp_at_startup___global_arg = sp_at_startup;
VG_(parse_procselfmaps) ( build_segment_map_callback ); /* everything */
sp_at_startup___global_arg = 0;
/* Hook to delay things long enough so we can get the pid and
attach GDB in another shell. */
if (VG_(clo_wait_for_gdb)) {
+ VG_(debugLog)(1, "main", "Wait for GDB\n");
VG_(printf)("pid=%d, entering delay loop\n", VG_(getpid)());
/* jrs 20050206: I don't understand why this works on x86. On
amd64 the obvious analogues (jump *$rip or jump *$rcx) don't
// Search for file descriptors that are inherited from our parent
// p: process_cmd_line_options [for VG_(clo_track_fds)]
//--------------------------------------------------------------
- if (VG_(clo_track_fds))
+ if (VG_(clo_track_fds)) {
+ VG_(debugLog)(1, "main", "Init preopened fds\n");
VG_(init_preopened_fds)();
+ }
//--------------------------------------------------------------
// Initialise the scheduler
// p: setup_file_descriptors() [else VG_(safe_fd)() breaks]
//--------------------------------------------------------------
+ VG_(debugLog)(1, "main", "Initialise scheduler\n");
VG_(scheduler_init)();
//--------------------------------------------------------------
// setup_client_stack() [for 'sp_at_startup']
// setup_scheduler() [for the rest of state 1 stuff]
//--------------------------------------------------------------
+ VG_(debugLog)(1, "main", "Initialise thread 1's state\n");
VGA_(init_thread1state)(client_eip, sp_at_startup, &VG_(threads)[1].arch );
// Tell the tool that we just wrote to the registers.
// p: n/a
//--------------------------------------------------------------
// Nb: temporarily parks the saved blocking-mask in saved_sigmask.
+ VG_(debugLog)(1, "main", "Initialise signal management\n");
VG_(sigstartup_actions)();
//--------------------------------------------------------------
// Read suppression file
// p: process_cmd_line_options() [for VG_(clo_suppressions)]
//--------------------------------------------------------------
- if (VG_(needs).core_errors || VG_(needs).tool_errors)
+ if (VG_(needs).core_errors || VG_(needs).tool_errors) {
+ VG_(debugLog)(1, "main", "Load suppressions\n");
VG_(load_suppressions)();
+ }
//--------------------------------------------------------------
// Initialise translation table and translation cache
// aren't identified as part of the client, which would waste
// > 20M of virtual address space.]
//--------------------------------------------------------------
+ VG_(debugLog)(1, "main", "Initialise TT/TC\n");
VG_(init_tt_tc)();
//--------------------------------------------------------------
// p: parse_procselfmaps? [XXX for debug info?]
// p: init_tt_tc [so it can call VG_(search_transtab) safely]
//--------------------------------------------------------------
+ VG_(debugLog)(1, "main", "Initialise redirects\n");
VG_(setup_code_redirect_table)();
VGP_(setup_redirects)();
vg_assert(VG_(master_tid) == 1);
+ VG_(debugLog)(1, "main", "Running thread 1\n");
VGA_(main_thread_wrapper)(1);
abort();