]> git.gag.com Git - fw/sdcc/blobdiff - debugger/mcs51/cmd.c
fixed bug #490097
[fw/sdcc] / debugger / mcs51 / cmd.c
index 89dfe6a5d4cfb2b520638dbde407bbd27f9b692b..ea71bff0de0c8eef587fc9d908fba274a90e1517 100644 (file)
 int listLines = 10;
 EXTERN_STACK_DCL(callStack,function *,1024);
 
+#if defined(__APPLE__) && defined(__MACH__)
+static char *copying=
+{" GNU GENERAL PUBLIC LICENSE Version 2"};
+static char *warranty=
+{" NO WARRANTY"};
+#else
 static char *copying=
 "                   GNU GENERAL PUBLIC LICENSE
                        Version 2, June 1991
@@ -312,6 +318,7 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
 POSSIBILITY OF SUCH DAMAGES.
 ";
+#endif
 
 static void printTypeInfo(link *);
 static void printValAggregates (symbol *,link *,char,unsigned int);
@@ -540,8 +547,10 @@ context *discoverContext (unsigned addr)
     int line = 0;
 
     /* find the function we are in */
-    if (!applyToSet(functions,funcInAddr,addr,&func))
-       return NULL;
+    if (!applyToSet(functions,funcInAddr,addr,&func)) {
+      fprintf(stderr, "Error?:discoverContext: cannot apply to set!\n");
+       return NULL;
+    }
 
     currCtxt->func = func;
     currCtxt->addr = func->laddr = addr;
@@ -574,6 +583,8 @@ void simGo (unsigned int gaddr)
     unsigned int addr ;
     context *ctxt;
     int rv;
+    static int initial_break_flag = 0;
+
  top:    
     addr = simGoTillBp (gaddr);
 
@@ -592,8 +603,37 @@ void simGo (unsigned int gaddr)
        if not then we continue with the execution 
        of the program */
     if (!rv) {
+      if (!initial_break_flag) {
+        initial_break_flag = 1;  // kludge to stop only at first run
+        fprintf(stdout, "Stopping at entry.  You can now list and set breakpoints\n");
+      }
+      else {
+               gaddr = -1;
+               goto top ;
+      }
+
+// notes: kpb
+// I took this out, after running "run" it would just keep re-running
+// even after a lot of break points hit.  For some reason above code
+// not triggering(dispatchCB).  This seems to be by design, startup adds
+// a bunch of breakpoints-but they are not USER breakpoints.  Perhaps the
+// debugger changed with its implementation of "go"("run").  It seems we
+// need to add a "next" or "step" followed by a "run"...
+// I added a "step" in simi.c when we want a resume function, this seems
+// to work.
+
+// still there is question of how do we stop it initially, since
+// it must be started before it can get a context.  If so, we would
+// want it to just run up to an initial entry point you'd think...
+// I don't see why we can't set breakpoints before an initial run,
+// this does not seem right to me.
+
+// line #'s are a bit off too.
+
+#if 0
        gaddr = -1;
        goto top ;
+#endif
     }
     
 }
@@ -1574,8 +1614,15 @@ int cmdClrUserBp (char *s, context *cctxt)
 /*-----------------------------------------------------------------*/
 int cmdSimulator (char *s, context *cctxt)
 {   
-    sendSim(s);
-    sendSim("\n");
+  char tmpstr[82];
+
+    if (strlen(s) > 80) {
+      printf("error 3A\n");
+      exit(1);
+    }
+    strcpy(tmpstr, s);
+    strcat(tmpstr, "\n");
+    sendSim(tmpstr);
     waitForSim();
     fprintf(stdout,"%s",simResponse());
     return 0;