Moved the stack-walking macros into m_stacktrace.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3732 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/amd64/core_arch.h b/coregrind/amd64/core_arch.h
index c14ad6d..98d65c0 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 ee5f1bf..d95fd75 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 36dd0dc..49d7dfc 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 @@
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 @@
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 dad5515..0f7ddae 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 */