From: Nicholas Nethercote Date: Sat, 11 Sep 2004 15:30:33 +0000 (+0000) Subject: Arch-abstraction: X-Git-Tag: svn/VALGRIND_3_0_0~1589 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7615eab7a2ef4daa1bb397ed8221cb3970d14ab2;p=thirdparty%2Fvalgrind.git Arch-abstraction: - abstract out some inline asm git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2696 --- diff --git a/coregrind/vg_mylibc.c b/coregrind/vg_mylibc.c index ef39f73794..66b57d5e28 100644 --- a/coregrind/vg_mylibc.c +++ b/coregrind/vg_mylibc.c @@ -1091,7 +1091,8 @@ static inline ExeContext *get_real_execontext(Addr ret) Addr esp, ebp; Addr stacktop, sigstack_low, sigstack_high; - asm("movl %%ebp, %0; movl %%esp, %1" : "=r" (ebp), "=r" (esp)); + ARCH_GET_REAL_STACK_PTR(esp); + ARCH_GET_REAL_FRAME_PTR(ebp); stacktop = VG_(valgrind_last); VG_(get_sigstack_bounds)( &sigstack_low, &sigstack_high ); if (esp >= sigstack_low && esp < sigstack_high) diff --git a/coregrind/x86/core_arch.h b/coregrind/x86/core_arch.h index 425ff5b5b4..00e154bad4 100644 --- a/coregrind/x86/core_arch.h +++ b/coregrind/x86/core_arch.h @@ -59,6 +59,16 @@ #define VGOFF_STACK_PTR VGOFF_(m_esp) #define VGOFF_FRAME_PTR VGOFF_(m_ebp) +// Get stack pointer and frame pointer +#define ARCH_GET_REAL_STACK_PTR(esp) do { \ + asm("movl %%esp, %0" : "=r" (esp)); \ +} while (0) + +#define ARCH_GET_REAL_FRAME_PTR(ebp) do { \ + asm("movl %%ebp, %0" : "=r" (ebp)); \ +} while (0) + + /* ----------------------------------------------------- Read-write parts of baseBlock. -------------------------------------------------- */