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 */
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 */
/*-----------------------------------------------------------------*/
V_ARG(function **,funcp);
if (*funcp)
- return 0;
+ return 0;
if (strcmp(func->sym->name,fname) == 0 &&
strcmp(func->mod->c_name,mname) == 0) {
}
+/*-----------------------------------------------------------------*/
+/* 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,
static int initial_break_flag = 0;
top:
+ if ( userinterrupt )
+ {
+ userinterrupt = 0;
+ return;
+ }
addr = simGoTillBp (gaddr);
/* got the pc for the break point now first
/* dispatch all the break point call back functions */
rv = dispatchCB (addr,ctxt);
-
ret:
/* the dispatch call back function will return
}
+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 */
/*-----------------------------------------------------------------*/
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) {
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)) {
/*-----------------------------------------------------------------*/
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;
}
(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;
}
fprintf(stdout,"Continuing.\n");
simGo(-1);
+ showfull = 1;
return 0;
}
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... */
}
}
+ srcMode = origSrcMode;
simGo(-1);
+ showfull = 1;
}
return 0;
}
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
func->aexitline);
}
}
+ srcMode = origSrcMode;
simGo(-1);
+ showfull = 1;
}
+ srcMode = origSrcMode;
}
return 0;
}
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 {
simGo(0);
}
}
-
+ showfull = 1;
return 0;
}
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",
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);
}
+/*-----------------------------------------------------------------*/
+/* 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 */
/*-----------------------------------------------------------------*/
while (isspace(*s)) s++;
/* list all break points */
- if (strcmp(s,"break") == 0) {
+ if (strncmp(s,"break",5) == 0) {
listUSERbp();
return 0;
}
/* 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;
}
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 */
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;
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 )
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 */
/*-----------------------------------------------------------------*/
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))
/*-----------------------------------------------------------------*/
static void printValFunc (symbol *sym)
{
- fprintf(stdout,"print function not yet implemented\n");
+ fprintf(stdout,"print function not yet implemented");
}
/*-----------------------------------------------------------------*/
fprintf(stdout,",");
}
- fprintf(stdout,"}\n");
+ fprintf(stdout,"}");
}
/*-----------------------------------------------------------------*/
addr += getSize(fields->type);
fields = fields->next;
}
- fprintf(stdout,"}\n");
+ fprintf(stdout,"}");
}
/*-----------------------------------------------------------------*/
}
}
+/*-----------------------------------------------------------------*/
+/* 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;
/* 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);
/* 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);
- }
+
}
/*-----------------------------------------------------------------*/
*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",
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 */
/*-----------------------------------------------------------------*/
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;
},
{ "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"
},
"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"
},
{ "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"
"{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"
},
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);
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++) {
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;
}
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 - */
/*-----------------------------------------------------------------*/
simArgs[nsimArgs++] = "-r 9756";
/* parse command line */
+ setsignals();
parseCmdLine(argc,argv);
commandLoop();