Martins changes for ddd
authorkbongers <kbongers@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 6 May 2003 20:52:46 +0000 (20:52 +0000)
committerkbongers <kbongers@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 6 May 2003 20:52:46 +0000 (20:52 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2597 4a8a32a2-be11-0410-ad9d-d568d2c75423

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

index 44d412d4b569c96a6fad54f55fe8e03f5ab12927..5e22f58f33395d02efcb1b9d7e54bf505eb40165 100644 (file)
@@ -295,6 +295,7 @@ int dispatchCB (unsigned addr, context *ctxt)
     if ((bp = hTabFirstItemWK(bptable,addr)) == NULL) {
       if ( doingSteps == 2 ) return 1;
       if ( doingSteps ) return 0;
+      if ( contsim    ) return 0;
       return simStopBPCB(addr);
     }
 
index 237c4a2a016f4745d4dee98850d84712f1655ba4..ff1346cb5bd1ea7aae315248b88155d5cc8a7195 100644 (file)
@@ -1262,77 +1262,77 @@ int cmdStep (char *s, context *cctxt)
     function *func = NULL;
 
     if (!cctxt || !cctxt->func || !cctxt->func->mod) 
-       fprintf(stdout,"The program is not being run.\n");
+        fprintf(stdout,"The program is not being run.\n");
     else {
-       /* if we are @ the end of a function then set
-          break points at execution points of the
-          function in the call stack... */
-       if (cctxt->addr == cctxt->func->sym->eaddr) {
-           if ((func = STACK_PEEK(callStack))) {
-               if (srcMode == SRC_CMODE)
-                   applyToSet (func->cfpoints,setStepEPBp,STEP,
-                               func->mod->c_name);     
-               else
-                   applyToSet (func->afpoints,setStepEPBp,STEP,
-                               func->mod->asm_name);
-           }
-       } else {
-           /* set breakpoints at all function entry points
-              and all exepoints of this functions & for
-              all functions one up in the call stack */
+        /* if we are @ the end of a function then set
+           break points at execution points of the
+           function in the call stack... */
+        if (cctxt->addr == cctxt->func->sym->eaddr) {
+            if ((func = STACK_PEEK(callStack))) {
+                if (srcMode == SRC_CMODE)
+                    applyToSet (func->cfpoints,setStepEPBp,STEP,
+                                func->mod->c_name);    
+                else
+                    applyToSet (func->afpoints,setStepEPBp,STEP,
+                                func->mod->asm_name);
+            }
+        } else {
+            /* set breakpoints at all function entry points
+               and all exepoints of this functions & for
+               all functions one up in the call stack */
            
-           /* all function entry points */
-           applyToSet(functions,setStepBp); 
+            /* all function entry points */
+            applyToSet(functions,setStepBp); 
            
-           if (srcMode == SRC_CMODE) {
-               /* for all execution points in this function */
-               applyToSet(cctxt->func->cfpoints,setStepEPBp,STEP,
-                          cctxt->func->mod->c_name);
+            if (srcMode == SRC_CMODE) {
+                /* for all execution points in this function */
+                applyToSet(cctxt->func->cfpoints,setStepEPBp,STEP,
+                           cctxt->func->mod->c_name);
                
-               /* set a break point @ the current function's
-                  exit */
-               setBreakPoint (cctxt->func->sym->eaddr, CODE, STEP , 
-                              stepBpCB, cctxt->func->mod->c_name, 
-                              cctxt->func->exitline);
+                /* set a break point @ the current function's
+                   exit */
+                setBreakPoint (cctxt->func->sym->eaddr, CODE, STEP , 
+                               stepBpCB, cctxt->func->mod->c_name, 
+                               cctxt->func->exitline);
                
-               /* now break point @ callers execution points */
-               if ((func = STACK_PPEEK(callStack))) {
-                   applyToSet (func->cfpoints,setStepEPBp,STEP,
-                               func->mod->c_name);     
-                   /* set bp @ callers exit point */
-                   setBreakPoint (func->sym->eaddr, CODE, STEP , 
-                                  stepBpCB, func->mod->c_name, 
-                                  func->exitline);
-               }
-           } else {
-               /* for all execution points in this function */
-               applyToSet(cctxt->func->afpoints,setStepEPBp,STEP,
-                          cctxt->func->mod->asm_name);
+                /* now break point @ callers execution points */
+                if ((func = STACK_PPEEK(callStack))) {
+                    applyToSet (func->cfpoints,setStepEPBp,STEP,
+                                func->mod->c_name);    
+                    /* set bp @ callers exit point */
+                    setBreakPoint (func->sym->eaddr, CODE, STEP , 
+                                   stepBpCB, func->mod->c_name, 
+                                   func->exitline);
+                }
+            } else {
+                /* for all execution points in this function */
+                applyToSet(cctxt->func->afpoints,setStepEPBp,STEP,
+                           cctxt->func->mod->asm_name);
                
-               /* set a break point @ the current function's
-                  exit */
-               setBreakPoint (cctxt->func->sym->eaddr, CODE, STEP , 
-                              stepBpCB, cctxt->func->mod->asm_name, 
-                              cctxt->func->aexitline);
+                /* set a break point @ the current function's
+                   exit */
+                setBreakPoint (cctxt->func->sym->eaddr, CODE, STEP , 
+                               stepBpCB, cctxt->func->mod->asm_name, 
+                               cctxt->func->aexitline);
                
-               /* now break point @ callers execution points */
-               if ((func = STACK_PPEEK(callStack))) {
+                /* now break point @ callers execution points */
+                if ((func = STACK_PPEEK(callStack))) {
                    
-                   applyToSet (func->afpoints,setStepEPBp,STEP,
-                               func->mod->asm_name);   
+                    applyToSet (func->afpoints,setStepEPBp,STEP,
+                                func->mod->asm_name);  
                    
-                   /* set bp @ callers exit point */
-                   setBreakPoint (func->sym->eaddr, CODE, STEP , 
-                                  stepBpCB, func->mod->asm_name, 
-                                  func->aexitline);
-               }
-           }
-       }
+                    /* set bp @ callers exit point */
+                    setBreakPoint (func->sym->eaddr, CODE, STEP , 
+                                   stepBpCB, func->mod->asm_name, 
+                                   func->aexitline);
+                }
+            }
+        }
 
-    doingSteps = 1;
-       simGo(2);
-    doingSteps = 0;
-    showfull = 1;
+        doingSteps = 1;
+        simGo(2);
+        doingSteps = 0;
+        showfull = 1;
     }
     return 0;
 }
@@ -1364,65 +1364,65 @@ int cmdNext (char *s, context *cctxt)
        we don't set break point for all function entry
        points */
     if (!cctxt || !cctxt->func || !cctxt->func->mod) 
-       fprintf(stdout,"The program is not being run.\n");
+        fprintf(stdout,"The program is not being run.\n");
     else {
-       /* if we are @ the end of a function then set
-          break points at execution points of the
-          function in the call stack... */
-       if (cctxt->addr == cctxt->func->sym->eaddr) {
-           if ((func = STACK_PEEK(callStack))) {
-               if (srcMode == SRC_CMODE)
-                   applyToSet (func->cfpoints,setStepEPBp,STEP,
-                               func->mod->c_name);     
-               else
-                   applyToSet (func->afpoints,setStepEPBp,STEP,
-                              func->mod->asm_name);
-           }
-       } else {
-           if (srcMode == SRC_CMODE) {
-               /* for all execution points in this function */
-               applyToSet(cctxt->func->cfpoints,setNextEPBp,NEXT,
-                          cctxt->func->mod->c_name);
-               /* set a break point @ the current function's
-                  exit */
-               setBreakPoint (cctxt->func->sym->eaddr, CODE, NEXT , 
-                              nextBpCB, cctxt->func->mod->c_name, 
-                              cctxt->func->exitline);
+        /* if we are @ the end of a function then set
+           break points at execution points of the
+           function in the call stack... */
+        if (cctxt->addr == cctxt->func->sym->eaddr) {
+            if ((func = STACK_PEEK(callStack))) {
+                if (srcMode == SRC_CMODE)
+                    applyToSet (func->cfpoints,setStepEPBp,NEXT,
+                                func->mod->c_name);    
+                else
+                    applyToSet (func->afpoints,setStepEPBp,NEXT,
+                                func->mod->asm_name);
+            }
+        } else {
+            if (srcMode == SRC_CMODE) {
+                /* for all execution points in this function */
+                applyToSet(cctxt->func->cfpoints,setNextEPBp,NEXT,
+                           cctxt->func->mod->c_name);
+                /* set a break point @ the current function's
+                   exit */
+                setBreakPoint (cctxt->func->sym->eaddr, CODE, NEXT , 
+                               nextBpCB, cctxt->func->mod->c_name, 
+                               cctxt->func->exitline);
                
-               /* now break point @ callers execution points */        
-               if ((func = STACK_PPEEK(callStack))) {
-                   applyToSet (func->cfpoints,setNextEPBp,NEXT ,
-                               func->mod->c_name);     
-                   /* set bp @ callers exit point */
-                   setBreakPoint (func->sym->eaddr, CODE, NEXT , 
-                                  stepBpCB, func->mod->c_name, 
-                                  func->exitline);
-               }
-           } else {
-               /* for all execution points in this function */
-               applyToSet(cctxt->func->afpoints,setNextEPBp,NEXT,
-                          cctxt->func->mod->asm_name);
-               /* set a break point @ the current function's
-                  exit */
-               setBreakPoint (cctxt->func->sym->eaddr, CODE, NEXT , 
-                              nextBpCB, cctxt->func->mod->asm_name, 
-                              cctxt->func->aexitline);
+                /* now break point @ callers execution points */       
+                if ((func = STACK_PPEEK(callStack))) {
+                    applyToSet (func->cfpoints,setNextEPBp,NEXT ,
+                                func->mod->c_name);    
+                    /* set bp @ callers exit point */
+                    setBreakPoint (func->sym->eaddr, CODE, NEXT , 
+                                   stepBpCB, func->mod->c_name, 
+                                   func->exitline);
+                }
+            } else {
+                /* for all execution points in this function */
+                applyToSet(cctxt->func->afpoints,setNextEPBp,NEXT,
+                           cctxt->func->mod->asm_name);
+                /* set a break point @ the current function's
+                   exit */
+                setBreakPoint (cctxt->func->sym->eaddr, CODE, NEXT , 
+                               nextBpCB, cctxt->func->mod->asm_name, 
+                               cctxt->func->aexitline);
                
-               /* now break point @ callers execution points */        
-               if ((func = STACK_PPEEK(callStack))) {
-                   applyToSet (func->cfpoints,setNextEPBp,NEXT ,
-                               func->mod->asm_name);   
-                   /* set bp @ callers exit point */
-                   setBreakPoint (func->sym->eaddr, CODE, NEXT , 
-                                  stepBpCB, func->mod->asm_name, 
-                                  func->aexitline);
-               }
-           }
-           doingSteps = 1;
+                /* now break point @ callers execution points */       
+                if ((func = STACK_PPEEK(callStack))) {
+                    applyToSet (func->cfpoints,setNextEPBp,NEXT ,
+                                func->mod->asm_name);  
+                    /* set bp @ callers exit point */
+                    setBreakPoint (func->sym->eaddr, CODE, NEXT , 
+                                   stepBpCB, func->mod->asm_name, 
+                                   func->aexitline);
+                }
+            }
+        }
+        doingSteps = 1;
         simGo(1);      
-           doingSteps = 0;
+        doingSteps = 0;
         showfull = 1;
-       }
     }    
     return 0;
 }
index 693e800f3a7a48b756a6ae304ff16a4766e072e4..5d9dbac065e18597f558c7f660caa9b99db21d44 100644 (file)
@@ -46,6 +46,7 @@ context *currCtxt = NULL;
 short fullname = 0;
 short showfull = 0;
 short userinterrupt = 0;
+char contsim = 0;
 char *ssdirl = DATADIR LIB_DIR_SUFFIX ":" DATADIR LIB_DIR_SUFFIX "/small" ;
 char *simArgs[40];
 int nsimArgs = 0;
@@ -472,6 +473,7 @@ static void functionPoints ()
 {
     function *func;
     symbol *sym;
+    exePoint *ep ;
 
     /* for all functions do */
     for ( func = setFirstItem(functions); func;
@@ -506,7 +508,6 @@ static void functionPoints ()
       if (mod->cLines[j]->addr >= sym->addr &&
     mod->cLines[j]->addr <= sym->eaddr ) {
 
-    exePoint *ep ;
 
     /* add it to the execution point */
     if (func->entryline > j)
@@ -523,7 +524,16 @@ static void functionPoints ()
     addSet(&func->cfpoints,ep);
       }
   }
-
+  /* check double line execution points of module */
+  for (ep = setFirstItem(mod->cfpoints); ep;
+       ep = setNextItem(mod->cfpoints))
+  {
+      if (ep->addr >= sym->addr &&
+          ep->addr <= sym->eaddr ) 
+      {
+          addSet(&func->cfpoints,ep);
+      }
+  }
   /* do the same for asm execution points */
   for ( j = 0 ; j < mod->nasmLines ; j++ ) {
       if (mod->asmLines[j]->addr >= sym->addr &&
@@ -843,6 +853,7 @@ static void parseCmdLine (int argc, char **argv)
     int passon_args_flag = 0;  /* if true, pass on args to simulator */
 
     Dprintf(D_sdcdb, ("sdcdb: parseCmdLine\n"));
+    contsim=0;
 
     for ( i = 1; i < argc ; i++) {
   //fprintf(stdout,"%s\n",argv[i]);
@@ -889,6 +900,10 @@ static void parseCmdLine (int argc, char **argv)
           continue;
       }
 #endif
+      if (strncmp(argv[i],"-contsim",8) == 0) {
+          contsim=1;
+          continue;
+      }
 
       /* model string */
       if (strncmp(argv[i],"-m",2) == 0) {
index 80c42627e24d8f2fb270ed18d865fab9c85ce8e6..36a4bd2f0f3d31a1baa3cd27140d7e5f8be3a706 100644 (file)
@@ -179,6 +179,7 @@ typedef struct module {
     int   nasmLines;         /* # of lines in the assembler file */
     srcLine  **cLines;       /* actual source lines */    
     srcLine  **asmLines;     /* actual assembler source lines*/
+    set       *cfpoints;     /* set of double line execution points */   
 } module;
 
 /*-----------------------------------------------------------------*/
@@ -261,6 +262,7 @@ char *gc_strdup(const char *s);
 srcLine **loadFile (char *name, int *nlines);
 extern short fullname;
 extern int srcMode;
+extern char contsim;
 char *searchDirsFname (char *);
 
 #endif
index 61133fa5481f6e136f26034c7376d9efc664784b..b4486d12ae189d823d05f907f5a1ca6e63c2fa68 100644 (file)
@@ -36,6 +36,7 @@
 #endif
 FILE *simin ; /* stream for simulator input */
 FILE *simout; /* stream for simulator output */
+typedef void (*sighandler_t)(int);
 
 int sock = -1; /* socket descriptor to comm with simulator */
 pid_t simPid = -1;
@@ -422,6 +423,7 @@ void simLoadFile (char *s)
 /*-----------------------------------------------------------------*/
 unsigned int simGoTillBp ( unsigned int gaddr)
 {
+    sighandler_t oldsig;
     char *sr;
     unsigned addr ; 
     char *sfmt;
@@ -441,6 +443,8 @@ unsigned int simGoTillBp ( unsigned int gaddr)
       //sleep(1);
       //waitForSim();
 
+      sendSim("reset\n");
+      waitForSim(wait_ms, NULL);
       sendSim("run 0x0\n");
     } else     if (gaddr == -1) { /* resume */
       sendSim ("run\n");
@@ -477,10 +481,16 @@ unsigned int simGoTillBp ( unsigned int gaddr)
         sr++ ;
     }
 
+    oldsig = signal(SIGINT,SIG_IGN);
+    /* get answer of stop command */
+    if ( userinterrupt )
+        waitForSim(wait_ms, NULL);
+
     /* better solution: ask pc */
     sendSim ("pc\n");
     waitForSim(100, NULL);
     sr = simResponse();
+    signal(SIGINT,oldsig);
 
     gaddr = strtol(sr+3,0,0);
     return gaddr;
index b35e2d150a36e33d578132a22e620958f686c4bb..6d12e577917c745c4f436218e2e5060975cb7574 100644 (file)
@@ -734,14 +734,28 @@ static void lnkCSrc (char *s)
 
     line--;
     /* one line can have more than one address : (for loops !)*/
-    if (line < mod->ncLines && line > 0 &&
+    if (line < mod->ncLines && line > 0 /*&&
         ( !mod->cLines[line]->addr ||
-           mod->cLines[line]->level > level )) {
-  mod->cLines[line]->addr = addr;
-  mod->cLines[line]->block = block;
-  mod->cLines[line]->level = level;
-  Dprintf(D_symtab, ("symtab: ccc %s(%d:0x%x) %s",mod->c_name,
-         line+1,addr,mod->cLines[line]->src));
+        mod->cLines[line]->level > level )*/ ) 
+    {
+        if ( mod->cLines[line]->addr )
+        {
+            /* save double line information for exepoints */
+            exePoint *ep ;
+            ep = Safe_calloc(1,sizeof(exePoint));
+            ep->addr =  mod->cLines[line]->addr ;
+            ep->line = line;
+            ep->block= mod->cLines[line]->block;
+            ep->level= mod->cLines[line]->level;
+            addSet(&mod->cfpoints,ep);
+            Dprintf(D_symtab, ("symtab: exe %s(%d:0x%x) %s",mod->c_name,
+                           line+1,addr,mod->cLines[line]->src));
+        }
+        mod->cLines[line]->addr = addr;
+        mod->cLines[line]->block = block;
+        mod->cLines[line]->level = level;
+        Dprintf(D_symtab, ("symtab: ccc %s(%d:0x%x) %s",mod->c_name,
+                           line+1,addr,mod->cLines[line]->src));
     }
     return;