commit 8c59677fe8d560d2a52406294e114dcc0124911f
parent 3121e29fbb5db64ed76b5682d9f99633776de500
Author: Brian Swetland <swetland@frotz.net>
Date: Sun, 5 Jan 2014 12:46:06 -0800
provide getstackpcs() that takes an ebp to start unwinding from
getcallerpcs() uses a void* to the first argument, but on x64 that
doesn't work (arguments passed in registers), so we just use the
actual rbp and unwind from there. But for cases where we want to
unwind somebody else's stack (procdump()), we need a way to handle
that sanely.
Diffstat:
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/include/defs.h b/include/defs.h
@@ -123,6 +123,7 @@ void swtch(struct context**, struct context*);
// spinlock.c
void acquire(struct spinlock*);
void getcallerpcs(void*, uintp*);
+void getstackpcs(uintp*, uintp*);
int holding(struct spinlock*);
void initlock(struct spinlock*, char*);
void release(struct spinlock*);
diff --git a/kernel/spinlock.c b/kernel/spinlock.c
@@ -74,13 +74,19 @@ void
getcallerpcs(void *v, uintp pcs[])
{
uintp *ebp;
- int i;
-
#if X64
asm volatile("mov %%rbp, %0" : "=r" (ebp));
#else
ebp = (uintp*)v - 2;
#endif
+ getstackpcs(ebp, pcs);
+}
+
+void
+getstackpcs(uintp *ebp, uintp pcs[])
+{
+ int i;
+
for(i = 0; i < 10; i++){
if(ebp == 0 || ebp < (uintp*)KERNBASE || ebp == (uintp*)0xffffffff)
break;