]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Arch-abstraction:
authorNicholas Nethercote <n.nethercote@gmail.com>
Mon, 13 Sep 2004 16:11:09 +0000 (16:11 +0000)
committerNicholas Nethercote <n.nethercote@gmail.com>
Mon, 13 Sep 2004 16:11:09 +0000 (16:11 +0000)
- abstract out all the SET_THREAD_REG macros

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

coregrind/core.h
coregrind/x86-linux/core_platform.h
coregrind/x86/core_arch.h
coregrind/x86/signal.c

index 91662a21f4e6a39f9d2fbbb35a98db6b5b0be341..6b001128a2e57bcbfaeef99123c9fe98bf0b734e 100644 (file)
@@ -926,29 +926,29 @@ extern void VG_(scheduler_handle_fatal_signal)( Int sigNo );
    doesn't really need to be set at compile time. */
 #define VG_AR_CLIENT_STACKBASE_REDZONE_SZB   16
 
-/* Write a value to a client's thread register, and shadow (if necessary) */
-#define SET_THREAD_REG( zztid, zzval, zzreg, zzREG, zzevent, zzargs... ) \
-   do { VG_(threads)[zztid].arch.m_##zzreg = (zzval);             \
-        VG_TRACK( zzevent, zztid, R_##zzREG, ##zzargs );          \
+// Write a value to a client's thread register, and shadow (if necessary).
+// Note that there are some further similar macros in the arch- and
+// platform-specific parts;  these ones are the totally generic ones.
+#define SET_THREAD_REG( zztid, zzval, zzGETREG, zzREG, zzevent, zzargs... ) \
+   do { zzGETREG(VG_(threads)[zztid].arch) = (zzval);         \
+        VG_TRACK( zzevent, zztid, zzREG, ##zzargs );          \
    } while (0)
 
-#define SET_SYSCALL_RETVAL(zztid, zzval) \
-   SET_THREAD_REG(zztid, zzval, eax, EAX, post_reg_write_syscall_return)
-
-#define SET_SIGNAL_ESP(zztid, zzval) \
-   SET_THREAD_REG(zztid, zzval, esp, ESP, post_reg_write_deliver_signal)
-
 #define SET_CLREQ_RETVAL(zztid, zzval) \
-   SET_THREAD_REG(zztid, zzval, edx, EDX, post_reg_write_clientreq_return)
+   SET_THREAD_REG(zztid, zzval, ARCH_CLREQ_RET, R_CLREQ_RET, \
+                  post_reg_write_clientreq_return)
 
 #define SET_CLCALL_RETVAL(zztid, zzval, f) \
-   SET_THREAD_REG(zztid, zzval, edx, EDX, post_reg_write_clientcall_return, f)
+   SET_THREAD_REG(zztid, zzval, ARCH_CLREQ_RET, R_CLREQ_RET, \
+                  post_reg_write_clientcall_return, f)
 
 #define SET_PTHREQ_ESP(zztid, zzval) \
-   SET_THREAD_REG(zztid, zzval, esp, ESP, post_reg_write_pthread_return)
+   SET_THREAD_REG(zztid, zzval, ARCH_STACK_PTR, R_STACK_PTR, \
+                  post_reg_write_pthread_return)
 
 #define SET_PTHREQ_RETVAL(zztid, zzval) \
-   SET_THREAD_REG(zztid, zzval, edx, EDX, post_reg_write_pthread_return)
+   SET_THREAD_REG(zztid, zzval, ARCH_PTHREQ_RET, R_PTHREQ_RET, \
+                  post_reg_write_pthread_return)
 
 
 /* ---------------------------------------------------------------------
@@ -985,7 +985,7 @@ extern void VG_(do_pthread_sigmask_SCSS_upd) ( ThreadId tid, Int how,
 
 /* Modify the current thread's state once we have detected it is
    returning from a signal handler. */
-extern Bool VG_(signal_returns) ( ThreadId );
+extern Bool VG_(signal_returns) ( ThreadId tid );
 
 /* Handy utilities to block/restore all host signals. */
 extern void VG_(block_all_host_signals) 
index 3dafc7805def4f1b469b243255e81e00f72f9e98..c7bb37a3e038e3614cdfacf721b59c16e71ee905 100644 (file)
 #define R_SYSCALL_ARG1                 R_EBX
 #define R_SYSCALL_RET                  R_EAX
 
+// Setting thread regs and shadow regs from within the core
+#define SET_SYSCALL_RETVAL(zztid, zzval) \
+   SET_THREAD_REG(zztid, zzval, PLATFORM_SYSCALL_RET, R_SYSCALL_RET, \
+                  post_reg_write_syscall_return)
+
 #endif   // __X86_LINUX_CORE_PLATFORM_H
 
 /*--------------------------------------------------------------------*/
index 00e154bad486d454c34dfdf461beef7600a93806..ed3cf7baebd9603b4a1e9891688cd3919c399993 100644 (file)
 #define ARCH_FRAME_PTR(regs)           ((regs).m_ebp)
 
 #define ARCH_CLREQ_ARGS(regs)          ((regs).m_eax)
+#define ARCH_PTHREQ_RET(regs)          ((regs).m_edx)
+#define ARCH_CLREQ_RET(regs)           ((regs).m_edx)
 
-// Interesting register numbers
+// Accessors for the baseBlock
 #define R_STACK_PTR                    R_ESP
 #define R_FRAME_PTR                    R_EBP
 
+#define R_CLREQ_RET                    R_EDX
+#define R_PTHREQ_RET                   R_EDX
+
 // Stack frame layout and linkage
 #define FIRST_STACK_FRAME(ebp)         (ebp)
 #define STACK_FRAME_RET(ebp)           (((UInt*)ebp)[1])
index da1f8b7f7dacb7f18b217ccbd5a098ba4cbd6a39..4a90714d8e6eebed8cbec19f7194ba47e909edda 100644 (file)
@@ -160,6 +160,10 @@ static void synth_ucontext(ThreadId tid, const vki_ksiginfo_t *si,
    sc->cr2 = (UInt)si->_sifields._sigfault._addr;
 }
 
+#define SET_SIGNAL_ESP(zztid, zzval) \
+   SET_THREAD_REG(zztid, zzval, ARCH_STACK_PTR, R_STACK_PTR, \
+                  post_reg_write_deliver_signal)
+
 void VGA_(push_signal_frame)(ThreadId tid, Addr esp_top_of_frame,
                              const vki_ksiginfo_t *siginfo,
                              void *handler, UInt flags,