]> git.gag.com Git - fw/sdcc/blobdiff - debugger/mcs51/sdcdb.c
Get debugger working
[fw/sdcc] / debugger / mcs51 / sdcdb.c
index 020814529a1f0eac5c8110ee514e4a4f96faa5b8..a416625a8394a22197ce6db01e1aed2a76ab66ad 100644 (file)
@@ -26,6 +26,7 @@
 #include "simi.h"
 #include "break.h"
 #include "cmd.h"
+#include "newalloc.h"
 
 char *currModName = NULL;
 cdbrecs *recsRoot = NULL ;
@@ -153,7 +154,7 @@ struct cmdtab
 char *gc_strdup(const char *s)
 {
     char *ret;
-    Safe_calloc(1,ret, strlen(s)+1);
+    ret = Safe_malloc(strlen(s)+1);
     strcpy(ret, s);
     return ret;
 }
@@ -168,7 +169,7 @@ char *alloccpy ( char *s, int size)
     if (!size)
   return NULL;
 
-    Safe_calloc(1,d,size+1);
+    d = Safe_malloc(size+1);
     memcpy(d,s,size);
     d[size] = '\0';
 
@@ -209,7 +210,7 @@ static int readCdb (FILE *file)
     if (!(bp = fgets(buffer,sizeof(buffer),file)))
       return 0;
 
-    Safe_calloc(1,currl,sizeof(cdbrecs));
+    currl = Safe_calloc(1,sizeof(cdbrecs));
     recsRoot = currl ;
 
     while (1) {
@@ -237,7 +238,7 @@ static int readCdb (FILE *file)
       }
 
       bp += 2;
-      Safe_calloc(1,currl->line,strlen(bp));
+      currl->line = Safe_malloc(strlen(bp));
       strncpy(currl->line,bp,strlen(bp)-1);
       currl->line[strlen(bp)-1] = '\0';
   }
@@ -248,7 +249,7 @@ static int readCdb (FILE *file)
   if (feof(file))
       break;
 
-  Safe_calloc(1,currl->next,sizeof(cdbrecs));
+  currl->next = Safe_calloc(1,sizeof(cdbrecs));
   currl = currl->next;
     }
 
@@ -351,7 +352,7 @@ srcLine **loadFile (char *name, int *nlines)
 
   slines = (srcLine **)resize((void **)slines,*nlines);
 
-  Safe_calloc(1,slines[(*nlines)-1],sizeof(srcLine));
+  slines[(*nlines)-1] = Safe_calloc(1,sizeof(srcLine));
   slines[(*nlines)-1]->src = alloccpy(bp,strlen(bp));
     }
 
@@ -429,12 +430,11 @@ static void functionPoints ()
 
   sym = func->sym;
 
-#ifdef SDCDB_DEBUG
-  printf("func '%s' has entry '%x' exit '%x'\n",
+  Dprintf(D_sdcdb, ("func '%s' has entry '%x' exit '%x'\n",
          func->sym->name,
          func->sym->addr,
-         func->sym->eaddr);
-#endif
+         func->sym->eaddr));
+
   if (!func->sym->addr && !func->sym->eaddr)
       continue ;
 
@@ -464,7 +464,7 @@ static void functionPoints ()
     if (func->exitline < j)
         func->exitline = j;
 
-    Safe_calloc(1,ep,sizeof(exePoint));
+    ep = Safe_calloc(1,sizeof(exePoint));
     ep->addr =  mod->cLines[j]->addr ;
     ep->line = j;
     ep->block= mod->cLines[j]->block;
@@ -487,7 +487,7 @@ static void functionPoints ()
         func->aexitline = j;
 
     /* add it to the execution point */
-    Safe_calloc(1,ep,sizeof(exePoint));
+    ep = Safe_calloc(1,sizeof(exePoint));
     ep->addr =  mod->asmLines[j]->addr ;
     ep->line = j;
     addSet(&func->afpoints,ep);
@@ -495,20 +495,21 @@ static void functionPoints ()
   }
 
 #ifdef SDCDB_DEBUG
-  printf("function '%s' has the following C exePoints\n",
-         func->sym->name);
+  Dprintf(D_sdcdb, ("function '%s' has the following C exePoints\n",
+         func->sym->name));
   {
       exePoint *ep;
 
       for (ep = setFirstItem(func->cfpoints); ep;
      ep = setNextItem(func->cfpoints))
-    fprintf (stdout,"{%x,%d} %s",ep->addr,ep->line,mod->cLines[ep->line]->src);
+     Dprintf(D_sdcdb, ("{%x,%d} %s",
+         ep->addr,ep->line,mod->cLines[ep->line]->src));
 
-      fprintf(stdout," and the following ASM exePoints\n");
+      Dprintf(D_sdcdb, (" and the following ASM exePoints\n"));
       for (ep = setFirstItem(func->afpoints); ep;
-     ep = setNextItem(func->afpoints))
-    fprintf (stdout,"{%x,%d} %s",ep->addr,ep->line,mod->asmLines[ep->line]->src);
-
+           ep = setNextItem(func->afpoints))
+        Dprintf (D_sdcdb, ("{%x,%d} %s",
+            ep->addr,ep->line,mod->asmLines[ep->line]->src));
   }
 #endif
     }
@@ -559,7 +560,7 @@ int cmdFile (char *s,context *cctxt)
     }
 
     /* allocate for context */
-    Safe_calloc(1,currCtxt ,sizeof(context));
+    currCtxt = Safe_calloc(1,sizeof(context));
 
     /* readin the debug information */
     if (!readCdb (cdbFile)) {