|
From: Nicholas N. <nj...@ca...> - 2004-09-13 16:11:42
|
CVS commit by nethercote:
Arch-abstraction:
- abstract out all the SET_THREAD_REG macros
M +15 -15 core.h 1.30
M +6 -1 x86/core_arch.h 1.8
M +4 -0 x86/signal.c 1.2
M +5 -0 x86-linux/core_platform.h 1.2
--- valgrind/coregrind/core.h #1.29:1.30
@@ -927,27 +927,27 @@ extern void VG_(scheduler_handle_fatal_s
#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)
@@ -986,5 +986,5 @@ extern void VG_(do_pthread_sigmask_SCSS_
/* 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. */
--- valgrind/coregrind/x86/core_arch.h #1.7:1.8
@@ -45,9 +45,14 @@
#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)
--- valgrind/coregrind/x86/signal.c #1.1:1.2
@@ -161,4 +161,8 @@ static void synth_ucontext(ThreadId tid,
}
+#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,
--- valgrind/coregrind/x86-linux/core_platform.h #1.1:1.2
@@ -57,4 +57,9 @@
#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
|