check now pop stack result
authormhelmling <mhelmling@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 15 Oct 2004 04:37:19 +0000 (04:37 +0000)
committermhelmling <mhelmling@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 15 Oct 2004 04:37:19 +0000 (04:37 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3540 4a8a32a2-be11-0410-ad9d-d568d2c75423

debugger/mcs51/break.c
debugger/mcs51/cmd.c
debugger/mcs51/sdcdb.h

index d71f9bf0667f6efcae69e4a57bfbca8245f5a8b8..e18cbcff081e88db61639d430925d228384f1b0d 100644 (file)
@@ -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;
index 21309c2ea4672e5b44c1a1b0aedc9b132d449855..d8268521be9a10ff9f4d476ad93150bf7563a2ca 100644 (file)
@@ -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
index 5b1ce24b2ee44ffad3c98bcf5dc19e1d688ace58..9e1268e2ab60ece5f5c0061ecc2fd6153832577e 100644 (file)
@@ -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)                 \