From f91c2f24bb4ac6eea46bc9758c16ea108b16108b Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Tue, 23 Nov 2004 00:40:33 +0000 Subject: [PATCH] Get rid of the machinery for registering helper functions. VEX calls them directly. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3077 --- coregrind/core.h | 10 ++-- coregrind/vg_main.c | 122 -------------------------------------- coregrind/x86/core_arch.h | 3 - coregrind/x86/helpers.S | 8 --- 4 files changed, 4 insertions(+), 139 deletions(-) diff --git a/coregrind/core.h b/coregrind/core.h index 18372e7a9..e6e8e0fbf 100644 --- a/coregrind/core.h +++ b/coregrind/core.h @@ -1737,8 +1737,6 @@ extern UInt VG_(patch_me); Exports of vg_helpers.S ------------------------------------------------------------------ */ -extern void VG_(helper_undefined_instruction); - /* Information about trampoline code (for signal return and syscalls) */ extern const Char VG_(trampoline_code_start); extern const Int VG_(trampoline_code_length); @@ -1766,10 +1764,10 @@ extern void VG_(missing_tool_func) ( const Char* fn ); /* An array of words. In generated code, %ebp always points to the start of this array. Useful stuff, like the simulated CPU state, - and the addresses of helper functions, can then be found by - indexing off %ebp. The following declares variables which, at - startup time, are given values denoting offsets into baseBlock. - These offsets are in *words* from the start of baseBlock. */ + can then be found by indexing off %ebp. The following declares + variables which, at startup time, are given values denoting offsets + into baseBlock. These offsets are in *words* from the start of + baseBlock. */ #define VG_BASEBLOCK_WORDS 400 diff --git a/coregrind/vg_main.c b/coregrind/vg_main.c index 3fdac2df3..17f92dfad 100644 --- a/coregrind/vg_main.c +++ b/coregrind/vg_main.c @@ -2164,25 +2164,6 @@ static void setup_file_descriptors(void) /*=== baseBlock: definition + setup ===*/ /*====================================================================*/ -Int VGOFF_(helper_undefined_instruction) = INVALID_OFFSET; - -/* MAX_NONCOMPACT_HELPERS can be increased easily. If MAX_COMPACT_HELPERS is - * increased too much, they won't really be compact any more... */ -#define MAX_COMPACT_HELPERS 8 -#define MAX_NONCOMPACT_HELPERS 50 - -/* 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]; @@ -2217,43 +2198,6 @@ Int VG_(alloc_BaB_1_set) ( Addr a ) return off; } -/* Registers a function in compact_helper_addrs; compact_helper_offsets is - filled in later. */ -void VG_(register_compact_helper)(Addr a) -{ - if (MAX_COMPACT_HELPERS <= VG_(n_compact_helpers)) { - VG_(printf)("Can only register %d compact helpers\n", - MAX_COMPACT_HELPERS); - VG_(core_panic)("Too many compact helpers registered"); - } - VG_(compact_helper_addrs)[VG_(n_compact_helpers)] = a; - VG_(n_compact_helpers)++; -} - -/* Registers a function in noncompact_helper_addrs; noncompact_helper_offsets - * is filled in later. - */ -void VG_(register_noncompact_helper)(Addr a) -{ - if (MAX_NONCOMPACT_HELPERS <= VG_(n_noncompact_helpers)) { - VG_(printf)("Can only register %d non-compact helpers\n", - MAX_NONCOMPACT_HELPERS); - VG_(printf)("Try increasing MAX_NON_COMPACT_HELPERS\n"); - VG_(core_panic)("Too many non-compact helpers registered"); - } - VG_(noncompact_helper_addrs)[VG_(n_noncompact_helpers)] = a; - VG_(n_noncompact_helpers)++; -} - -/* Allocate offsets in baseBlock for the tool helpers */ -static -void assign_helpers_in_baseBlock(UInt n, Int offsets[], Addr addrs[]) -{ - UInt i; - for (i = 0; i < n; i++) - offsets[i] = VG_(alloc_BaB_1_set)( addrs[i] ); -} - Bool VG_(need_to_handle_SP_assignment)(void) { return ( VG_(defined_new_mem_stack_4)() || @@ -2277,73 +2221,7 @@ Bool VG_(need_to_handle_SP_assignment)(void) static void init_baseBlock ( Addr client_eip, Addr sp_at_startup ) { VGA_(init_low_baseBlock)(client_eip, sp_at_startup); - - /* Allocate slots for compact helpers */ - assign_helpers_in_baseBlock(VG_(n_compact_helpers), - VG_(compact_helper_offsets), - VG_(compact_helper_addrs)); - VGA_(init_high_baseBlock)(client_eip, sp_at_startup); - -#define REG(kind, size) \ - if (VG_(defined_##kind##_mem_stack##size)()) \ - VG_(register_noncompact_helper)( \ - (Addr) VG_(tool_interface).track_##kind##_mem_stack##size ); - REG(new, _8); - REG(new, _12); - REG(new, _16); - REG(new, _32); - REG(new, ); - REG(die, _8); - REG(die, _12); - REG(die, _16); - REG(die, _32); - REG(die, ); -#undef REG - - if (VG_(need_to_handle_SP_assignment)()) - VG_(register_noncompact_helper)((Addr) VG_(unknown_SP_update)); - - VGOFF_(helper_undefined_instruction) - = VG_(alloc_BaB_1_set)( (Addr) & VG_(helper_undefined_instruction)); - - /* Allocate slots for noncompact helpers */ - assign_helpers_in_baseBlock(VG_(n_noncompact_helpers), - VG_(noncompact_helper_offsets), - 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_(tool_panic)("Unfound helper"); } diff --git a/coregrind/x86/core_arch.h b/coregrind/x86/core_arch.h index b97823421..dde329cf3 100644 --- a/coregrind/x86/core_arch.h +++ b/coregrind/x86/core_arch.h @@ -108,9 +108,6 @@ extern Int VGOFF_(ldt); /* This thread's TLS pointer. */ extern Int VGOFF_(tls_ptr); -/* Nb: Most helper offsets are in include/tool.h, for use by tools */ -extern Int VGOFF_(helper_undefined_instruction); - /* --------------------------------------------------------------------- Elf stuff diff --git a/coregrind/x86/helpers.S b/coregrind/x86/helpers.S index 3435af476..a8c813c8f 100644 --- a/coregrind/x86/helpers.S +++ b/coregrind/x86/helpers.S @@ -83,14 +83,6 @@ VG_(tramp_syscall_offset): .text - - -/* Undefined instruction (generates SIGILL) */ -.globl VG_(helper_undefined_instruction) -VG_(helper_undefined_instruction): -1: ud2 - jmp 1b - /* Let the linker know we don't need an executable stack */ .section .note.GNU-stack,"",@progbits