]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Removed 6 global variables from vg_include.h without even having to add
authorNicholas Nethercote <n.nethercote@gmail.com>
Tue, 3 Aug 2004 15:45:46 +0000 (15:45 +0000)
committerNicholas Nethercote <n.nethercote@gmail.com>
Tue, 3 Aug 2004 15:45:46 +0000 (15:45 +0000)
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

coregrind/vg_from_ucode.c
coregrind/vg_include.h
coregrind/vg_main.c

index e64879e278d1872ed0d5cc4e7ebaf31caa46ccd2..988448aca148f2e6b635ca807ee610b8baacd73d 100644 (file)
@@ -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) {
index ea5b7db6b67bdff49e173db4e19e4ba45a150cb7..501a21be64754d633ee0b07d1deead254edeb150 100644 (file)
@@ -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 */
 
 
index f1e7bf000c3f8de85d2ed28993d017c86251b7d8..ed14246afa4f648b096e143c6fb13d6031545379 100644 (file)
@@ -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                                           ===*/