sdcdb updates,ddd
authorkbongers <kbongers@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 24 Apr 2003 04:53:25 +0000 (04:53 +0000)
committerkbongers <kbongers@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 24 Apr 2003 04:53:25 +0000 (04:53 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2561 4a8a32a2-be11-0410-ad9d-d568d2c75423

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

index e28c1c743e523489188e449c804d58cb5dd1029d..040bbaa42f938f4df8c54e7890fb6cdb652ec9f5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2003-04-23  Karl Bongers(apply patches for Martin Helmling)
+
+        * debugger/mcs51/sdcdb.c,simi.c,cmd.c,..
+        Martin Helmling added support for ddd GUI debugger.
+        Code added to display assembly, set variables, and other commands
+        to interface to ddd.
+
 2003-04-23  Bernhard Held <bernhard@bernhardheld.de>
 
        * as/Makefile: fix target clean
index f44b501c6951996cac681d4879bb3f4ec4a470c7..34d9c8b9dc7e17088440833eeecbe3f758ffe361 100644 (file)
@@ -2,6 +2,46 @@ sdcc/debugger
 
 SDCDB debugger
 ======================
+Notes April 23, 2003
+
+Martin Helmling added support for ddd GUI debugger.
+Code added to display assembly, set variables, and other commands
+to interface to ddd.
+
+From Martins email:
+
+in the attachment is my actual patch.
+
+The 'up' and 'down' stack commands are not implemented.
+But the features for 'ddd' to see bopth the c source and the assembler 
+works,
+also the display of variables.
+Set variables are only implemented for basic types.
+Register variables can also displayed, but here I think a problem in the 
+*.cdb file exists.
+Sometimes the register name not exists:
+
+S:LcacheTxAnalogValue$offset$1$1({1}SC:U),E,0,0
+S:LcacheTxAnalogValue$i$1$1({1}SC:S),R,0,0,[]
+S:LcacheTxAnalogValue$val$1$1({4}ST__00020000:S),E,0,0
+S:LcacheTxAnalogValue$value$1$1({1}SC:U),R,0,0,[]
+S:LcacheTxAnalogValue$sloc0$1$0({4}SL:U),E,0,0
+S:LsetRelays$addr$1$1({1}SC:U),R,0,0,[r2]
+S:LsetRelays$state$1$1({1}SC:U),R,0,0,[r3]
+S:LsetRelays$value$1$1({1}SC:U),R,0,0,[r5]
+S:L_main$i$1$1({1}SC:U),R,0,0,[]
+S:L_main$j$1$1({1}SC:U),R,0,0,[r3]
+S:L_main$ok$1$1({1}SC:U),R,0,0,[r3]
+
+the empty [] I mean !!
+
+Is this a known bug  in sdcc ?
+
+Also sometimes not the correct breakpoints for stepping found  in sdcdb. 
+I try to fix this tomorrow.
+
+
+
 Notes Feb 10, 2002 - Karl Bongers
 
 SDCDB is a debugger for SDCC compiler.  It works as a front
index 75f5b72a74677dc52bd2b9ee60284ae58d689661..534723479df933c09f01685567b4125128cd8590 100644 (file)
@@ -217,12 +217,12 @@ void listUSERbp ()
   fprintf(stdout,"No breakpoints.\n");
   return ;
     }
-    fprintf(stdout,"Num Address What\n");
+    fprintf(stdout,"Num Type           Disp Enb Address    What\n");
     for ( bp = hTabFirstItem(bptable,&k) ; bp ;
     bp = hTabNextItem(bptable,&k)) {
 
   if (bp->bpType == USER ) {
-      fprintf(stdout,"%-3d 0x%04x  at %s:%d\n",
+      fprintf(stdout,"%-3d breakpoint     keep y   0x%08x at %s:%d\n",
         bp->bpnum,bp->addr,
         bp->filename,bp->lineno);
 
index d56b4f1e1f7b7e6371dd3c15e050d8aca98f0a20..cda3f9f7be6364a9c7f065e4c34581bd87305f14 100644 (file)
@@ -328,8 +328,10 @@ static char *warranty=
 
 static void printTypeInfo(link *);
 static void printValAggregates (symbol *,link *,char,unsigned int);
+static void setSymValue(symbol *sym, char *val, context *cctxt);
 
 int srcMode = SRC_CMODE ;
+static set  *dispsymbols = NULL   ; /* set of displayable symbols */
 
 /*-----------------------------------------------------------------*/
 /* funcWithName - returns function with name                       */
@@ -435,6 +437,35 @@ static void clearBPatModLine (module *mod, int line)
     return;
 }
 
+/*-----------------------------------------------------------------*/
+/* moduleLineWithAddr - finds and returns a line  with a given address */
+/*-----------------------------------------------------------------*/
+DEFSETFUNC(moduleLineWithAddr)
+{
+    module *mod = item;
+    int i;
+
+    V_ARG(unsigned int,addr);
+    V_ARG(module **,rmod);
+    V_ARG(int *,line);
+
+    if (*rmod)
+        return 0;
+
+    for (i=0; i < mod->nasmLines; i++ ) 
+    {
+        if ( mod->asmLines[i]->addr == addr)
+        {
+            *rmod = mod ;
+            if (line )
+                *line = mod->ncLines;
+            return 1;
+        }
+    }
+
+    return 0;
+}
+
 /*-----------------------------------------------------------------*/
 /* funcWithNameModule - returns functions with a name module combo */
 /*-----------------------------------------------------------------*/
@@ -446,7 +477,7 @@ DEFSETFUNC(funcWithNameModule)
     V_ARG(function **,funcp);
 
     if (*funcp)
-       return 0;
+        return 0;
 
     if (strcmp(func->sym->name,fname) == 0 &&
        strcmp(func->mod->c_name,mname) == 0) {
@@ -552,31 +583,66 @@ DEFSETFUNC(lineAtAddr)
     
 }
 
+/*-----------------------------------------------------------------*/
+/* lineNearAddr - for execution points returns the one with addr   */
+/*-----------------------------------------------------------------*/
+DEFSETFUNC(lineNearAddr)
+{
+    exePoint *ep = item;
+    V_ARG(unsigned int,addr);
+    V_ARG(int *,line);
+    V_ARG(int *,block);
+    V_ARG(int *,level);
+
+    /* the line in which the address is */
+    if (ep->addr <= addr) {
+       *line = ep->line;
+       if (block)
+           *block = ep->block ;
+       if (level)
+           *level = ep->level ;
+       return 1;
+    }
+
+    return 0;
+    
+}
+
 /*-----------------------------------------------------------------*/
 /* discoverContext - find out the current context of the bp        */
 /*-----------------------------------------------------------------*/
 context *discoverContext (unsigned addr)
 {
     function *func = NULL;
+    module   *mod  = NULL;
     int line = 0;
 
     /* find the function we are in */
     if (!applyToSet(functions,funcInAddr,addr,&func)) {
-      fprintf(stderr, "Error?:discoverContext: cannot apply to set!\n");
-       return NULL;
+        if (!applyToSet(functions,funcWithName,"main") ||
+            !applyToSet(modules,moduleLineWithAddr,addr,&mod,&line))
+        {
+            fprintf(stderr, "Error?:discoverContext: cannot apply to set!\n");
+            return NULL;
+        }
+        currCtxt->func = func;
+        currCtxt->addr = addr;
+        currCtxt->modName = mod->name;
+        currCtxt->cline = func->exitline;
     }
-
-    currCtxt->func = func;
-    currCtxt->addr = func->laddr = addr;
-    currCtxt->modName = func->modName;
-    
-    /* find the c line number */
-    if(applyToSet(func->cfpoints,lineAtAddr,addr,
-                 &line,&currCtxt->block,&currCtxt->level)) 
-       currCtxt->cline = func->lline = line;
     else
-       currCtxt->cline = func->exitline;
+    {
+        currCtxt->func = func;
+        currCtxt->addr = func->laddr = addr;
+        currCtxt->modName = func->modName;
     
+        /* find the c line number */
+        if(applyToSet(func->cfpoints,lineNearAddr,addr,
+                  &line,&currCtxt->block,&currCtxt->level)) 
+            currCtxt->cline = func->lline = line;
+        else
+            currCtxt->cline = func->exitline;
+    }    
     /* find the asm line number */
     line = 0;
     if (applyToSet(func->afpoints,lineAtAddr,addr,
@@ -600,6 +666,11 @@ void simGo (unsigned int gaddr)
     static int initial_break_flag = 0;
 
  top:    
+    if ( userinterrupt )
+    {
+        userinterrupt = 0;
+        return;
+    }
     addr = simGoTillBp (gaddr);
 
     /* got the pc for the break point now first
@@ -609,7 +680,6 @@ void simGo (unsigned int gaddr)
     
     /* dispatch all the break point call back functions */
     rv = dispatchCB (addr,ctxt);    
-
  ret:    
 
     /* the dispatch call back function will return
@@ -652,6 +722,162 @@ void simGo (unsigned int gaddr)
     
 }
 
+static int printAsmLine( function *func, module *m, long saddr, long eaddr)
+{
+    int i,j,delta;
+    int symaddr;
+    int lastaddr = saddr+1;
+    char *symname;
+
+    if ( func )
+    {
+        symaddr = func->sym->addr;
+        symname = func->sym->name;
+    }
+    else
+    {
+        symaddr = saddr;
+        symname = "" ;
+    }
+    for (j=0,i=0; i < m->nasmLines; i++ ) 
+    {
+        if ( saddr >= 0 && m->asmLines[i]->addr < saddr)
+        {
+                continue;
+        }
+        if ( eaddr >= 0 && m->asmLines[i]->addr > eaddr)
+        {
+                continue;
+        }
+        if ( func && 
+            (m->asmLines[i]->addr < func->sym->addr ||
+             m->asmLines[i]->addr > func->sym->eaddr ))
+        {
+            continue;
+        } 
+        delta = m->asmLines[i]->addr - symaddr;
+        if ( delta >= 0 )
+        {
+            j++;
+            lastaddr = m->asmLines[i]->addr;
+            printf("0x%08x <%s",lastaddr,symname);
+            if (delta > 0) printf("+%d",delta);
+            printf(">:\t%s",m->asmLines[i]->src);            
+        }
+    }
+    return lastaddr;
+}
+
+/*-----------------------------------------------------------------*/
+/* cmdDisasm - disassemble  asm instruction                        */
+/*-----------------------------------------------------------------*/
+static int cmdDisasm (char *s, context *cctxt, int args)
+{
+    function *func = NULL;
+    long  saddr = -1;
+    long  eaddr = -1;
+    int   found = 0;
+    module *modul;
+    /* white space skip */
+
+    if ( args > 0 )
+    {
+        while (*s && isspace(*s)) s++;
+
+        if ( isdigit(*s))
+        {
+            saddr = strtol(s,&s,0);
+            if ( args > 1 )
+            {
+                while (*s && isspace(*s)) s++;
+
+                if ( isdigit(*s))
+                    eaddr = strtol(s,0,0);
+            }
+            else
+                eaddr = saddr+1;
+        }
+    }
+
+    if ( eaddr == -1 )
+    {       
+        /* no start or only start so dump function */
+        if ( saddr == -1 )
+        {
+            func = cctxt->func;
+        }
+        else
+        {
+            applyToSet(functions,funcInAddr,saddr,&func);
+        }
+        if ( func )
+        {
+            printf("Dump of assembler code for function %s:\n",func->sym->name);
+            printAsmLine(func,func->mod,-1,-1);
+            printf("End of assembler dump.\n");
+            return 0; 
+        }
+        else
+        {
+            if (applyToSet(modules,moduleLineWithAddr,saddr,&modul,NULL))
+            {
+                eaddr = saddr + 5;
+                printf("Dump of assembler code:\n");
+                printAsmLine(NULL,modul,saddr,eaddr);
+                printf("End of assembler dump.\n");
+                return 0; 
+            }
+        }
+    }
+    else
+    {
+        if ( args > 1 )
+            printf("Dump of assembler code from 0x%08x to 0x%08x:\n",saddr,eaddr);
+        found = 0;
+        while ( saddr < eaddr )
+        {
+            func = NULL;
+            if (applyToSet(functions,funcInAddr,saddr,&func))
+            {
+                found = 1;
+                modul = func->mod;
+            }
+            else
+            {
+                if ( found )
+                    break;
+                if (!applyToSet(modules,moduleLineWithAddr,saddr,&modul,NULL))
+                    break;
+            }
+            saddr = printAsmLine(func,modul,saddr,eaddr) + 1;
+        }
+        if( saddr >= eaddr)
+        {
+            if ( args > 1 )
+                printf("End of assembler dump.\n");
+            return 0; 
+        }
+        
+    }
+    fprintf(stderr,"No function contains specified address.\n");
+    return 0; 
+}
+/*-----------------------------------------------------------------*/
+/* cmdDisasm1 - disassemble one asm instruction                    */
+/*-----------------------------------------------------------------*/
+int cmdDisasm1 (char *s, context *cctxt)
+{
+    return cmdDisasm( s, cctxt, 1);
+}
+
+/*-----------------------------------------------------------------*/
+/* cmdDisasmF - disassemble asm instructions                       */
+/*-----------------------------------------------------------------*/
+int cmdDisasmF(char *s, context *cctxt)
+{
+    return cmdDisasm( s, cctxt, 2);
+}
+
 /*-----------------------------------------------------------------*/
 /* cmdSetUserBp - set break point at the user specified location   */
 /*-----------------------------------------------------------------*/
@@ -667,6 +893,7 @@ int cmdSetUserBp (char *s, context *cctxt)
        c) filename:lineno  - line number of the given file
        e) filename:function- function X in file Y (useful for static functions)
        f) function         - function entry point
+       g) *addr            - break point at address 
     */
 
     if (!cctxt) {
@@ -702,7 +929,34 @@ int cmdSetUserBp (char *s, context *cctxt)
                        
        goto ret ;
     }
-
+    /* case g) *addr */
+    if ( *s == '*' && isdigit(*(s+1)))
+    {
+        int  line   = 0;
+        long braddr = strtol(s+1,0,0);
+        if (!applyToSet(functions,funcInAddr,braddr,&func))
+        {
+            module *modul;
+            if (!applyToSet(modules,moduleLineWithAddr,braddr,&modul,&line))
+            {
+                fprintf(stderr,"Address 0x%08x not exists in code.\n",braddr); 
+            }
+            else
+            {
+                setBreakPoint ( braddr , CODE , USER , userBpCB ,
+                            modul->c_name,line);
+            }
+            goto ret ;
+        }
+               else
+        {
+            int line = func->exitline;
+            applyToSet(func->cfpoints,lineNearAddr,braddr,&line,NULL,NULL);
+            setBreakPoint ( braddr , CODE , USER , userBpCB ,
+                            func->mod->c_name,line);
+        }
+       goto ret ;
+    }
     /* case b) lineno */
     /* check if line number */
     if (isdigit(*s)) {
@@ -787,7 +1041,13 @@ int cmdSetUserBp (char *s, context *cctxt)
 /*-----------------------------------------------------------------*/
 int cmdListAsm (char *s, context *cctxt)
 {
-    fprintf(stderr,"'listasm' command not yet implemented\n");
+    if (  cctxt && cctxt->func) 
+    {
+        /* actual line */
+        if (printAsmLine(cctxt->func,cctxt->func->mod,
+                         (long)cctxt->addr,(long)cctxt->addr))
+            return 0; 
+    }
     return 0;
 }
 
@@ -806,7 +1066,34 @@ int cmdSetOption (char *s, context *cctxt)
                (srcMode == SRC_CMODE ? "C" : "asm"));
        return 0;
     }
-    
+
+    if (strncmp(s,"variable ",9) == 0) 
+    {
+        symbol *sym ;
+        char *val;
+        s += 9;
+        while (isspace(*s)) s++;
+        if (!*s) return 0;
+
+        val = s;
+        while (*val && !isspace(*val) && *val != '=') val++;
+        while (isspace(*val)) *val++ = '\0';
+        if (*val) *val++ = '\0';
+        if (*val)
+        {
+            if ((sym = symLookup(s,cctxt))) 
+            {
+                setSymValue(sym,val,cctxt);
+                return 0;
+            }   
+            fprintf(stdout,"No symbol \"%s\" in current context.\n",s);
+        }
+        else
+            fprintf(stdout,"No new value for \"%s\".\n",s);
+        return 0;       
+    }
+
     fprintf(stderr,"'set %s' command not yet implemented\n",s);
     return 0;
 }
@@ -823,6 +1110,7 @@ int cmdContinue (char *s, context *cctxt)
 
     fprintf(stdout,"Continuing.\n");
     simGo(-1);
+    showfull = 1;
     return 0;
 }
 
@@ -863,6 +1151,9 @@ int cmdStep (char *s, context *cctxt)
     if (!cctxt || !cctxt->func || !cctxt->func->mod) 
        fprintf(stdout,"The program is not being run.\n");
     else {
+    int origSrcMode = srcMode;
+    if ( *s == 'i' )
+        srcMode = SRC_AMODE;
        /* if we are @ the end of a function then set
           break points at execution points of the
           function in the call stack... */
@@ -928,7 +1219,9 @@ int cmdStep (char *s, context *cctxt)
            }
        }
 
+    srcMode = origSrcMode;
        simGo(-1);
+    showfull = 1;
     }
     return 0;
 }
@@ -945,6 +1238,9 @@ int cmdNext (char *s, context *cctxt)
     if (!cctxt || !cctxt->func || !cctxt->func->mod) 
        fprintf(stdout,"The program is not being run.\n");
     else {
+    int origSrcMode = srcMode;
+    if ( *s == 'i' )
+        srcMode = SRC_AMODE;
        
        /* if we are @ the end of a function then set
           break points at execution points of the
@@ -998,8 +1294,11 @@ int cmdNext (char *s, context *cctxt)
                                   func->aexitline);
                }
            }
+        srcMode = origSrcMode;
            simGo(-1);  
+        showfull = 1;
        }
+    srcMode = origSrcMode;
     }    
     return 0;
 }
@@ -1012,6 +1311,11 @@ int cmdRun (char *s, context *cctxt)
     char buff[10];
     if (!cctxt || !cctxt->func || !cctxt->func->mod) {
        fprintf(stdout,"Starting program\n");
+    if ( ! simactive )
+    {
+        fprintf(stdout,"No executable file specified.\nUse the \"file\" command.\n");
+        return 0;
+    }
        simGo(0);
     } else {
        
@@ -1026,7 +1330,7 @@ int cmdRun (char *s, context *cctxt)
            simGo(0);
        }
     }
-
+    showfull = 1;
     return 0;
 }
 
@@ -1094,8 +1398,8 @@ int cmdListFunctions (char *s, context *cctxt)
       if (f == NULL)
         break;
       if (our_verbose) {
-        printf("  %d) sym:%x, modName:%s, mod:%x\n", i,
-          f->sym, f->modName, f->mod);
+        printf("  %d) sym:%x, fname:%s, modName:%s, mod:%x\n", i,
+          f->sym, f->sym->name, f->modName, f->mod);
         printf("    entryline:%d, aentryline:%d, exitline:%d, aexitline:%d\n",
                 f->entryline, f->aentryline, f->exitline, f->aexitline);
         printf("    cfpoints:%x, afpoints:%x, laddr:%x, lline:%d\n",
@@ -1142,29 +1446,25 @@ int cmdListModules (char *s, context *cctxt)
       printf("    cLines:%x, asmLines:%x\n",
               m->cLines, m->asmLines);
       }
-      if (our_verbose > 2) {
-        i = 0;
-        if (m->cLines) {
-          cs = m->cLines[i++];
+      if (our_verbose >= 2) {
+        if (m->ncLines) {
           printf("    [cLines] ");
-          while (cs) {
-            if (our_verbose)
+          if ( our_verbose)
+          for (i=0; i<m->ncLines; i++ ) {
+              cs = m->cLines[i];
               printf("   (%d) addr:%x, block:%d, level:%d, src:%s\n",
                  i, cs->addr, cs->block, cs->level, cs->src);
-            cs = m->cLines[i++];
           }
           if (!our_verbose)
               printf("%d records", i);
         }
-        i = 0;
-        if (m->asmLines) {
-          as = m->asmLines[i++];
+        if (m->nasmLines) {
           printf("    [asmLines] ");
-          while (as) {
-            if (our_verbose)
+          if ( our_verbose)
+          for (i=0; i<m->nasmLines; i++ ) {
+              as = m->asmLines[i];
               printf("   (%d) addr:%x, block:%d, level:%d, src:%s\n",
                  i, as->addr, as->block, as->level, as->src);
-            as = m->asmLines[i++];
           }
           if (!our_verbose)
               printf("%d records", i);
@@ -1318,6 +1618,33 @@ static void infoStack(context *ctxt)
 
 }
 
+/*-----------------------------------------------------------------*/
+/* cmdWhere -  where command                                       */
+/*-----------------------------------------------------------------*/
+int cmdWhere(char *s, context *cctxt)
+{
+       infoStack(cctxt);
+    showfull = 1;
+       return 0;
+}
+
+/*-----------------------------------------------------------------*/
+/* cmdUp -  Up command                                             */
+/*-----------------------------------------------------------------*/
+int cmdUp(char *s, context *cctxt)
+{
+       return 0;
+}
+
+/*-----------------------------------------------------------------*/
+/* cmdDown - down command                                          */
+/*-----------------------------------------------------------------*/
+int cmdDown(char *s, context *cctxt)
+{
+       return 0;
+}
+
+static int infomode = 0;
 /*-----------------------------------------------------------------*/
 /* cmdInfo - info command                                          */
 /*-----------------------------------------------------------------*/
@@ -1326,7 +1653,7 @@ int cmdInfo (char *s, context *cctxt)
     while (isspace(*s)) s++;
 
     /* list all break points */
-    if (strcmp(s,"break") == 0) {
+    if (strncmp(s,"break",5) == 0) {
        listUSERbp();
        return 0;
     }
@@ -1334,12 +1661,20 @@ int cmdInfo (char *s, context *cctxt)
     /* info frame same as frame */
     if (strcmp(s,"frame") == 0) {
        cmdFrame (s,cctxt);
+    showfull = 1;
+       return 0;
+    }
+
+    if (strncmp(s,"line",4) == 0) {
+    infomode=1;
+       cmdListSrc (s+4,cctxt);
        return 0;
     }
 
     /* info stack display call stack */
     if (strcmp(s,"stack") == 0) {
        infoStack(cctxt);
+    showfull = 1;
        return 0;
     }
 
@@ -1349,6 +1684,16 @@ int cmdInfo (char *s, context *cctxt)
        return 0;
     }
 
+    /* info stack display call stack */
+    if (strcmp(s,"all-registers") == 0) {
+       fprintf(stdout,"%s",simRegs());
+       fprintf(stdout,"Special Function Registers:\n");
+    sendSim("ds 0x80 0x100\n");
+    waitForSim(100,NULL);
+    fprintf(stdout,simResponse());
+       return 0;
+    }
+
     /* info stack display call stack */
     if (strcmp(s,"symbols") == 0) {
       /* dump out symbols we have read in */
@@ -1357,6 +1702,13 @@ int cmdInfo (char *s, context *cctxt)
       return 0;
     }
 
+    if (strcmp(s,"variables") == 0) {
+      /* dump out symbols we have read in */
+      fprintf(stdout,"Dumping symbols...\n");
+      infoSymbols(cctxt);
+      return 0;
+    }
+
     fprintf(stdout,"Undefined info command: \"%s\".  Try \"help\n",s);
     return 0;
 
@@ -1486,6 +1838,13 @@ int cmdListSrc (char *s, context *cctxt)
     
     if (llines > listLines) llines = listLines;
 
+    if ( infomode )
+    {
+           fprintf(stdout,"Line %d of \"%s\" starts at address 0x%08x.\n",pline,
+                   list_mod->c_name, list_mod->cLines[pline]->addr);
+        infomode=0;
+        return 0;
+    }
     for ( i = 0 ; i < llines ; i++ ) {
        if (srcMode == SRC_CMODE) {
            if ( (pline + i) >= list_mod->ncLines )
@@ -1503,6 +1862,51 @@ int cmdListSrc (char *s, context *cctxt)
     return 0;
 }
 
+static void setValBasic(symbol *sym, char *val)
+{
+    union 
+    {          
+        float f;     
+        unsigned long val;
+        long         sval;
+        struct {
+            short    lo;
+            short    hi;
+        } i;
+        unsigned char b[4];
+    }v;
+
+    if (IS_FLOAT(sym->type))   
+        v.f = strtof(val,NULL);    
+    else
+       if (IS_PTR(sym->type))
+           v.sval = strtol(val,NULL,0);
+       else
+    {
+           if (IS_SPEC(sym->type) && IS_INTEGRAL(sym->type)) 
+        {
+            if (IS_CHAR(sym->etype))
+            { 
+                v.b[0] = val[0];
+            }
+            else
+                if (IS_INT(sym->etype)) 
+                    if (IS_LONG(sym->etype))
+                        if (SPEC_USIGN(sym->etype))
+                            v.val = strtol(val,NULL,0);
+                        else
+                            v.sval = strtol(val,NULL,0);
+                    else
+                        v.i.lo = strtol(val,NULL,0);
+                else
+                    v.sval = strtol(val,NULL,0);
+           } 
+        else
+            v.sval = strtol(val,NULL,0);
+    }
+    simSetValue(sym->addr,sym->addrspace,sym->size,v.sval);    
+}
+
 /*-----------------------------------------------------------------*/
 /* printValBasic - print value of basic types                      */
 /*-----------------------------------------------------------------*/
@@ -1531,9 +1935,14 @@ static void printValBasic(symbol *sym,unsigned addr,char mem, int size)
            fprintf(stdout,"0x%x",v.val);
        else
            if (IS_SPEC(sym->type) && IS_INTEGRAL(sym->type)) {
-               if (IS_CHAR(sym->etype)) 
-                   fprintf(stdout,"'%c' %d 0x%x",v.val,v.val,v.val);
-               else
+               if (IS_CHAR(sym->etype))
+        { 
+                   if ( isprint(v.val))
+                fprintf(stdout,"%d 0x%x '%c'",v.val,v.val,v.val);
+            else
+                fprintf(stdout,"%d 0x%x '\\%o'",v.val,v.val,v.val);
+               }
+        else
                    if (IS_INT(sym->etype)) 
                        if (IS_LONG(sym->etype))
                            if (SPEC_USIGN(sym->etype))
@@ -1555,7 +1964,7 @@ static void printValBasic(symbol *sym,unsigned addr,char mem, int size)
 /*-----------------------------------------------------------------*/
 static void printValFunc (symbol *sym)
 {
-    fprintf(stdout,"print function not yet implemented\n");
+    fprintf(stdout,"print function not yet implemented");
 }
 
 /*-----------------------------------------------------------------*/
@@ -1578,7 +1987,7 @@ static void printArrayValue (symbol *sym, char space, unsigned int addr)
                        fprintf(stdout,",");
        }
 
-       fprintf(stdout,"}\n");          
+       fprintf(stdout,"}");            
 }
 
 /*-----------------------------------------------------------------*/
@@ -1599,7 +2008,7 @@ static void printStructValue (symbol *sym,link *type, char space, unsigned int a
                addr += getSize(fields->type);
                fields = fields->next;
        }
-       fprintf(stdout,"}\n");
+       fprintf(stdout,"}");
 }
 
 /*-----------------------------------------------------------------*/
@@ -1619,10 +2028,42 @@ static void printValAggregates (symbol *sym, link *type,char space,unsigned int
        } 
 }
 
+/*-----------------------------------------------------------------*/
+/* setSymValue - set     value of a symbol                         */
+/*-----------------------------------------------------------------*/
+static void setSymValue(symbol *sym, char *val, context *cctxt)
+{
+    if (sym->isonstack) 
+    {
+        symbol *bp = symLookup("bp",cctxt);
+        if (!bp) 
+        {
+            fprintf(stdout,"cannot determine stack frame\n");
+            return ;
+        }
+
+        sym->addr = simGetValue(bp->addr,bp->addrspace,bp->size)
+            + sym->offset ;      
+    }
+    /* arrays & structures first */
+    if (IS_AGGREGATE(sym->type))
+       {
+    }
+    else
+       /* functions */
+       if (IS_FUNC(sym->type))
+    {
+    }
+       else
+    {
+        setValBasic(sym,val);
+    }
+}
+
 /*-----------------------------------------------------------------*/
 /* printSymValue - print value of a symbol                         */
 /*-----------------------------------------------------------------*/
-static void printSymValue (symbol *sym, context *cctxt)
+static void printSymValue (symbol *sym, context *cctxt, int flg, int dnum)
 {
     static int stack = 1;
     unsigned long val;
@@ -1640,7 +2081,18 @@ static void printSymValue (symbol *sym, context *cctxt)
     
     /* get the value from the simulator and
        print it */
-    fprintf(stdout,"$%d = ",stack++);
+    switch (flg)
+    {
+        case 0: 
+        default:
+            break;
+        case 1: 
+            fprintf(stdout,"$%d = ",stack++);
+            break;
+        case 2: 
+            fprintf(stdout,"%d: %s = ",dnum,sym->name);
+            break;
+    }
     /* arrays & structures first */
     if (IS_AGGREGATE(sym->type))
        printValAggregates(sym,sym->type,sym->addrspace,sym->addr);
@@ -1648,11 +2100,11 @@ static void printSymValue (symbol *sym, context *cctxt)
        /* functions */
        if (IS_FUNC(sym->type))
            printValFunc(sym);
-       else {
+       else 
            printValBasic(sym,sym->addr,sym->addrspace,sym->size);
-           fprintf(stdout,"\n");
+    if ( flg > 0 ) fprintf(stdout,"\n");
            //fprintf(stdout,"(BASIC %x,%c,%d)\n",sym->addr,sym->addrspace,sym->size);
-       }
+       
 }
 
 /*-----------------------------------------------------------------*/
@@ -1770,7 +2222,7 @@ int cmdPrint (char *s, context *cctxt)
     *bp = '\0';
 
     if ((sym = symLookup(s,cctxt))) {
-       printSymValue(sym,cctxt);
+       printSymValue(sym,cctxt,1,0);
     } else {
        fprintf(stdout,
                "No symbol \"%s\" in current context.\n",              
@@ -1779,6 +2231,133 @@ int cmdPrint (char *s, context *cctxt)
     return 0;
 }
 
+/*-----------------------------------------------------------------*/
+/* cmdOutput - print value of variable without number and newline  */
+/*-----------------------------------------------------------------*/
+int cmdOutput (char *s, context *cctxt)
+{   
+    symbol *sym ;
+    char *bp = s+strlen(s) -1;
+
+    while (isspace(*s)) s++;
+    if (!*s) return 0;
+    while (isspace(*bp)) bp--;
+    bp++ ;
+    *bp = '\0';
+
+    if ((sym = symLookup(s,cctxt))) {
+       printSymValue(sym,cctxt,0,0);
+    } else {
+       fprintf(stdout,
+               "No symbol \"%s\" in current context.",        
+               s);
+    }
+    return 0;
+}
+
+typedef struct _dsymbol
+{
+    char *name;
+    int  dnum;
+} dsymbol;
+
+/** find display entry with this number */
+
+DEFSETFUNC(dsymWithNumber)
+{
+    dsymbol *dsym = item;
+    V_ARG(int , dnum);
+    V_ARG(dsymbol **,dsymp);
+
+    if ( dsym->dnum == dnum )
+    {
+        *dsymp = dsym;
+        return 1;
+    }
+    return 0;
+}
+
+/*-----------------------------------------------------------------*/
+/* displayAll  - display all valid variables                       */
+/*-----------------------------------------------------------------*/
+void displayAll(context *cctxt)
+{
+    dsymbol *dsym;
+    symbol  *sym;
+    if ( !dispsymbols )
+        return;
+    for (dsym = setFirstItem(dispsymbols);
+         dsym ;
+         dsym = setNextItem(dispsymbols)) 
+    {
+        if ( (sym = symLookup(dsym->name,cctxt)))
+            printSymValue(sym,cctxt,2,dsym->dnum);            
+    }
+}
+
+/*-----------------------------------------------------------------*/
+/* cmdDisplay  - display value of variable                         */
+/*-----------------------------------------------------------------*/
+int cmdDisplay (char *s, context *cctxt)
+{   
+    symbol *sym ;
+    char *bp = s+strlen(s) -1;
+    static int dnum = 1;
+
+    while (isspace(*s)) s++;
+    if (!*s)
+    {
+        displayAll(cctxt);
+        return 0;
+    }
+    while (isspace(*bp)) bp--;
+    bp++ ;
+    *bp = '\0';
+
+    if ((sym = symLookup(s,cctxt))) 
+    {
+        dsymbol *dsym = (dsymbol *)Safe_calloc(1,sizeof(dsymbol));
+        dsym->dnum = dnum++ ;
+        dsym->name = sym->name;
+        addSetHead(&dispsymbols,dsym);
+    }
+    else
+    {
+        fprintf(stdout,"No symbol \"%s\" in current context.\n",              
+                s);
+    }
+    return 0;
+}
+
+/*-----------------------------------------------------------------*/
+/* cmdUnDisplay  - undisplay value of variable                              */
+/*-----------------------------------------------------------------*/
+int cmdUnDisplay (char *s, context *cctxt)
+{   
+    dsymbol *dsym;
+    int dnum;
+
+    while (isspace(*s)) s++;
+    if (!*s)
+    {
+        deleteSet(&dispsymbols);
+        return 0;
+    }
+    while ( s && *s )
+    {
+        dnum = strtol(s,&s,10);
+        if (applyToSetFTrue(dispsymbols,dsymWithNumber,dnum,&dsym)) 
+        {
+            deleteSetItem(&dispsymbols,dsym);
+        } 
+        else
+        {
+            fprintf(stdout,"Arguments must be display numbers.\n");    
+        }
+    }
+    return 0;
+}
+
 /*-----------------------------------------------------------------*/
 /* cmdPrintType - print type of a variable                         */
 /*-----------------------------------------------------------------*/
index 9d4c7602ebd1ef4d942004e9f499e714315a3069..b010d54d62b65f36d028823de61f7b4370b3cc31 100644 (file)
@@ -45,6 +45,16 @@ extern int cmdInfo      (char *, context *);
 extern int cmdShow      (char *, context *);
 extern int cmdFinish    (char *, context *);
 
+extern int cmdUp        (char *, context *);
+extern int cmdDown      (char *, context *);
+extern int cmdWhere     (char *, context *);
+extern int cmdOutput    (char *, context *);
+extern int cmdDisasm1   (char *, context *);
+extern int cmdDisasmF   (char *, context *);
+extern int cmdDisplay   (char *, context *);
+extern int cmdUnDisplay (char *, context *);
+extern void displayAll  (context *);
+
 extern int cmdListModules (char *s, context *cctxt);
 extern int cmdListFunctions (char *s, context *cctxt);
 extern int cmdListSymbols (char *s, context *cctxt);
index 53a1a38cf253044b872a34211ed4e932213a4a65..a5b77d5df18bd829d45a4d41649ed7427dc3f74a 100644 (file)
@@ -39,6 +39,8 @@ int nLinkrecs = 0;
 linkrec **linkrecs = NULL; /* all linkage editor records */
 context *currCtxt = NULL;
 short fullname = 0;
+short showfull = 0;
+short userinterrupt = 0;
 char *ssdirl = DATADIR LIB_DIR_SUFFIX ":" DATADIR LIB_DIR_SUFFIX "/small" ;
 char *simArgs[40];
 int nsimArgs = 0;
@@ -75,19 +77,20 @@ struct cmdtab
     },
     { "c"        ,  cmdContinue   , NULL },
 
+    { "disassemble",cmdDisasmF    , "x disassemble asm commands\n" },
     { "delete" ,  cmdDelUserBp  ,
       "{d}elete n\t\t clears break point number n\n"
     },
-    { "d"        ,  cmdDelUserBp  , NULL },
-
-    { "help"     ,  cmdHelp       ,
-      "{h|?}elp\t\t this message\n"
+    { "display"    ,  cmdDisplay     ,
+      "display [<variable>]\t print value of given variable each time the program stops\n"
     },
-    { "?"        ,  cmdHelp       , NULL },
-    { "h"        ,  cmdHelp       , NULL },
+    { "undisplay"  ,  cmdUnDisplay   ,
+      "undisplay [<variable>]\t dont display this variable or all\n"
+    },
+    { "d"        ,  cmdDelUserBp  , NULL },
 
     { "info"     ,  cmdInfo       ,
-      "info <break stack frame registers>\n"
+      "info <break stack frame registers all-registers>\n"
       "\t list all break points, call-stack, frame or register information\n"
     },
 
@@ -106,7 +109,7 @@ struct cmdtab
       "show"
       " <copying warranty>\t copying & distribution terms, warranty\n"
     },
-    { "set"      ,  cmdSetOption  , "set <srcmode>\t\t toggle between c/asm.\n" },
+    { "set"      ,  cmdSetOption  , "set <srcmode>\t\t toggle between c/asm.\nset variable <var> = >value\t\tset variable to new value\n" },
     { "step"     ,  cmdStep       ,
       "{s}tep\t\t\t Step program until it reaches a different source line.\n"
     },
@@ -126,6 +129,9 @@ struct cmdtab
     { "print"    ,  cmdPrint      ,
       "{p}rint <variable>\t print value of given variable\n"
     },
+    { "output"   ,  cmdOutput      ,
+      "output <variable>\t print value of given variable without $ and newline \n"
+    },
     { "p"        ,  cmdPrint      , NULL },
     { "file"     ,  cmdFile       ,
       "file <filename>\t\t load symbolic information from <filename>\n"
@@ -137,14 +143,22 @@ struct cmdtab
       "{fi}nish\t\t execute till return of current function\n"
     },
     { "fi"       ,  cmdFinish     , NULL },
+    { "where"    ,  cmdWhere      , "where\t\t\t print stack\n" },
     { "fr"       ,  cmdFrame      , NULL },
     { "f"        ,  cmdFrame      , NULL },
+    { "x /i"     ,  cmdDisasm1    , "x\t\t disassemble one asm command\n" },
     { "!"        ,  cmdSimulator  ,
       "!<simulator command>\t send a command directly to the simulator\n"
     },
     { "."        ,  cmdSimulator  ,
       ".{cmd}\t switch from simulator or debugger command mode\n"
     },
+    { "help"     ,  cmdHelp       ,
+      "{h|?}elp\t [CMD_NAME | 0,1,2,3(help page)] (general help or specific help)\n"
+    },
+    { "?"        ,  cmdHelp       , NULL },
+    { "h"        ,  cmdHelp       , NULL },
+
     { "quit"     ,  cmdQuit       ,
       "{q}uit\t\t\t \"Watch me now. Iam going Down. My name is Bobby Brown\"\n"
     },
@@ -581,7 +595,8 @@ int cmdFile (char *s,context *cctxt)
     functionPoints();
 
     /* start the simulator & setup connection to it */
-    openSimulator((char **)simArgs,nsimArgs);
+    if ( sock == -1 )
+        openSimulator((char **)simArgs,nsimArgs);
     fprintf(stdout,"%s",simResponse());
     /* now send the filename to be loaded to the simulator */
     sprintf(buffer,"%s.ihx",s);
@@ -614,6 +629,15 @@ int cmdHelp (char *s, context *cctxt)
       if (endline > 0)
         startline = endline - 20;
     }
+    else if (*s)
+    {
+        for (i = 0 ; i < (sizeof(cmdTab)/sizeof(struct cmdtab)) ; i++) 
+        {
+            if ((cmdTab[i].htxt) && !strcmp(cmdTab[i].cmd,s))
+                fprintf(stdout,"%s",cmdTab[i].htxt);             
+        }
+        return 0;
+    }
 
     for (i = 0 ; i < (sizeof(cmdTab)/sizeof(struct cmdtab)) ; i++) {
 
@@ -693,15 +717,17 @@ int interpretCmd (char *s)
         rv = (*cmdTab[i].cmdfunc)(s + strlen(cmdTab[i].cmd),currCtxt);
 
         /* if full name then give the file name & position */
-        if (fullname && currCtxt && currCtxt->func) {
+        if (fullname && showfull && currCtxt && currCtxt->func) {
+          showfull = 0;
           if (srcMode == SRC_CMODE)
-            fprintf(stdout,"\032\032%s:%d:1\n",
+            fprintf(stdout,"\032\032%s:%d:1:beg:0x%08x\n",
                     currCtxt->func->mod->cfullname,
-                    currCtxt->cline+1);
+                    currCtxt->cline,currCtxt->addr);
           else
-            fprintf(stdout,"\032\032%s:%d:1\n",
+            fprintf(stdout,"\032\032%s:%d:1:beg:0x%08x\n",
                     currCtxt->func->mod->afullname,
-                    currCtxt->asmline+1);
+                    currCtxt->asmline,currCtxt->addr);
+          displayAll(currCtxt);
         }
         goto ret;
       }
@@ -874,6 +900,53 @@ static void parseCmdLine (int argc, char **argv)
   cmdFile(filename,NULL);
 }
 
+/*-----------------------------------------------------------------*/
+/* setsignals -  catch some signals                                */
+/*-----------------------------------------------------------------*/
+#include <signal.h>
+static void
+bad_signal(int sig)
+{
+    if ( simactive )
+        closeSimulator();
+    exit(1);
+}
+
+static void
+sigintr(int sig)
+{
+    /* may be interrupt from user: stop debugger ( also simulator ??) */
+    userinterrupt = 1;
+}
+
+/* the only child can be the simulator */
+static void sigchld(int sig)
+{
+    /* the only child can be the simulator */
+    int status, retpid;
+    retpid = wait ( &status );
+    /* if ( retpid == simPid ) */
+    simactive = 0;
+}
+
+static void
+setsignals()
+{
+    signal(SIGHUP , bad_signal);               
+    signal(SIGINT , sigintr ); 
+    signal(SIGTERM, bad_signal);       
+    signal(SIGCHLD, sigchld );
+
+    signal(SIGPIPE, SIG_IGN);
+    signal(SIGABRT, bad_signal);
+    signal(SIGALRM, bad_signal);
+    signal(SIGFPE,  bad_signal);
+    signal(SIGILL,  bad_signal);
+    signal(SIGPIPE, bad_signal);
+    signal(SIGQUIT, bad_signal);
+    signal(SIGSEGV, bad_signal);
+}
+
 /*-----------------------------------------------------------------*/
 /* main -                                                          */
 /*-----------------------------------------------------------------*/
@@ -888,6 +961,7 @@ int main ( int argc, char **argv)
     simArgs[nsimArgs++] = "-r 9756";
     /* parse command line */
 
+    setsignals();
     parseCmdLine(argc,argv);
 
     commandLoop();
index 9a3c1d58c55ef887323f8ad3f57492ee7ca50048..586aa2cfa093d2be31b1fc7d734c33dc68b4aa55 100644 (file)
@@ -226,6 +226,9 @@ extern set *modules  ; /* set of modules   */
 extern set *functions; /* set of functions */
 extern set *symbols  ; /* set of symbols */
 
+extern char *currModName ;
+extern short userinterrupt ;
+extern short showfull ;
 extern int nStructs ;
 extern struct structdef **structs ; /* all structures */
 extern char *ssdirl; /* source directory search path */
index 55836bedc154b591c6c5de7b988d9d939c0863ee..8da959c34a0c48a6e5911e1c0d73a81844d82750 100644 (file)
@@ -37,7 +37,7 @@
 FILE *simin ; /* stream for simulator input */
 FILE *simout; /* stream for simulator output */
 
-int sock ; /* socket descriptor to comm with simulator */
+int sock = -1; /* socket descriptor to comm with simulator */
 pid_t simPid;
 static char simibuff[MAX_SIM_BUFF];    /* sim buffer       */
 static char regBuff[MAX_SIM_BUFF];
@@ -63,7 +63,7 @@ Dprintf(D_simi, ("waitForSim start(%d)\n", timeout_ms));
 
     // MS_SLEEP(timeout_ms); dont need, in blocking mode.
 
-    while ((ch = fgetc(simin))) {
+    while ((ch = fgetc(simin)) > 0 ) {
       *sbp++ = ch;
     }
     *sbp = 0;
@@ -180,11 +180,67 @@ char *simResponse()
 /*-----------------------------------------------------------------*/
 void sendSim(char *s)
 {
+    if ( ! simout ) 
+        return;
+
     Dprintf(D_simi, ("sendSim-->%s", s));  // s has LF at end already
     fputs(s,simout);
     fflush(simout);
 }
 
+int simSetValue (unsigned int addr,char mem, int size, unsigned long val)
+{
+    char buffer[40], *s,*prefix;
+    int i;
+    switch (mem) 
+    {
+        case 'A':
+            prefix = "x";
+            break;
+        case 'B':       
+            prefix = "i";
+            break;
+        case 'C':
+        case 'D':
+            prefix = "c";
+            break;
+        case 'E':
+        case 'G':
+            prefix = "i";
+            break;
+        case 'F':
+            prefix = "x";
+            break;
+        case 'H':
+            prefix = "bit" ;
+            break;
+        case 'I':
+            prefix = "sfr" ;
+            break;
+        case 'J':
+            prefix = "sbit" ;
+            break;
+        case 'R':
+            return; /* set registers !! */
+            //prefix = "i" ;
+            break;
+        default:
+            return;
+    }
+    sprintf(buffer,"set mem %s 0x%x",prefix,addr);
+    s = buffer + strlen(buffer);
+    for ( i = 0 ; i < size ; i++ )
+    {
+        sprintf(s," 0x%x", val & 0xff);
+        s += strlen(s);
+        val >>= 8;
+    }
+    sprintf(s,"\n");
+    sendSim(buffer);
+    waitForSim(100,NULL);
+    simResponse();   
+}
+
 /*-----------------------------------------------------------------*/
 /* simGetValue - get value @ address for mem space                 */
 /*-----------------------------------------------------------------*/
@@ -205,7 +261,7 @@ unsigned long simGetValue (unsigned int addr,char mem, int size)
       break;
     case 'C':
     case 'D':
-       prefix = "dch";
+    prefix = "dch";
        break;
     case 'E':
     case 'G':
@@ -221,7 +277,13 @@ unsigned long simGetValue (unsigned int addr,char mem, int size)
        break;
     case 'I':
        prefix = "ds" ;
-       break;  
+       break;
+    case 'R':
+       prefix = "i r" ;
+       break;
+    default:
+       prefix = "dump" ;
+       break;
     }
     
     /* create the simulator command */
@@ -244,6 +306,17 @@ unsigned long simGetValue (unsigned int addr,char mem, int size)
     /* then make the branch for bit variables */
     /* skip thru the address part */
     while (isxdigit(*resp)) resp++;
+
+    if (!strcmp(prefix,"i r")) 
+    {
+        /* skip registers */
+        for (i = 0 ; i < addr ; i++ ) 
+        {
+            while (isspace(*resp)) resp++ ;
+            /* skip */
+            while (isxdigit(*resp)) resp++;
+        }
+       }
     
     if (!strcmp(prefix,"dump")) {
 
@@ -427,10 +500,11 @@ char  *simRegs()
          
     resp  = simResponse();
 
+#if 0
     return resp;
 
-#if 0
-  Take this out(2-09-02) cant see as its that useful to reformat, karl.
+#else
+    /*Take this out(2-09-02) cant see as its that useful to reformat, karl.*/
   
     /* the response is of the form 
        XXXXXX R0 R1 R2 R3 R4 R5 R6 R7 ........
@@ -507,12 +581,18 @@ F  0x006d 75 87 80 MOV   PCON,#80
 /*-----------------------------------------------------------------*/
 void closeSimulator ()
 {
-
+    if ( ! simin || ! simout || sock == -1 )
+    {
+        simactive = 0;
+        return;
+    }
     sendSim("q\n");
     kill (simPid,SIGKILL);
     fclose (simin);
     fclose (simout);
     shutdown(sock,2);   
     close(sock);    
-    
+    sock = -1;
 }
+
+
index a8c6751dd41cf6dc4aa953f9585eb0163d913537..05ace69a043330242fe9c613fb66c1bd598a2f01 100644 (file)
@@ -27,6 +27,7 @@
 
 #define MAX_SIM_BUFF 8*1024
 //#define SIMNAME "s51"
+extern int sock;
 extern char simactive;
 void  openSimulator (char **,int);
 void waitForSim(int timeout_ms, char *expect);
@@ -40,5 +41,5 @@ void  simReset ();
 char  *simRegs() ;
 unsigned int simGoTillBp (unsigned int);
 unsigned long simGetValue (unsigned int ,char , int );
-
+int simSetValue (unsigned int ,char , int, unsigned long );
 #endif
index 1305cc3ee8f610f8b2bbc8a5fdc982db4e98997d..75fac2345b4dfe145ec340b5e12aa80da4472045 100644 (file)
@@ -25,7 +25,6 @@
 #include "symtab.h"
 #include "newalloc.h"
 
-extern char *currModName ;
 structdef *structWithName (char *);
 
 /*------------------------------------------------------------------*/
@@ -281,8 +280,20 @@ symbol *parseSymbol (char *s, char **rs)
     /* get the stack offset */
     s++;
     nsym->offset = strtol(s,&s,10);
-    *rs = s;
 
+    if ( nsym->addrspace == 'R' )
+    {
+        /* get registeroffset */
+        while (*s && *s != '[') s++ ;
+        s++ ;
+        if ( *s == 'r' )
+        {
+            nsym->addr = strtol(s+1,&s,10);
+        }
+        while (*s && *s != ']') s++ ;
+    }
+
+    *rs = s;
     addSet(&symbols,nsym);
 
     return nsym;