]> hydra-www.ietfng.org Git - xv6-public/commitdiff
Make getcallerpcs size parametric
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Sat, 24 Oct 2015 04:34:33 +0000 (00:34 -0400)
committerPeter H. Froehlich <peter.hans.froehlich@gmail.com>
Tue, 3 Nov 2015 22:57:10 +0000 (17:57 -0500)
console.c
defs.h
proc.c
spinlock.c

index ed0b73b3d941e13ceda36ed044af72708dc46875..c2319be7ce4a6af8ceff39218c6879032bfe008b 100644 (file)
--- a/console.c
+++ b/console.c
@@ -113,7 +113,7 @@ panic(char *s)
   cprintf("cpu%d: panic: ", cpu->id);
   cprintf(s);
   cprintf("\n");
-  getcallerpcs(&s, pcs);
+  getcallerpcs(&s, NELEM(pcs), pcs);
   for(i=0; i<10; i++)
     cprintf(" %p", pcs[i]);
   panicked = 1; // freeze other CPU
diff --git a/defs.h b/defs.h
index 8c3568c1dce7f7ca10374f71d71d91764e479e96..b0406dff311b2a89e7ed83b4d8097df1a9d15677 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -127,7 +127,7 @@ void            swtch(struct context**, struct context*);
 
 // spinlock.c
 void            acquire(struct spinlock*);
-void            getcallerpcs(void*, uint*);
+void            getcallerpcs(void*, uint, uint*);
 int             holding(struct spinlock*);
 void            initlock(struct spinlock*, char*);
 void            release(struct spinlock*);
diff --git a/proc.c b/proc.c
index f60d6dd912ffa1efe4322d9587f3989404fe00ab..758ab6d5d3a543bfff9fbeb5ce9c2d4286d35346 100644 (file)
--- a/proc.c
+++ b/proc.c
@@ -456,7 +456,7 @@ procdump(void)
       state = "???";
     cprintf("%d %s %s", p->pid, state, p->name);
     if(p->state == SLEEPING){
-      getcallerpcs((uint*)p->context->ebp+2, pc);
+      getcallerpcs((uint*)p->context->ebp+2, NELEM(pc), pc);
       for(i=0; i<10 && pc[i] != 0; i++)
         cprintf(" %p", pc[i]);
     }
index a16621cb549f2f78c64a4255530f8ad686300e3d..bcb5378dbfb5578e60dbd37538bda490031978f3 100644 (file)
@@ -36,7 +36,7 @@ acquire(struct spinlock *lk)
 
   // Record info about lock acquisition for debugging.
   lk->cpu = cpu;
-  getcallerpcs(&lk, lk->pcs);
+  getcallerpcs(&lk, NELEM(lk->pcs), lk->pcs);
 }
 
 // Release the lock.
@@ -65,19 +65,19 @@ release(struct spinlock *lk)
 
 // Record the current call stack in pcs[] by following the %ebp chain.
 void
-getcallerpcs(void *v, uint pcs[])
+getcallerpcs(void *v, uint n, uint pcs[])
 {
   uint *ebp;
   int i;
   
   ebp = (uint*)v - 2;
-  for(i = 0; i < 10; i++){
+  for(i = 0; i < n; i++){
     if(ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff)
       break;
     pcs[i] = ebp[1];     // saved %eip
     ebp = (uint*)ebp[0]; // saved %ebp
   }
-  for(; i < 10; i++)
+  for(; i < n; i++)
     pcs[i] = 0;
 }