sdcdb updates,ddd
[fw/sdcc] / debugger / mcs51 / symtab.c
index 5a1c1bb7bd6fa72103ad65c469ab7a3bdadb702c..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;
@@ -544,27 +555,33 @@ symbol *symLookup (char *name, context *ctxt)
 {
     symbol *sym = NULL ;
 
-    /* first try & find a local variable for the
-       given name */
-    if ( applyToSet(symbols,symLocal,
+    if ((ctxt) && (ctxt->func) &&
+        (ctxt->func->sym) && (ctxt->func->sym->name)) {
+      /* first try & find a local variable for the given name */
+      if ( applyToSet(symbols,symLocal,
         name,
         ctxt->func->sym->name,
         ctxt->block,
         ctxt->level,
         &sym))
-  return sym;
+         return sym;
+      sym = NULL;
+    }
+
+    if ((ctxt) && (ctxt->func) &&
+        (ctxt->func->mod) && (ctxt->func->mod->name)) {
+      /* then try local to this module */
+      if (applyToSet(symbols,symLocal,
+          name,
+          ctxt->func->mod->name,
+          0,0,&sym))
+             return sym;
+      sym = NULL;
+    }
 
-    sym = NULL;
-    /* then try local to this module */
-    if (applyToSet(symbols,symLocal,
-       name,
-       ctxt->func->mod->name,
-       0,0,&sym))
-  return sym;
-    sym = NULL;
     /* no:: try global */
     if ( applyToSet(symbols,symGlobal,name,&sym))
-  return sym;
+      return sym;
 
     /* cannot find return null */
     return NULL;