]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Print debugging info at various places in the startup sequence.
authorJulian Seward <jseward@acm.org>
Mon, 25 Apr 2005 02:05:54 +0000 (02:05 +0000)
committerJulian Seward <jseward@acm.org>
Mon, 25 Apr 2005 02:05:54 +0000 (02:05 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3561

coregrind/vg_main.c

index 7e5c7171f676bd6eb1c1aaa1fd70489d2d17a24d..40017db394cc90c13d89692c75d0d1cc75aeea56 100644 (file)
@@ -2404,12 +2404,6 @@ void VG_(sanity_check_general) ( Bool force_expensive )
   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 )
@@ -2493,13 +2487,10 @@ int main(int argc, char **argv, char **envp)
    // 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);
    }
 
    //--------------------------------------------------------------
@@ -2516,6 +2507,7 @@ int main(int argc, char **argv, char **envp)
    // 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);
 
@@ -2529,6 +2521,7 @@ int main(int argc, char **argv, char **envp)
    //   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);
 
    //==============================================================
@@ -2540,6 +2533,7 @@ int main(int argc, char **argv, char **envp)
    // 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 );
 
    //--------------------------------------------------------------
@@ -2547,6 +2541,7 @@ int main(int argc, char **argv, char **envp)
    //   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);
 
    //--------------------------------------------------------------
@@ -2562,6 +2557,7 @@ int main(int argc, char **argv, char **envp)
    //   p: set-libdir  [for VG_(libdir)]
    //   p: load_tool() [for 'preload']
    //--------------------------------------------------------------
+   VG_(debugLog)(1, "main", "Setup client env\n");
    env = fix_environment(envp, preload);
 
    //--------------------------------------------------------------
@@ -2569,18 +2565,20 @@ int main(int argc, char **argv, char **envp)
    //   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
@@ -2591,12 +2589,14 @@ int main(int argc, char **argv, char **envp)
    // 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 );
 
    //==============================================================
@@ -2611,6 +2611,7 @@ int main(int argc, char **argv, char **envp)
    //   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)();
 
@@ -2627,6 +2628,7 @@ int main(int argc, char **argv, char **envp)
    // 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) {
@@ -2652,6 +2654,7 @@ int main(int argc, char **argv, char **envp)
    //   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;
@@ -2683,6 +2686,7 @@ int main(int argc, char **argv, char **envp)
    /* 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
@@ -2696,13 +2700,16 @@ int main(int argc, char **argv, char **envp)
    // 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)();
 
    //--------------------------------------------------------------
@@ -2712,6 +2719,7 @@ int main(int argc, char **argv, char **envp)
    //      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.
@@ -2730,6 +2738,7 @@ int main(int argc, char **argv, char **envp)
    //   p: n/a
    //--------------------------------------------------------------
    // Nb: temporarily parks the saved blocking-mask in saved_sigmask.
+   VG_(debugLog)(1, "main", "Initialise signal management\n");
    VG_(sigstartup_actions)();
 
    //--------------------------------------------------------------
@@ -2753,8 +2762,10 @@ int main(int argc, char **argv, char **envp)
    // 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
@@ -2762,6 +2773,7 @@ int main(int argc, char **argv, char **envp)
    //         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)();
 
    //--------------------------------------------------------------
@@ -2769,6 +2781,7 @@ int main(int argc, char **argv, char **envp)
    //   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)();
 
@@ -2795,6 +2808,7 @@ int main(int argc, char **argv, char **envp)
 
    vg_assert(VG_(master_tid) == 1);
 
+   VG_(debugLog)(1, "main", "Running thread 1\n");
    VGA_(main_thread_wrapper)(1);
 
    abort();