]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Moved baseBlock initialisation to after command-line processing, for skins that
authorNicholas Nethercote <njn@valgrind.org>
Mon, 14 Oct 2002 09:25:19 +0000 (09:25 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Mon, 14 Oct 2002 09:25:19 +0000 (09:25 +0000)
don't register helpers until command-line options are seen.  As requested by
Jeremy Fitzhardinge.  Also neatened the code up marginally.

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

coregrind/vg_main.c

index 7b976e4ffc8a4abd8e3f9939a0c356b1c2714913..de238bbf404be3f49e83b8335349f1aff81c3a40 100644 (file)
@@ -319,10 +319,15 @@ static void vg_init_baseBlock ( void )
    assign_helpers_in_baseBlock(VG_(n_noncompact_helpers), 
                                VG_(noncompact_helper_offsets), 
                                VG_(noncompact_helper_addrs));
-}
 
-static void vg_init_shadow_regs ( void )
-{
+
+   /* Initialise slots that require it */
+   VG_(copy_m_state_static_to_baseBlock)();
+
+   /* Pretend the root thread has a completely empty LDT to start with. */
+   VG_(baseBlock)[VGOFF_(ldt)] = (UInt)NULL;
+
+   /* Initialise shadow regs */
    if (VG_(needs).shadow_regs) {
       UInt eflags;
    
@@ -337,8 +342,9 @@ static void vg_init_shadow_regs ( void )
       VG_(baseBlock)[VGOFF_(sh_edi)]    = VG_(written_shadow_reg);
       VG_(baseBlock)[VGOFF_(sh_eflags)] = eflags;
 
-   } else
+   } else {
       VG_(written_shadow_reg) = VG_UNUSED_SHADOW_REG_VALUE;
+   }
 }
 
 
@@ -1212,17 +1218,16 @@ void VG_(main) ( void )
    SK_(pre_clo_init) ( & VG_(details), & VG_(needs), & VG_(track_events) );
    sanity_check_needs();
 
-   /* Set up baseBlock offsets and copy the saved machine's state into it. */
-   vg_init_baseBlock();
-   VG_(copy_m_state_static_to_baseBlock)();
-   /* Pretend that the root thread has a completely empty LDT to start
-      with. */
-   VG_(baseBlock)[VGOFF_(ldt)] = (UInt)NULL;
-   vg_init_shadow_regs();
-
-   /* Process Valgrind's command-line opts (from env var VG_OPTS). */
+   /* Process Valgrind's command-line opts (from env var VG_ARGS). */
    process_cmd_line_options();
 
+   /* Do post command-line processing initialisation */
+   SK_(post_clo_init)();
+
+   /* Set up baseBlock offsets and copy the saved machine's state into it. 
+      Comes after SK_(post_clo_init) in case it registers helpers. */
+   vg_init_baseBlock();
+
    /* Hook to delay things long enough so we can get the pid and
       attach GDB in another shell. */
    if (0) { 
@@ -1247,9 +1252,6 @@ void VG_(main) ( void )
    /* Start calibration of our RDTSC-based clock. */
    VG_(start_rdtsc_calibration)();
 
-   /* Do this here just to give rdtsc calibration more time */
-   SK_(post_clo_init)();
-
    /* Must come after SK_(init) so memory handler accompaniments (eg.
     * shadow memory) can be setup ok */
    VGP_PUSHCC(VgpInitMem);