From: Nicholas Nethercote Date: Mon, 16 May 2005 00:16:56 +0000 (+0000) Subject: Moved the stack-walking macros into m_stacktrace. X-Git-Tag: svn/VALGRIND_3_0_0~586 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1365301e393cf32ca27944e300035b8b2ed589a6;p=thirdparty%2Fvalgrind.git Moved the stack-walking macros into m_stacktrace. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3732 --- diff --git a/coregrind/amd64/core_arch.h b/coregrind/amd64/core_arch.h index c14ad6d6ed..98d65c0a92 100644 --- a/coregrind/amd64/core_arch.h +++ b/coregrind/amd64/core_arch.h @@ -56,11 +56,6 @@ #define VGA_CLREQ_ARGS guest_RAX #define VGA_CLREQ_RET guest_RDX -// Stack frame layout and linkage -#define VGA_FIRST_STACK_FRAME(rbp) (rbp) -#define VGA_STACK_FRAME_RET(rbp) (((UWord*)rbp)[1]) -#define VGA_STACK_FRAME_NEXT(rbp) (((UWord*)rbp)[0]) - /* --------------------------------------------------------------------- Architecture-specific part of a ThreadState ------------------------------------------------------------------ */ diff --git a/coregrind/arm/core_arch.h b/coregrind/arm/core_arch.h index ee5f1bf4d0..d95fd755d8 100644 --- a/coregrind/arm/core_arch.h +++ b/coregrind/arm/core_arch.h @@ -62,12 +62,6 @@ #define VGA_CLREQ_ARGS guest_R0 #define VGA_CLREQ_RET guest_R0 -// Stack frame layout and linkage -// XXX ToDo: ??? -#define VGA_FIRST_STACK_FRAME(ebp) (ebp) -#define VGA_STACK_FRAME_RET(ebp) (((UInt*)ebp)[1]) -#define VGA_STACK_FRAME_NEXT(ebp) (((UInt*)ebp)[0]) - // Get stack pointer and frame pointer #define VGA_GET_REAL_STACK_PTR(esp) do { \ I_die_here; \ diff --git a/coregrind/m_stacktrace.c b/coregrind/m_stacktrace.c index 36dd0dc703..49d7dfcd43 100644 --- a/coregrind/m_stacktrace.c +++ b/coregrind/m_stacktrace.c @@ -35,6 +35,19 @@ /*--- Exported functions. ---*/ /*------------------------------------------------------------*/ +// Stack frame layout and linkage +#if defined(VGA_x86) +# define FIRST_STACK_FRAME(ebp) (ebp) +# define STACK_FRAME_RET(ebp) (((UWord*)ebp)[1]) +# define STACK_FRAME_NEXT(ebp) (((UWord*)ebp)[0]) +#elif defined(VGA_amd64) +# define FIRST_STACK_FRAME(rbp) (rbp) +# define STACK_FRAME_RET(rbp) (((UWord*)rbp)[1]) +# define STACK_FRAME_NEXT(rbp) (((UWord*)rbp)[0]) +#else +# error Unknown platform +#endif + /* Take a snapshot of the client's stack, putting the up to 'n_ips' IPs into 'ips'. In order to be thread-safe, we pass in the thread's IP and FP. Returns number of IPs put in 'ips'. */ @@ -82,6 +95,10 @@ UInt VG_(get_StackTrace2) ( Addr* ips, UInt n_ips, user-space threads package work. JRS 20021001 */ } else { + // XXX: I think this line is needed for PPC to work, but I'm not + // certain, so I'm commenting it out for the moment. + //fp = FIRST_STACK_FRAME(fp) + while (True) { if (i >= n_ips) @@ -110,10 +127,10 @@ UInt VG_(get_StackTrace2) ( Addr* ips, UInt n_ips, then use this as a fallback. */ if (fp_min <= fp && fp <= fp_max) { /* fp looks sane, so use it. */ - ip = VGA_STACK_FRAME_RET(fp); + ip = STACK_FRAME_RET(fp); sp = fp + sizeof(Addr) /*saved %ebp/%rbp*/ + sizeof(Addr) /*ra*/; - fp = VGA_STACK_FRAME_NEXT(fp); + fp = STACK_FRAME_NEXT(fp); ips[i++] = ip; if (debug) VG_(printf)(" ipsF[%d]=%08p\n", i-1, ips[i-1]); diff --git a/coregrind/x86/core_arch.h b/coregrind/x86/core_arch.h index dad5515bb0..0f7ddae314 100644 --- a/coregrind/x86/core_arch.h +++ b/coregrind/x86/core_arch.h @@ -56,11 +56,6 @@ #define VGA_CLREQ_ARGS guest_EAX #define VGA_CLREQ_RET guest_EDX -// Stack frame layout and linkage -#define VGA_FIRST_STACK_FRAME(ebp) (ebp) -#define VGA_STACK_FRAME_RET(ebp) (((UInt*)ebp)[1]) -#define VGA_STACK_FRAME_NEXT(ebp) (((UInt*)ebp)[0]) - //extern const Char VG_(helper_wrapper_before)[]; /* in dispatch.S */ //extern const Char VG_(helper_wrapper_return)[]; /* in dispatch.S */