From: Nicholas Nethercote Date: Wed, 11 May 2005 22:45:48 +0000 (+0000) Subject: Moved Vex's arch/subarch detection out of main() into VG_(translate)()'s X-Git-Tag: svn/VALGRIND_3_0_0~651 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=96329ab01548241329c342a545f5ed87fb161a05;p=thirdparty%2Fvalgrind.git Moved Vex's arch/subarch detection out of main() into VG_(translate)()'s 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 --- diff --git a/coregrind/core.h b/coregrind/core.h index 1fffc18570..e6ad55d213 100644 --- a/coregrind/core.h +++ b/coregrind/core.h @@ -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); diff --git a/coregrind/vg_main.c b/coregrind/vg_main.c index ae87d9d749..41f5fbb231 100644 --- a/coregrind/vg_main.c +++ b/coregrind/vg_main.c @@ -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 diff --git a/coregrind/vg_translate.c b/coregrind/vg_translate.c index a4218bfbab..0fa409ab5e 100644 --- a/coregrind/vg_translate.c +++ b/coregrind/vg_translate.c @@ -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,