add stack underflow detector

This commit is contained in:
Yuichi Nishiwaki 2013-10-30 10:05:21 +09:00
parent a4d20060e7
commit 9bc172bde5
1 changed files with 4 additions and 1 deletions

View File

@ -529,7 +529,7 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv)
puts("**VM END STATE**");
printf("stbase\t= %p\nsp\t= %p\n", pic->stbase, pic->sp);
printf("cibase\t= %p\nci\t= %p\n", pic->cibase, pic->ci);
if (pic->stbase != pic->sp) {
if (pic->stbase < pic->sp) {
pic_value *sp;
printf("* stack trace:");
for (sp = pic->stbase; pic->sp != sp; ++sp) {
@ -537,6 +537,9 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv)
puts("");
}
}
if (pic->stbase > pic->sp) {
puts("*** stack underflow!");
}
#endif
return val;