]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Moved Vex's arch/subarch detection out of main() into VG_(translate)()'s
authorNicholas Nethercote <njn@valgrind.org>
Wed, 11 May 2005 22:45:48 +0000 (22:45 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Wed, 11 May 2005 22:45:48 +0000 (22:45 +0000)
init routine.  This meant that VG_(vex_arch) and VG_(vex_subarch) could be
made local to VG_(translate)().

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

coregrind/core.h
coregrind/vg_main.c
coregrind/vg_translate.c

index 1fffc18570ab62f2a69cd13758130d0482c3ec21..e6ad55d213759cad05eaa7c5d951056973aa1c3e 100644 (file)
@@ -776,10 +776,6 @@ extern UInt VG_(dispatch_ctr);
 /* Stats ... */
 extern void VG_(print_scheduler_stats) ( void );
 
-/* Indicates what arch and subarch we are running on. */
-extern VexArch    VG_(vex_arch);
-extern VexSubArch VG_(vex_subarch);
-
 /* 64-bit counter for the number of basic blocks done. */
 extern ULong VG_(bbs_done);
 
index ae87d9d749ee2a296ed8c88303b09b6247b01e97..41f5fbb23116bd4e12d2a11b47ef71f1c886ddaa 100644 (file)
@@ -153,10 +153,6 @@ Int    VG_(client_argc);
 Char** VG_(client_argv);
 Char** VG_(client_envp);
 
-/* Indicates what arch and subarch we are running on. */
-VexArch    VG_(vex_arch)    = VexArch_INVALID;
-VexSubArch VG_(vex_subarch) = VexSubArch_INVALID;
-
 
 /* ---------------------------------------------------------------------
    Running stuff                            
@@ -2626,30 +2622,6 @@ int main(int argc, char **argv, char **envp)
 
    VG_TDICT_CALL(tool_post_clo_init);
 
-   //--------------------------------------------------------------
-   // 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) {
-         VG_(printf)("\n");
-         VG_(printf)("valgrind: fatal error: unsupported CPU.\n");
-         VG_(printf)("   Supported CPUs are:\n");
-         VG_(printf)("   * x86 with SSE state (Pentium II or above, "
-                     "AMD Athlon or above)\n");
-         VG_(printf)("\n");
-         VG_(exit)(1);
-      }
-      if (VG_(clo_verbosity) > 2) {
-         VG_(message)(Vg_DebugMsg, 
-                      "Host CPU: arch = %s, subarch = %s",
-                      LibVEX_ppVexArch( VG_(vex_arch) ),
-                      LibVEX_ppVexSubArch( VG_(vex_subarch) ) );
-      }
-   }
-
    //--------------------------------------------------------------
    // Build segment map (all segments)
    //   p: shadow/redzone segments
index a4218bfbabb665579e179d00d36ae2662b4d5317..0fa409ab5eafc1f64696245df7d985a7f6eb6953 100644 (file)
@@ -342,7 +342,6 @@ static Bool need_to_handle_SP_assignment(void)
             VG_(tdict).track_die_mem_stack    );
 }
 
-
 Bool VG_(translate) ( ThreadId tid, 
                       Addr64   orig_addr,
                       Bool     debugging_translation,
@@ -355,11 +354,32 @@ Bool VG_(translate) ( ThreadId tid,
    Segment*  seg;
    VexGuestExtents vge;
 
+   /* Indicates what arch and subarch we are running on. */
+   static VexArch    vex_arch    = VexArch_INVALID;
+   static VexSubArch vex_subarch = VexSubArch_INVALID;
+
    /* Make sure Vex is initialised right. */
    VexTranslateResult tres;
    static Bool vex_init_done = False;
 
    if (!vex_init_done) {
+      Bool ok = VGA_(getArchAndSubArch)( &vex_arch, &vex_subarch );
+      if (!ok) {
+         VG_(printf)("\n");
+         VG_(printf)("valgrind: fatal error: unsupported CPU.\n");
+         VG_(printf)("   Supported CPUs are:\n");
+         VG_(printf)("   * x86 with SSE state (Pentium II or above, "
+                     "AMD Athlon or above)\n");
+         VG_(printf)("\n");
+         VG_(exit)(1);
+      }
+      if (VG_(clo_verbosity) > 2) {
+         VG_(message)(Vg_DebugMsg, 
+                      "Host CPU: arch = %s, subarch = %s",
+                      LibVEX_ppVexArch   ( vex_arch ),
+                      LibVEX_ppVexSubArch( vex_subarch ) );
+      }
+
       LibVEX_Init ( &failure_exit, &log_bytes, 
                     1,     /* debug_paranoia */ 
                     False, /* valgrind support */
@@ -446,8 +466,8 @@ Bool VG_(translate) ( ThreadId tid,
    tl_assert2(VG_(tdict).tool_instrument,
               "you forgot to set VgToolInterface function 'tool_instrument'");
    tres = LibVEX_Translate ( 
-             VG_(vex_arch), VG_(vex_subarch),
-             VG_(vex_arch), VG_(vex_subarch),
+             vex_arch, vex_subarch,
+             vex_arch, vex_subarch,
              (UChar*)ULong_to_Ptr(orig_addr), 
              (Addr64)orig_addr, 
              chase_into_ok,