]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Moved the variable VGOFF_(m_eip) from x86, and moved it (and its
authorNicholas Nethercote <njn@valgrind.org>
Sat, 27 Nov 2004 14:27:21 +0000 (14:27 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Sat, 27 Nov 2004 14:27:21 +0000 (14:27 +0000)
computation) into the generic core, because it's needed by the dispatch
loop of all archs.  Also renamed it VG_(instr_ptr_offset), which is
clearer.  Since it was the last use of the VGOFF_ prefix, I removed that
prefix.

Also cleaned up the ARM stubs slightly, by removing some of the copied,
commented-out x86 code which has since fallen out of date with the real
x86 code and was thus misleading.

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

coregrind/arm/core_arch.h
coregrind/arm/state.c
coregrind/core.h
coregrind/core_asm.h
coregrind/valgrind.vs
coregrind/vg_main.c
coregrind/x86/core_arch.h
coregrind/x86/dispatch.S
coregrind/x86/state.c
include/tool_asm.h

index 4e895741d4e05cc921a7e348146874195ee7cf69..ee0124c4ef9e3cdb1785d2fe8c7440c729ce4cbd 100644 (file)
    I_die_here; \
 } while (0)
 
-#if 0
-// So the dispatch loop can find %EIP
-extern Int VGOFF_(m_eip);
-#endif
-
 /* ---------------------------------------------------------------------
    Elf stuff
    ------------------------------------------------------------------ */
index 5204c9fb0812fbbb0a6ac4d1eab5bc1cbfe7feba..70a34f7e832151de5084af78e2a2acf03b1b0ada 100644 (file)
@@ -38,9 +38,6 @@
 /*--- Initialising the first thread                        ---*/
 /*------------------------------------------------------------*/
 
-Int VGOFF_(m_eip) = INVALID_OFFSET;
-
-
 /* Given a pointer to the ThreadArchState for thread 1 (the root
    thread), initialise the VEX guest state, and copy in essential
    starting values.
@@ -51,49 +48,7 @@ void VGA_(init_thread1state) ( Addr client_eip,
 {
    I_die_here;
 #if 0
-   vg_assert(0 == sizeof(VexGuestX86State) % 8);
-
-   /* Zero out the initial state, and set up the simulated FPU in a
-      sane way. */
-   LibVEX_GuestX86_initialise(&arch->vex);
-
-   /* Zero out the shadow area. */
-   VG_(memset)(&arch->vex_shadow, 0, sizeof(VexGuestX86State));
-
-   /* Put essential stuff into the new state. */
-   /* initialise %cs, %ds and %ss to point at the operating systems
-      default code, data and stack segments */
-   arch->vex.guest_ESP = esp_at_startup;
-   arch->vex.guest_EIP = client_eip;
-
-   asm volatile("movw %%cs, %0"
-                :
-                : "m" (arch->vex.guest_CS));
-   asm volatile("movw %%ds, %0"
-                :
-                : "m" (arch->vex.guest_DS));
-   asm volatile("movw %%ss, %0"
-                :
-                : "m" (arch->vex.guest_SS));
-
-   /* The dispatch loop needs to be able to find %EIP given a pointer
-      to the start of the .vex field. */
-   VGOFF_(m_eip) = offsetof(VexGuestX86State,guest_EIP)/4;
-
-   VG_TRACK( post_reg_write, Vg_CoreStartup, /*tid*/1, /*offset*/0,
-             sizeof(VexGuestArchState));
-
-   /* I assume that if we have SSE2 we also have SSE */
-   VG_(have_ssestate) = False;
-   //      VG_(cpu_has_feature)(VG_X86_FEAT_FXSR) &&
-   //   VG_(cpu_has_feature)(VG_X86_FEAT_SSE);
-
-   if (0) {
-      if (VG_(have_ssestate))
-         VG_(printf)("Looks like a SSE-capable CPU\n");
-      else
-         VG_(printf)("Looks like a MMX-only CPU\n");
-   }
+   // When implementing this, look at x86/state.c
 #endif
 }
 
@@ -111,14 +66,6 @@ void VGA_(clear_thread)( ThreadArchState *arch )
 #endif
 }  
 
-void VGA_(init_thread)( ThreadArchState *arch )
-{
-   I_die_here;
-#if 0
-   VG_(baseBlock)[VGOFF_(tls_ptr)] = (UInt)arch->tls;
-#endif
-}  
-
 void VGA_(cleanup_thread) ( ThreadArchState *arch )
 {  
    I_die_here;
@@ -136,19 +83,7 @@ void VGA_(setup_child) ( ThreadArchState *regs, ThreadArchState *parent_regs )
 {  
    I_die_here;
 #if 0
-   /* We inherit our parent's LDT. */
-   if (parent_regs->ldt == NULL) {
-      /* We hope this is the common case. */
-      VG_(baseBlock)[VGOFF_(ldt)] = 0;
-   } else {
-      /* No luck .. we have to take a copy of the parent's. */
-      regs->ldt = VG_(allocate_LDT_for_thread)( parent_regs->ldt );
-      VG_(baseBlock)[VGOFF_(ldt)] = (UInt) regs->ldt;
-   }
-
-   /* Initialise the thread's TLS array */
-   VG_(clear_TLS_for_thread)( regs->tls );
-   VG_(baseBlock)[VGOFF_(tls_ptr)] = (UInt) regs->tls;
+   // XXX: look at x86/state.c
 #endif
 }  
 
index 4d4dd927dabb76c1db38c85d34980d4fc042f77c..32eb3fd4be1174507a3e5a8acfd1b56eea3cc6f5 100644 (file)
@@ -1239,6 +1239,9 @@ extern void VG_(start_debugger) ( Int tid );
 /* Counts downwards in vg_run_innerloop. */
 extern UInt VG_(dispatch_ctr);
 
+// Instruction pointer guest state offset, used by $VG_ARCH/dispatch.S.
+extern UInt VG_(instr_ptr_offset);
+
 /* --- Counters, for informational purposes only. --- */
 
 // These counters must be declared here because they're maintained by
@@ -1753,7 +1756,7 @@ extern void VG_(missing_tool_func) ( const Char* fn );
 #define PTHREQ_RET(regs)   ((regs).vex.ARCH_PTHREQ_RET)
 #define CLREQ_RET(regs)    ((regs).vex.ARCH_CLREQ_RET)
 
-// Offsets for the shadow state
+// Offsets for the Vex state
 #define O_STACK_PTR        (offsetof(VexGuestArchState, ARCH_STACK_PTR))
 #define O_FRAME_PTR        (offsetof(VexGuestArchState, ARCH_FRAME_PTR))
 
index 46190c2ce5ff64b076a175b2b0e10456679301ae..ae11313970bc71e968b1539f1afc204271fe7489 100644 (file)
 #define VG_TRC_INNER_COUNTERZERO  29 /* TRC only; means bb ctr == 0 */
 #define VG_TRC_UNRESUMABLE_SIGNAL 37 /* TRC only; got sigsegv/sigbus */
 
-
 /* Constants for the fast translation lookup cache. */
 #define VG_TT_FAST_BITS 15
 #define VG_TT_FAST_SIZE (1 << VG_TT_FAST_BITS)
 #define VG_TT_FAST_MASK ((VG_TT_FAST_SIZE) - 1)
 
-/* Constants for the fast original-code-write check cache. */
-
-
 /* Assembly code stubs make this request */
 #define VG_USERREQ__SIGNAL_RETURNS          0x4001
 
index e8233ea3b33540c2f5aac59fcb3df2402a952c68..c93f6dbdbd19b6628f080f832f298f1d5912eb57 100644 (file)
@@ -3,7 +3,6 @@ VALGRIND_2.1 {
                vgPlain_*;
                vgTool_*;
                vgProf_*;
-                vgOff_*;
                 vgArch_*;
                *IROp*;
                *IRExpr*;
index 0930f2c41d451f0b7c75f9693bc2df897a0dfddb..681058e79aa4f358af6230ad7c888131d1e89974 100644 (file)
@@ -142,6 +142,9 @@ Int    VG_(client_argc);
 Char** VG_(client_argv);
 Char** VG_(client_envp);
 
+// Instruction pointer guest state offset, used by $VG_ARCH/dispatch.S.
+UInt VG_(instr_ptr_offset);
+
 /* ---------------------------------------------------------------------
    Running stuff                            
    ------------------------------------------------------------------ */
@@ -2617,6 +2620,7 @@ int main(int argc, char **argv)
    //      setup_scheduler()      [for the rest of state 1 stuff]
    //--------------------------------------------------------------
    VGA_(init_thread1state)(client_eip, sp_at_startup, &VG_(threads)[1].arch );
+   VG_(instr_ptr_offset) = offsetof(VexGuestArchState, ARCH_INSTR_PTR);
 
    //--------------------------------------------------------------
    // Set up the ProxyLWP machinery
index 06af902869cf78dd13f8a9ca5400fff8d262b171..064123fdd79fa8587f0e779ea93f105a3ff2d809 100644 (file)
@@ -69,7 +69,7 @@
 } while (0)
 
 // So the dispatch loop can find %EIP
-extern Int VGOFF_(m_eip);
+extern Int vgoff_m_eip;
 
 
 /* ---------------------------------------------------------------------
index 62799427737e02ec0a7a274202cb5a81f559efc4..fb72d13899f752cddb276f257e08c910d2e894e4 100644 (file)
@@ -85,15 +85,15 @@ VG_(run_innerloop):
        movl    28(%esp), %ebp
        
        /* fetch m_eip into %eax */
-       movl    VGOFF_(m_eip), %esi
-       movl    (%ebp, %esi, 4), %eax
+       movl    VG_(instr_ptr_offset), %esi
+       movl    (%ebp, %esi, 1), %eax
        
        /* fall into main loop */
 
 dispatch_boring:
        /* save the jump address in the guest state */
-       movl    VGOFF_(m_eip), %esi
-       movl    %eax, (%ebp, %esi, 4)
+       movl    VG_(instr_ptr_offset), %esi
+       movl    %eax, (%ebp, %esi, 1)
 
        /* Are we out of timeslice?  If yes, defer to scheduler. */
        subl $1, VG_(dispatch_ctr)
@@ -160,9 +160,9 @@ dispatch_exceptional:
        jz      counter_is_zero
 
        /* save %eax in %EIP and defer to sched */
-       movl    VGOFF_(m_eip), %esi
+       movl    VG_(instr_ptr_offset), %esi
        movl    28(%esp), %edi
-       movl    %eax, (%edi, %esi, 4)
+       movl    %eax, (%edi, %esi, 1)
        movl    %ebp, %eax
        jmp     run_innerloop_exit
 
index 1525dda3b783eb10798db2e0e7e5153a2eef30f2..0454a505f05afd119a703cbfcb4ece2abb7d1d74 100644 (file)
@@ -38,9 +38,6 @@
 /*--- Initialising the first thread                        ---*/
 /*------------------------------------------------------------*/
 
-Int VGOFF_(m_eip) = INVALID_OFFSET;
-
-
 /* Given a pointer to the ThreadArchState for thread 1 (the root
    thread), initialise the VEX guest state, and copy in essential
    starting values.
@@ -74,10 +71,6 @@ void VGA_(init_thread1state) ( Addr client_eip,
                 :
                 : "m" (arch->vex.guest_SS));
 
-   /* The dispatch loop needs to be able to find %EIP given a pointer
-      to the start of the .vex field. */
-   VGOFF_(m_eip) = offsetof(VexGuestX86State,guest_EIP)/4;
-
    VG_TRACK( post_reg_write, Vg_CoreStartup, /*tid*/1, /*offset*/0,
              sizeof(VexGuestArchState));
 
@@ -253,3 +246,4 @@ Int VGA_(ptrace_setregs_from_tst)(Int pid, ThreadArchState* arch)
 /*--------------------------------------------------------------------*/
 /*--- end                                                          ---*/
 /*--------------------------------------------------------------------*/
+
index db36a85324d13722872d747f3479d55677bf3d2b..9bd21cb28a03df080a6f96775d02d1cbffd40870 100644 (file)
@@ -42,7 +42,6 @@
    name can safely be used across different macros. */
 #define VG_(str)    VGAPPEND(vgPlain_,str)
 #define VGP_(str)   VGAPPEND(vgProf_,str)
-#define VGOFF_(str) VGAPPEND(vgOff_,str)
 #define VGA_(str)   VGAPPEND(vgArch_,str)
 
 /* Tool-specific ones.  Note that final name still starts with "vg". */