If we panic inside trap(), Do a stack traceback before printing the trap log.

Also change the stack-traceback code to avoid having multiple returns
(and thus multiple stack pops) because with gcc -O2 that breaks the
heuristic that a "jr ra" preceding the PC precedes code to push the
current stack frame.  Which breaks stacktrace() before it even
traces past itself :-(.  Use a goto instead.
This commit is contained in:
jonathan 1995-05-02 19:51:52 +00:00
parent 0c8be3a288
commit be2c7f3d13
3 changed files with 15 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.16 1995/04/29 21:10:31 jonathan Exp $ */
/* $NetBSD: trap.c,v 1.17 1995/05/02 19:51:52 jonathan Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -713,6 +713,7 @@ trap(statusReg, causeReg, vadr, pc, args)
}
#else
#ifdef DEBUG
stacktrace();
trapDump("trap");
#endif
#endif
@ -1732,7 +1733,8 @@ specialframe:
subr = 0;
if (frames++ > 100) {
(*printfn)("\nstackframe count exceeded\n");
return; /*XXX*/
/* return breaks stackframe-size heuristics with gcc -O2 */
goto finish; /*XXX*/
}
/* check for bad SP: could foul up next frame */
@ -1922,6 +1924,7 @@ done:
goto loop;
}
} else {
finish:
if (curproc)
(*printfn)("User-level: pid %d\n", curproc->p_pid);
else

View File

@ -1,4 +1,4 @@
/* $NetBSD: pmax_trap.c,v 1.16 1995/04/29 21:10:31 jonathan Exp $ */
/* $NetBSD: pmax_trap.c,v 1.17 1995/05/02 19:51:52 jonathan Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -713,6 +713,7 @@ trap(statusReg, causeReg, vadr, pc, args)
}
#else
#ifdef DEBUG
stacktrace();
trapDump("trap");
#endif
#endif
@ -1732,7 +1733,8 @@ specialframe:
subr = 0;
if (frames++ > 100) {
(*printfn)("\nstackframe count exceeded\n");
return; /*XXX*/
/* return breaks stackframe-size heuristics with gcc -O2 */
goto finish; /*XXX*/
}
/* check for bad SP: could foul up next frame */
@ -1922,6 +1924,7 @@ done:
goto loop;
}
} else {
finish:
if (curproc)
(*printfn)("User-level: pid %d\n", curproc->p_pid);
else

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.16 1995/04/29 21:10:31 jonathan Exp $ */
/* $NetBSD: trap.c,v 1.17 1995/05/02 19:51:52 jonathan Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -713,6 +713,7 @@ trap(statusReg, causeReg, vadr, pc, args)
}
#else
#ifdef DEBUG
stacktrace();
trapDump("trap");
#endif
#endif
@ -1732,7 +1733,8 @@ specialframe:
subr = 0;
if (frames++ > 100) {
(*printfn)("\nstackframe count exceeded\n");
return; /*XXX*/
/* return breaks stackframe-size heuristics with gcc -O2 */
goto finish; /*XXX*/
}
/* check for bad SP: could foul up next frame */
@ -1922,6 +1924,7 @@ done:
goto loop;
}
} else {
finish:
if (curproc)
(*printfn)("User-level: pid %d\n", curproc->p_pid);
else