From: Nicholas Nethercote Date: Tue, 3 Aug 2004 15:45:46 +0000 (+0000) Subject: Removed 6 global variables from vg_include.h without even having to add X-Git-Tag: svn/VALGRIND_2_2_0~80 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ac6d31fd77ede364732df408679b6571bbb56944;p=thirdparty%2Fvalgrind.git Removed 6 global variables from vg_include.h without even having to add anything, just by moving VG_(helper_offset)() from vg_from_ucode.c to vg_main.c. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2556 --- diff --git a/coregrind/vg_from_ucode.c b/coregrind/vg_from_ucode.c index e64879e278..988448aca1 100644 --- a/coregrind/vg_from_ucode.c +++ b/coregrind/vg_from_ucode.c @@ -2338,43 +2338,6 @@ void VG_(emit_AMD_prefetch_reg) ( Int reg ) VG_(printf)("\n\t\tamd-prefetch (%s)\n", nameIReg(4,reg) ); } -/*----------------------------------------------------*/ -/*--- Helper offset -> addr translation ---*/ -/*----------------------------------------------------*/ - -/* Finds the baseBlock offset of a tool-specified helper. - * Searches through compacts first, then non-compacts. */ -Int VG_(helper_offset)(Addr a) -{ - UInt i; - Char buf[100]; - - for (i = 0; i < VG_(n_compact_helpers); i++) - if (VG_(compact_helper_addrs)[i] == a) - return VG_(compact_helper_offsets)[i]; - for (i = 0; i < VG_(n_noncompact_helpers); i++) - if (VG_(noncompact_helper_addrs)[i] == a) - return VG_(noncompact_helper_offsets)[i]; - - /* Shouldn't get here */ - VG_(get_fnname) ( a, buf, 100 ); - - VG_(printf)( - "\nCouldn't find offset of helper from its address (%p: %s).\n" - "A helper function probably used hasn't been registered?\n\n", a, buf); - - VG_(printf)(" compact helpers: "); - for (i = 0; i < VG_(n_compact_helpers); i++) - VG_(printf)("%p ", VG_(compact_helper_addrs)[i]); - - VG_(printf)("\n non-compact helpers: "); - for (i = 0; i < VG_(n_noncompact_helpers); i++) - VG_(printf)("%p ", VG_(noncompact_helper_addrs)[i]); - - VG_(printf)("\n"); - VG_(skin_panic)("Unfound helper"); -} - /*----------------------------------------------------*/ /*--- Instruction synthesisers ---*/ /*----------------------------------------------------*/ @@ -2609,7 +2572,8 @@ void VG_(synth_ccall) ( Addr fn, Int argc, Int regparms_n, UInt argv[], } /* Call the function - may trash all flags */ - VG_(synth_call) ( False, VG_(helper_offset) ( fn ), False, FlagsEmpty, FlagsOSZACP ); + VG_(synth_call) ( False, VG_(helper_offset) ( fn ), False, + FlagsEmpty, FlagsOSZACP ); /* Clear any args from stack */ if (0 != stack_used) { diff --git a/coregrind/vg_include.h b/coregrind/vg_include.h index ea5b7db6b6..501a21be64 100644 --- a/coregrind/vg_include.h +++ b/coregrind/vg_include.h @@ -1595,7 +1595,6 @@ extern void VG_(missing_tool_func) ( const Char* fn ); extern UInt VG_(baseBlock)[VG_BASEBLOCK_WORDS]; - /* ----------------------------------------------------- Read-write parts of baseBlock. -------------------------------------------------- */ @@ -1650,20 +1649,6 @@ extern Int VGOFF_(tls); extern Int VGOFF_(helper_undefined_instruction); -/* For storing extension-specific helpers, determined at runtime. The addr - * and offset arrays together form a (addr, offset) map that allows a - * helper's baseBlock offset to be computed from its address. It's done - * like this so CCALL_M_Ns and other helper calls can use the function - * address rather than having to much around with offsets. */ -extern UInt VG_(n_compact_helpers); -extern UInt VG_(n_noncompact_helpers); - -extern Addr VG_(compact_helper_addrs) []; -extern Int VG_(compact_helper_offsets)[]; - -extern Addr VG_(noncompact_helper_addrs) []; -extern Int VG_(noncompact_helper_offsets)[]; - #endif /* ndef __VG_INCLUDE_H */ diff --git a/coregrind/vg_main.c b/coregrind/vg_main.c index f1e7bf000c..ed14246afa 100644 --- a/coregrind/vg_main.c +++ b/coregrind/vg_main.c @@ -2122,13 +2122,17 @@ Int VGOFF_(helper_undefined_instruction) = INVALID_OFFSET; #define MAX_COMPACT_HELPERS 8 #define MAX_NONCOMPACT_HELPERS 50 -UInt VG_(n_compact_helpers) = 0; -UInt VG_(n_noncompact_helpers) = 0; - -Addr VG_(compact_helper_addrs) [MAX_COMPACT_HELPERS]; -Int VG_(compact_helper_offsets)[MAX_COMPACT_HELPERS]; -Addr VG_(noncompact_helper_addrs) [MAX_NONCOMPACT_HELPERS]; -Int VG_(noncompact_helper_offsets)[MAX_NONCOMPACT_HELPERS]; +/* For storing tool-specific helpers, determined at runtime. The addr + * and offset arrays together form a (addr, offset) map that allows a + * helper's baseBlock offset to be computed from its address. It's done + * like this so CCALLs can use the function address rather than having to + * muck around with offsets. */ +static UInt VG_(n_compact_helpers) = 0; +static UInt VG_(n_noncompact_helpers) = 0; +static Addr VG_(compact_helper_addrs) [MAX_COMPACT_HELPERS]; +static Int VG_(compact_helper_offsets)[MAX_COMPACT_HELPERS]; +static Addr VG_(noncompact_helper_addrs) [MAX_NONCOMPACT_HELPERS]; +static Int VG_(noncompact_helper_offsets)[MAX_NONCOMPACT_HELPERS]; /* This is the actual defn of baseblock. */ UInt VG_(baseBlock)[VG_BASEBLOCK_WORDS]; @@ -2409,6 +2413,39 @@ static void init_baseBlock ( Addr client_eip, Addr esp_at_startup ) VG_(noncompact_helper_addrs)); } +// Finds the baseBlock offset of a tool-specified helper. +// Searches through compacts first, then non-compacts. +Int VG_(helper_offset)(Addr a) +{ + UInt i; + Char buf[100]; + + for (i = 0; i < VG_(n_compact_helpers); i++) + if (VG_(compact_helper_addrs)[i] == a) + return VG_(compact_helper_offsets)[i]; + for (i = 0; i < VG_(n_noncompact_helpers); i++) + if (VG_(noncompact_helper_addrs)[i] == a) + return VG_(noncompact_helper_offsets)[i]; + + /* Shouldn't get here */ + VG_(get_fnname) ( a, buf, 100 ); + + VG_(printf)( + "\nCouldn't find offset of helper from its address (%p: %s).\n" + "A helper function probably used hasn't been registered?\n\n", a, buf); + + VG_(printf)(" compact helpers: "); + for (i = 0; i < VG_(n_compact_helpers); i++) + VG_(printf)("%p ", VG_(compact_helper_addrs)[i]); + + VG_(printf)("\n non-compact helpers: "); + for (i = 0; i < VG_(n_noncompact_helpers); i++) + VG_(printf)("%p ", VG_(noncompact_helper_addrs)[i]); + + VG_(printf)("\n"); + VG_(skin_panic)("Unfound helper"); +} + /*====================================================================*/ /*=== Setup pointercheck ===*/