a new function for startup (_main)
[fw/sdcc] / debugger / mcs51 / simi.c
index b4486d12ae189d823d05f907f5a1ca6e63c2fa68..6eb859cadf3c1ae26fdaca38edff9eb693118d5c 100644 (file)
@@ -36,7 +36,6 @@
 #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;
@@ -145,7 +144,17 @@ void openSimulator (char **args, int nargs)
     int retry = 0;
     int i ;
     Dprintf(D_simi, ("simi: openSimulator\n"));
-
+#ifdef SDCDB_DEBUG
+    if (D_simi & sdcdbDebug)
+    {
+        printf("simi: openSimulator: ");
+        for (i=0; i < nargs; i++ )
+        {
+            printf("arg%d: %s ",i,args[i]);
+        }
+        printf("\n");
+    }
+#endif
     invalidateCache(XMEM_CACHE);
     invalidateCache(IMEM_CACHE);
     invalidateCache(SREG_CACHE);
@@ -288,6 +297,15 @@ static int getMemString(char *buffer, char wrflag,
     return cachenr;
 }
 
+void simSetPC( unsigned int addr )
+{
+    char buffer[40];
+    sprintf(buffer,"pc %d\n", addr);
+    sendSim(buffer);
+    waitForSim(100,NULL);
+    simResponse();   
+}
+
 int simSetValue (unsigned int addr,char mem, int size, unsigned long val)
 {
     char cachenr, i;
@@ -313,6 +331,7 @@ int simSetValue (unsigned int addr,char mem, int size, unsigned long val)
     sendSim(buffer);
     waitForSim(100,NULL);
     simResponse();   
+    return 0;
 }
 
 
@@ -412,7 +431,7 @@ void simLoadFile (char *s)
 {
     char buff[128];
 
-    sprintf(buff,"l \"%s\"\n",s);
+    sprintf(buff,"file \"%s\"\n",s);
     printf(buff);
     sendSim(buff);
     waitForSim(500,NULL);
@@ -423,7 +442,6 @@ void simLoadFile (char *s)
 /*-----------------------------------------------------------------*/
 unsigned int simGoTillBp ( unsigned int gaddr)
 {
-    sighandler_t oldsig;
     char *sr;
     unsigned addr ; 
     char *sfmt;
@@ -481,7 +499,7 @@ unsigned int simGoTillBp ( unsigned int gaddr)
         sr++ ;
     }
 
-    oldsig = signal(SIGINT,SIG_IGN);
+    nointerrupt = 1;
     /* get answer of stop command */
     if ( userinterrupt )
         waitForSim(wait_ms, NULL);
@@ -490,7 +508,7 @@ unsigned int simGoTillBp ( unsigned int gaddr)
     sendSim ("pc\n");
     waitForSim(100, NULL);
     sr = simResponse();
-    signal(SIGINT,oldsig);
+    nointerrupt = 0;
 
     gaddr = strtol(sr+3,0,0);
     return gaddr;
@@ -519,6 +537,7 @@ void closeSimulator ()
         simactive = 0;
         return;
     }
+    simactive = 0;
     sendSim("quit\n");
     fclose (simin);
     fclose (simout);