From ebee9c2e2b87def7de434ac2dda9bc916739e4c6 Mon Sep 17 00:00:00 2001 From: mhelmling Date: Fri, 15 Oct 2004 04:37:19 +0000 Subject: [PATCH] check now pop stack result git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3540 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- debugger/mcs51/break.c | 8 +++++++- debugger/mcs51/cmd.c | 6 ++++++ debugger/mcs51/sdcdb.h | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/debugger/mcs51/break.c b/debugger/mcs51/break.c index d71f9bf0..e18cbcff 100644 --- a/debugger/mcs51/break.c +++ b/debugger/mcs51/break.c @@ -462,10 +462,16 @@ BP_CALLBACK(fexitCB) /* pop the top most from the call stack */ func = STACK_POP(callStack); + if (!func) + { + fprintf(stdout,"Stack underflow\n"); + return 1; + } + Dprintf(D_break, ("break: fexitCB: BP_CALLBACK entry %s %p\n",func->sym->name, p_callStack)); /* check main function */ - if ( STACK_EMPTY(callStack)) + if ( STACK_EMPTY(callStack) && !strcmp(func->sym->name,"main")) { fprintf(stdout,"Program exited with code %d.\n",simGetValue (0x82,'I',2)); return 1; diff --git a/debugger/mcs51/cmd.c b/debugger/mcs51/cmd.c index 21309c2e..d8268521 100644 --- a/debugger/mcs51/cmd.c +++ b/debugger/mcs51/cmd.c @@ -707,6 +707,12 @@ void simGo (unsigned int gaddr) userinterrupt = 0; return; } + if ( gaddr == 0 ) + { + function *func = NULL;; + if (applyToSet(functions,funcInAddr,gaddr,&func)) + STACK_PUSH(callStack,func); + } addr = simGoTillBp (gaddr); /* got the pc for the break point now first diff --git a/debugger/mcs51/sdcdb.h b/debugger/mcs51/sdcdb.h index 5b1ce24b..9e1268e2 100644 --- a/debugger/mcs51/sdcdb.h +++ b/debugger/mcs51/sdcdb.h @@ -105,7 +105,7 @@ typedef short bool; : STACK_PUSH_(stack,x) ) #define STACK_POP(stack) (STACK_EMPTY(stack) \ - ?((t_##stack)(long)(STACK_ERR(0))) \ + ?((t_##stack) NULL) \ : STACK_POP_(stack) ) #define STACK_PEEK(stack) (STACK_EMPTY(stack) \ -- 2.47.2