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
// 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*);
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]);
}
// Record info about lock acquisition for debugging.
lk->cpu = cpu;
- getcallerpcs(&lk, lk->pcs);
+ getcallerpcs(&lk, NELEM(lk->pcs), lk->pcs);
}
// Release the lock.
// 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;
}