static void printTypeInfo(link *);
static void printValAggregates (symbol *,link *,char,unsigned int,int);
-static void printOrSetSymValue (symbol *sym, context *cctxt,
- int flg, int dnum, int fmt, char *rs, char *val);
+static int printOrSetSymValue (symbol *sym, context *cctxt,
+ int flg, int dnum, int fmt,
+ char *rs, char *val, char cmp);
int srcMode = SRC_CMODE ;
static set *dispsymbols = NULL ; /* set of displayable symbols */
unsigned int addr ;
context *ctxt;
int rv;
-
+ stopCommandList();
top:
if ( userinterrupt )
{
/* if current context is known */
if (cctxt->func) {
+ Dprintf(D_break, ("commonSetUserBp: a) cctxtaddr:%x \n",cctxt->addr));
if (srcMode == SRC_CMODE)
/* set the break point */
setBreakPoint ( cctxt->addr , CODE , bpType , userBpCB ,
}
else
{
+ Dprintf(D_break, ("commonSetUserBp: g) addr:%x \n",braddr));
setBreakPoint ( braddr , CODE , bpType , userBpCB ,
modul->c_name,line);
}
}
/* case b) lineno */
/* check if line number */
- if (isdigit(*s)) {
+ if ( !strchr(s,':') && isdigit(*s)) {
/* get the lineno */
int line = atoi(s) -1;
+ Dprintf(D_break, ("commonSetUserBp: b) line:%d \n",line));
/* if current context not present then we must get the module
which has main & set the break point @ line number provided
}
/* case c) filename:lineno */
- if (isdigit(*(bp +1))) {
-
+ if (isdigit(*(bp +1))) {
+ Dprintf(D_break, ("commonSetUserBp: c) line:%d \n",atoi(bp+1)));
setBPatModLine (mod,atoi(bp+1)-1,bpType);
goto ret;
if (!applyToSet(functions,funcWithNameModule,bp+1,s,&func))
fprintf(stderr,"Function \"%s\" not defined.\n",bp+1);
else
+ Dprintf(D_break, ("commonSetUserBp: d) \n"));
setBPatModLine (mod,
(srcMode == SRC_CMODE ?
func->entryline :
}
/* case e) function */
+ Dprintf(D_break, ("commonSetUserBp: e) \n"));
if (!applyToSet(functions,funcWithName,s,&func))
fprintf(stderr,"Function \"%s\" not defined.\n",s);
else
while (isspace(*s)) *s++ = '\0';
if (*s)
{
- printOrSetSymValue(sym,cctxt,0,0,0,rs,s);
+ printOrSetSymValue(sym,cctxt,0,0,0,rs,s,'\0');
return 0;
}
else
return 0;
}
+/*-----------------------------------------------------------------*/
+/* cmdIgnore - set ignorecount for breakpoint */
+/*-----------------------------------------------------------------*/
+int cmdIgnore (char *s, context *cctxt)
+{
+ int bpnum, cnt ;
+ while (isspace(*s)) s++;
+ if (!*s )
+ {
+ fprintf(stdout,"Argument required (breakpoint number).\n");
+ return 0;
+ }
+ bpnum = strtol(s,&s,10);
+ while (isspace(*s)) s++;
+ if (!*s )
+ {
+ fprintf(stdout,"Second argument (specified ignore-count) is missing.");
+ return 0;
+ }
+ cnt = strtol(s,0,10);
+ setUserbpIgnCount(bpnum,cnt);
+ return 0;
+}
+
+/*-----------------------------------------------------------------*/
+/* cmdCondition - set condition for breakpoint */
+/*-----------------------------------------------------------------*/
+int cmdCondition (char *s, context *cctxt)
+{
+ int bpnum ;
+ while (isspace(*s)) s++;
+ if (!*s )
+ {
+ fprintf(stdout,"Argument required (breakpoint number).\n");
+ return 0;
+ }
+ bpnum = strtol(s,&s,10);
+ while (isspace(*s)) s++;
+ if (*s)
+ s = Safe_strdup(s);
+ else
+ s = NULL;
+ setUserbpCondition(bpnum,s);
+ return 0;
+}
+
/*-----------------------------------------------------------------*/
/* cmdCommands - set commands for breakpoint */
/*-----------------------------------------------------------------*/
fprintf(stdout,"No executable file specified.\nUse the \"file\" command.\n");
return 0;
}
+ resetHitCount();
simGo(0);
} else {
fgets(buff,sizeof(buff),stdin);
if (toupper(buff[0]) == 'Y') {
simReset();
+ resetHitCount();
simGo(0);
}
}
return 0;
}
-static void setValBasic(symbol *sym, link *type,
- char mem, unsigned addr,int size, char *val)
+static unsigned long getValBasic(symbol *sym, link *type, char *val)
{
char *s;
union
}v;
if (IS_FLOAT(type))
- v.f = strtof(val,NULL);
+ v.f = strtod(val,NULL);
else
if (IS_PTR(type))
v.val = strtol(val,NULL,0);
else
v.val = strtol(val,NULL,0);
}
- simSetValue(addr,mem,size,v.val);
+ return v.val;
}
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/* printOrSetSymValue - print or set value of a symbol */
/*-----------------------------------------------------------------*/
-static void printOrSetSymValue (symbol *sym, context *cctxt,
- int flg, int dnum, int fmt, char *rs, char *val)
+static int printOrSetSymValue (symbol *sym, context *cctxt,
+ int flg, int dnum, int fmt, char *rs,
+ char *val, char cmp )
{
static char fmtChar[] = " todx ";
static int stack = 1;
if (!bp)
{
fprintf(stdout,"cannot determine stack frame\n");
- return ;
+ return 1;
}
sym->addr = simGetValue(bp->addr,bp->addrspace,bp->size)
*s2 = save_ch2;
if ( ! fields )
{
- fprintf(stdout,"Unkown variable \"%s\" for index.\n", s);
- return;
+ fprintf(stdout,"Unknown variable \"%s\" for index.\n", s);
+ return 1;
}
/* arrays & structures first */
if (! IS_INTEGRAL(fields->type))
{
fprintf(stdout,"Wrong type of variable \"%s\" for index \n", s);
- return;
+ return 1;
}
n = simGetValue(fields->addr,fields->addrspace,getSize(fields->type));
}
if ( n < 0 || n >= DCL_ELEM(type))
{
fprintf(stdout,"Wrong index %d.\n", n);
- return;
+ return 1;
}
type = type->next;
size = getSize(type);
if ( ! fields )
{
fprintf(stdout,"Unknown field \"%s\" of structure\n", s);
- return;
+ return 1;
}
type = fields->type;
size = getSize(type);
if (IS_AGGREGATE(type))
{
if ( val )
- fprintf(stdout,"Cannot set aggregate variable\n");
+ {
+ fprintf(stdout,"Cannot set/compare aggregate variable\n");
+ return 1;
+ }
else
printValAggregates(sym,type,sym->addrspace,addr,fmt);
}
{
if ( !val )
printValFunc(sym,fmt);
+ else
+ return 1;
}
else
{
if ( val )
- setValBasic (sym,type,sym->addrspace,addr,size,val);
+ {
+ unsigned long newval;
+ newval = getValBasic(sym,type,val);
+
+ if ( cmp )
+ {
+ unsigned long lval;
+ lval = simGetValue(addr,sym->addrspace,size);
+ switch ( cmp )
+ {
+ case '<' : return ( lval < newval ? 1:0 ); break;
+ case '>' : return ( lval > newval ? 1:0 ); break;
+ case 'l' : return ( lval <= newval ? 1:0 ); break;
+ case 'g' : return ( lval >= newval ? 1:0 ); break;
+ case '=' : return ( lval == newval ? 1:0 ); break;
+ case '!' : return ( lval != newval ? 1:0 ); break;
+ }
+ }
+ else
+ {
+ simSetValue(addr,sym->addrspace,size,newval);
+ return 1;
+ }
+ }
else
printValBasic(sym,type,sym->addrspace,addr,size,fmt);
}
if ( flg > 0 ) fprintf(stdout,"\n");
-
+ return 0;
}
/*-----------------------------------------------------------------*/
}
}
+/*-----------------------------------------------------------------*/
+/* conditionIsTrue - compare variable with constant value */
+/*-----------------------------------------------------------------*/
+int conditionIsTrue( char *s, context *cctxt)
+{
+ symbol *sym = NULL;
+ int fmt;
+ char *rs, *dup, cmp_char;
+ dup = s = Safe_strdup(s);
+ if ( !( rs = preparePrint(s, cctxt, &fmt, &sym )) || !sym)
+ fmt = 1;
+ else if (!( s = strpbrk(rs,"<>=!")))
+ fmt = 1;
+ else
+ {
+ cmp_char = *s;
+ *s++ = '\0';
+ if ( *s == '=' )
+ {
+ /* if <= or >= an other char is used
+ * == or != not checked in switch
+ */
+ switch( cmp_char )
+ {
+ case '>': cmp_char = 'g' ; break;
+ case '<': cmp_char = 'l' ; break;
+ }
+ s++ ;
+ }
+ while (isspace(*s)) *s++ = '\0';
+ fmt = printOrSetSymValue(sym,cctxt,0,0,0,rs,s,cmp_char);
+ }
+ Safe_free(dup);
+ return fmt;
+}
+
/*-----------------------------------------------------------------*/
/* cmdPrint - print value of variable */
/*-----------------------------------------------------------------*/
if ( sym )
{
- printOrSetSymValue(sym,cctxt,1,0,fmt,rs,NULL);
+ printOrSetSymValue(sym,cctxt,1,0,fmt,rs,NULL,'\0');
}
return 0;
}
if ( sym )
{
- printOrSetSymValue(sym,cctxt,0,0,fmt,rs,NULL);
+ printOrSetSymValue(sym,cctxt,0,0,fmt,rs,NULL,'\0');
}
return 0;
}
dsym = setNextItem(dispsymbols))
{
if ( (sym = symLookup(dsym->name,cctxt)))
- printOrSetSymValue(sym,cctxt,2,dsym->dnum,dsym->fmt,dsym->rs,NULL);
+ printOrSetSymValue(sym,cctxt,2,dsym->dnum,dsym->fmt,
+ dsym->rs,NULL,'\0');
}
}