#include "sdcdb.h"
#include "symtab.h"
+#include "newalloc.h"
-extern char *currModName ;
structdef *structWithName (char *);
/*------------------------------------------------------------------*/
function *func ;
char *rs;
int i;
- Safe_calloc(1,func,sizeof(function));
+ func = Safe_calloc(1,sizeof(function));
func->sym = parseSymbol(line,&rs);
func->sym->isfunc = 1;
func->modName = currModName ;
s = ++bp;
while (*s != ')') { /* till we reach the end */
link *type;
- Safe_calloc(1,type,sizeof(link));
+ type = Safe_calloc(1,sizeof(link));
if (*s == ',') s++;
/* is a declarator */
symbol *nsym ;
char *bp = s;
- Safe_calloc(1,nsym,sizeof(symbol));
+ nsym = Safe_calloc(1,sizeof(symbol));
/* copy over the mangled name */
while (*bp != '(') bp++;
/* 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;
module *nmod ;
char buffer[512];
- Safe_calloc(1,nmod,sizeof(module));
+ nmod = Safe_calloc(1,sizeof(module));
addSet (&modules,nmod);
if (createName) {
sprintf(buffer,"%s.c",s);
- Safe_calloc(1,nmod->c_name,strlen(buffer)+1);
+ nmod->c_name = Safe_malloc(strlen(buffer)+1);
strcpy(nmod->c_name,buffer);
sprintf(buffer,"%s.asm",s);
- Safe_calloc(1,nmod->asm_name,strlen(buffer)+1);
+ nmod->asm_name = Safe_malloc(strlen(buffer)+1);
strcpy(nmod->asm_name,buffer);
}
return structs[i];
}
- Safe_calloc(1,nsdef,sizeof(structdef));
+ nsdef = Safe_calloc(1,sizeof(structdef));
nsdef->tag = alloccpy(s,strlen(s));
nsdef->sname = currModName ;
{
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;
s++;
sscanf(s,"%x",&func->sym->eaddr);
-#ifdef SDCDB_DEBUG
- printf("%s(eaddr%x)\n",func->sym->name,func->sym->eaddr);
-#endif
+
+ Dprintf(D_symtab, ("%s(eaddr%x)\n",func->sym->name,func->sym->eaddr));
}
/*-----------------------------------------------------------------*/
s++;
sscanf(s,"%x",&sym->addr);
-#ifdef SDCDB_DEBUG
- printf("%s(%x)\n",sym->name,sym->addr);
-#endif
+
+ Dprintf(D_symtab, ("%s(%x)\n",sym->name,sym->addr));
}
/*-----------------------------------------------------------------*/
line--;
if (line < mod->nasmLines) {
mod->asmLines[line]->addr = addr;
-#ifdef SDCDB_DEBUG
- printf("%s(%d:%x) %s",mod->asm_name,line,addr,mod->asmLines[line]->src);
-#endif
+ Dprintf(D_symtab, ("%s(%d:%x) %s",mod->asm_name,line,addr,mod->asmLines[line]->src));
}
}
mod->cLines[line]->addr = addr;
mod->cLines[line]->block = block;
mod->cLines[line]->level = level;
-#ifdef SDCDB_DEBUG
- printf("%s(%d:%x) %s",mod->c_name,
- line+1,addr,mod->cLines[line]->src);
-#endif
+ Dprintf(D_symtab, ("%s(%d:%x) %s",mod->c_name,
+ line+1,addr,mod->cLines[line]->src));
}
return;