From 274f997bf808d919e31605700ff8ce4b1a0c5a7c Mon Sep 17 00:00:00 2001 From: kbongers Date: Wed, 28 May 2003 17:53:10 +0000 Subject: [PATCH] Martin adds condition,ignore cmds git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2657 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 4 + debugger/README | 9 ++ debugger/mcs51/break.c | 324 +++++++++++++++++++++++++++-------------- debugger/mcs51/break.h | 21 +-- debugger/mcs51/cmd.c | 154 +++++++++++++++++--- debugger/mcs51/cmd.h | 3 + debugger/mcs51/sdcdb.c | 20 ++- debugger/mcs51/sdcdb.h | 1 + 8 files changed, 398 insertions(+), 138 deletions(-) diff --git a/ChangeLog b/ChangeLog index 31da72e4..ac35e0e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2003-05-28 Karl Bongers(patches from Martin Helmling) + * debugger/mcs51/sdcdb.c,cmd.c,break.c and .h files. Martin adds + condition and ignore commands. + 2003-05-28 Frieder Ferlemann * doc/sdccman.lyx: Changes all over, index improved, smaller margins. The manual diff --git a/debugger/README b/debugger/README index c86d642b..00a6b64a 100644 --- a/debugger/README +++ b/debugger/README @@ -4,6 +4,15 @@ SDCDB debugger - Development notes. ====================== +ddd - Notes from Martin Helmling, May 23, 2003 +======================== + +Additionally following new commands work: + +ignore - ignore the breakpoint n times +condition <|>|<=|>=|==|!= - break condition +commands - see gdb description - + ddd - Notes from Martin Helmling, April 28, 2003 ======================== diff --git a/debugger/mcs51/break.c b/debugger/mcs51/break.c index 8e5065e4..d71f9bf0 100644 --- a/debugger/mcs51/break.c +++ b/debugger/mcs51/break.c @@ -24,6 +24,7 @@ #include "sdcdb.h" #include "symtab.h" #include "break.h" +#include "cmd.h" #include "newalloc.h" static hTab *bptable = NULL; @@ -53,11 +54,23 @@ long getLastBreakptNumber() return bpnum; } +void resetHitCount() +{ + int k; + breakp *bp; + for ( bp = hTabFirstItem(bptable,&k); bp ; + bp = hTabNextItem(bptable,&k)) + { + bp->hitCnt = 0; + bp->ignoreCnt = 0; + } +} + /*-----------------------------------------------------------------*/ /* setBreakPoint - creates an entry in the break point table */ /*-----------------------------------------------------------------*/ int setBreakPoint (unsigned addr, char addrType, char bpType, - int (*callBack)(unsigned,char,char,int,context *) , + int (*callBack)(unsigned,breakp *,context *) , char *fileName, int lineno) { breakp *bp, *bpl; @@ -101,11 +114,11 @@ int setBreakPoint (unsigned addr, char addrType, char bpType, if (bpType != STEP && bpType != NEXT) { - /* if a break point does not already exist then - send command to simulator to add one */ - if (!hTabSearch(bptable,addr)) - /* send the break command to the simulator */ - simSetBP (addr); + /* if a break point does not already exist then + send command to simulator to add one */ + if (!hTabSearch(bptable,addr)) + /* send the break command to the simulator */ + simSetBP (addr); } /* now add the break point to list */ @@ -125,14 +138,15 @@ void deleteSTEPbp () Dprintf(D_break, ("break: Deleting all STEP BPs\n")); /* for break points delete if they are STEP */ for ( bp = hTabFirstItem(bptable,&k); bp ; - bp = hTabNextItem(bptable,&k)) { - - /* if this is a step then delete */ - if (bp->bpType == STEP) { - hTabDeleteItem(&bptable,bp->addr,bp,DELETE_ITEM,NULL); + bp = hTabNextItem(bptable,&k)) + { - free(bp); - } + /* if this is a step then delete */ + if (bp->bpType == STEP) + { + hTabDeleteItem(&bptable,bp->addr,bp,DELETE_ITEM,NULL); + Safe_free(bp); + } } } @@ -150,18 +164,28 @@ void deleteNEXTbp () /* for break points delete if they are NEXT */ for ( bp = hTabFirstItem(bptable,&k); bp ; - bp = hTabNextItem(bptable,&k)) { - - /* if this is a step then delete */ - if (bp->bpType == NEXT) { - hTabDeleteItem(&bptable,bp->addr,bp,DELETE_ITEM,NULL); + bp = hTabNextItem(bptable,&k)) + { - free(bp); - } + /* if this is a step then delete */ + if (bp->bpType == NEXT) + { + hTabDeleteItem(&bptable,bp->addr,bp,DELETE_ITEM,NULL); + Safe_free(bp); + } } } +static void freeUSERbp(breakp *bp) +{ + if ( bp->commands ) + Safe_free(bp->commands); + if ( bp->condition ) + Safe_free(bp->condition); + Safe_free(bp); +} + /*-----------------------------------------------------------------*/ /* deleteUSERbp - deletes USER break point with number */ /*-----------------------------------------------------------------*/ @@ -175,34 +199,35 @@ void deleteUSERbp (int bpnum) /* for break points delete if they are STEP */ for ( bp = hTabFirstItem(bptable,&k); bp ; - bp = hTabNextItem(bptable,&k)) { - - /* if this is a user then delete if break - point matches or bpnumber == -1 (meaning delete - all user break points */ - if ((bp->bpType == USER || bp->bpType == TMPUSER ) - && ( bp->bpnum == bpnum || bpnum == -1)) { - hTabDeleteItem(&bptable,bp->addr,bp,DELETE_ITEM,NULL); - - /* if this leaves no other break points then - send command to simulator to delete bp from this addr */ - if (hTabSearch(bptable,bp->addr) == NULL) { - simClearBP (bp->addr); - Dprintf(D_break, ("break: deleteUSERbp:simClearBP 0x%x\n", bp->addr)); - - } - fprintf(stdout,"Deleted breakpoint %d\n", - bp->bpnum); - userBpPresent --; - if (bpnum == -1) - continue ; - else - break; - } + bp = hTabNextItem(bptable,&k)) { + + /* if this is a user then delete if break + point matches or bpnumber == -1 (meaning delete + all user break points */ + if ((bp->bpType == USER || bp->bpType == TMPUSER ) + && ( bp->bpnum == bpnum || bpnum == -1)) + { + hTabDeleteItem(&bptable,bp->addr,bp,DELETE_ITEM,NULL); + + /* if this leaves no other break points then + send command to simulator to delete bp from this addr */ + if (hTabSearch(bptable,bp->addr) == NULL) { + simClearBP (bp->addr); + Dprintf(D_break, ("break: deleteUSERbp:simClearBP 0x%x\n", bp->addr)); + + } + fprintf(stdout,"Deleted breakpoint %d\n",bp->bpnum); + userBpPresent-- ; + freeUSERbp(bp); + if (bpnum == -1) + continue ; + else + break; + } } if (!bp && bpnum != -1) - fprintf(stderr,"No breakpoint number %d.\n",bpnum); + fprintf(stderr,"No breakpoint number %d.\n",bpnum); } /*-----------------------------------------------------------------*/ @@ -230,35 +255,96 @@ void setUserbpCommand (int bpnum, char *cmds) fprintf(stderr,"No breakpoint number %d.\n",bpnum); } +/*-----------------------------------------------------------------*/ +/* setUserbpCondition - set condition string for breakpoint */ +/*-----------------------------------------------------------------*/ +void setUserbpCondition (int bpnum, char *cond) +{ + breakp *bp; + int k; + Dprintf(D_break, ("break: setUserbpCondition %d: condition:'%s'\n", + bpnum, cond?cond:"")); + + for ( bp = hTabFirstItem(bptable,&k); bp ; + bp = hTabNextItem(bptable,&k)) + { + if ((bp->bpType == USER || bp->bpType == TMPUSER ) + && ( bp->bpnum == bpnum )) + { + if ( bp->condition ) + Safe_free(bp->condition); + bp->condition = cond; + return; + } + } + fprintf(stderr,"No breakpoint number %d.\n",bpnum); +} + +/*-----------------------------------------------------------------*/ +/* setUserbpIgnCount - set ignorecount for breakpoint */ +/*-----------------------------------------------------------------*/ +void setUserbpIgnCount (int bpnum, int ignorecnt ) +{ + breakp *bp; + int k; + Dprintf(D_break, ("break: setUserbpIgnCount %d: ignorecnt=%d\n", + bpnum, ignorecnt)); + + for ( bp = hTabFirstItem(bptable,&k); bp ; + bp = hTabNextItem(bptable,&k)) + { + if ((bp->bpType == USER || bp->bpType == TMPUSER ) + && ( bp->bpnum == bpnum )) + { + bp->ignoreCnt = bp->hitCnt + ignorecnt; + return; + } + } + fprintf(stderr,"No breakpoint number %d.\n",bpnum); +} + /*-----------------------------------------------------------------*/ /* listUSERbp - list all user break points */ /*-----------------------------------------------------------------*/ void listUSERbp () { breakp *bp; - int k; + int k, isuser; /* if there are none then say so & return */ if (!userBpPresent) { - fprintf(stdout,"No breakpoints.\n"); - return ; + fprintf(stdout,"No breakpoints.\n"); + return ; } 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 breakpoint keep y 0x%08x at %s:%d\n", - bp->bpnum,bp->addr, - bp->filename,bp->lineno+1); - - } - else if (bp->bpType == TMPUSER ) { - fprintf(stdout,"%-3d breakpoint del y 0x%08x at %s:%d\n", - bp->bpnum,bp->addr, - bp->filename,bp->lineno+1); + bp = hTabNextItem(bptable,&k)) { + + isuser = 0; + if (bp->bpType == USER ) { + fprintf(stdout,"%-3d breakpoint keep y 0x%08x at %s:%d\n", + bp->bpnum,bp->addr, + bp->filename,bp->lineno+1); + isuser = 1; + } + else if (bp->bpType == TMPUSER ) { + fprintf(stdout,"%-3d breakpoint del y 0x%08x at %s:%d\n", + bp->bpnum,bp->addr, + bp->filename,bp->lineno+1); + isuser = 1; + } + if ( ! isuser ) + continue; + if ( bp->ignoreCnt > bp->hitCnt ) + fprintf(stdout,"\tignore next %d hits\n", + bp->ignoreCnt - bp->hitCnt ); + if ( bp->condition ) + fprintf(stdout,"\tstop only if %s\n",bp->condition ); + if ( bp->hitCnt > 0 ) + fprintf(stdout,"\tbreakpoint already hit %d time%s\n", + bp->hitCnt,bp->hitCnt>1?"s":"" ); + - } } } @@ -282,27 +368,29 @@ void clearUSERbp ( unsigned int addr ) /* for break points delete if they are STEP */ for ( bp = hTabFirstItemWK(bptable,addr); bp ; - bp = hTabNextItemWK(bptable)) { - - /* if this is a step then delete */ - if (bp->bpType == USER || bp->bpType == TMPUSER) { - hTabDeleteItem(&bptable,bp->addr,bp,DELETE_ITEM,NULL); - - /* if this leaves no other break points then - send command to simulator to delete bp from this addr */ - if (hTabSearch(bptable,bp->addr) == NULL) { - simClearBP(bp->addr); - - } - fprintf(stdout,"Deleted breakpoint %d\n", - bp->bpnum); - userBpPresent-- ; - break; - } + bp = hTabNextItemWK(bptable)) { + + /* if this is a step then delete */ + if (bp->bpType == USER || bp->bpType == TMPUSER) + { + hTabDeleteItem(&bptable,bp->addr,bp,DELETE_ITEM,NULL); + + /* if this leaves no other break points then + send command to simulator to delete bp from this addr */ + if (hTabSearch(bptable,bp->addr) == NULL) + { + simClearBP(bp->addr); + } + fprintf(stdout,"Deleted breakpoint %d\n", + bp->bpnum); + userBpPresent-- ; + freeUSERbp(bp); + break; + } } if (!bp) - fprintf(stderr,"No breakpoint at address 0x%x.\n",addr); + fprintf(stderr,"No breakpoint at address 0x%x.\n",addr); } /*-----------------------------------------------------------------*/ @@ -327,15 +415,7 @@ int dispatchCB (unsigned addr, context *ctxt) /* dispatch the call back functions */ for (; bp; bp = hTabNextItemWK(bptable)) { - if ( bp->commands ) - { - char save_ch; - Dprintf(D_break, ("break: dispatchCB: commands:\n%send\n", bp->commands)); - setCmdLine(bp->commands); - } - - rv += (*bp->callBack)(addr,bp->addrType, - bp->bpType,bp->bpnum,ctxt); + rv += (*bp->callBack)(addr,bp,ctxt); } if (rv == 0) { @@ -397,30 +477,60 @@ BP_CALLBACK(fexitCB) /*-----------------------------------------------------------------*/ BP_CALLBACK(userBpCB) { - Dprintf(D_break, ("break: userBpCB: BP_CALLBACK entry\n")); + bp->hitCnt++ ; + Dprintf(D_break, ("break: userBpCB: BP_CALLBACK entry hit=%d ignor=%d\n", + bp->hitCnt, bp->ignoreCnt)); + if ( bp->ignoreCnt > bp->hitCnt ) + return 0; + + if ( bp->condition ) + { + if (! conditionIsTrue( bp->condition, ctxt )) + return 0; + } + + if ( bp->commands ) + { + Dprintf(D_break, ("break: userBpCB: commands:%d\n", bp->commands)); + setCmdLine(bp->commands); + } + if (srcMode == SRC_CMODE) { - fprintf(stdout,"Breakpoint %d, %s() at %s:%d\n", - bpnum, - ctxt->func->sym->name, - ctxt->func->mod->c_name, - ctxt->cline+1); - if (ctxt->func->mod && ctxt->cline > 0) - fprintf(stdout,"%d\t%s",ctxt->cline+1, - ctxt->func->mod->cLines[ctxt->cline]->src); + fprintf(stdout,"Breakpoint %d, %s() at %s:%d\n", + bp->bpnum, + ctxt->func->sym->name, + ctxt->func->mod->c_name, + ctxt->cline+1); + if (ctxt->func->mod && ctxt->cline > 0) + fprintf(stdout,"%d\t%s",ctxt->cline+1, + ctxt->func->mod->cLines[ctxt->cline]->src); } else { - fprintf(stdout,"Breakpoint %d, %s() at %s:%d\n", - bpnum, - ctxt->func->sym->name, - ctxt->func->mod->asm_name, - ctxt->asmline+1); - if (ctxt->func->mod && ctxt->asmline > 0) - fprintf(stdout,"%d\t%s",ctxt->asmline+1, - ctxt->func->mod->asmLines[ctxt->asmline]->src); + fprintf(stdout,"Breakpoint %d, %s() at %s:%d\n", + bp->bpnum, + ctxt->func->sym->name, + ctxt->func->mod->asm_name, + ctxt->asmline+1); + if (ctxt->func->mod && ctxt->asmline > 0) + fprintf(stdout,"%d\t%s",ctxt->asmline+1, + ctxt->func->mod->asmLines[ctxt->asmline]->src); } - if ( bpType == TMPUSER && bpnum > 0 ) - deleteUSERbp (bpnum); + if ( bp->bpType == TMPUSER && bp->bpnum > 0 ) + { + hTabDeleteItem(&bptable,bp->addr,bp,DELETE_ITEM,NULL); + + /* if this leaves no other break points then + send command to simulator to delete bp from this addr */ + if (hTabSearch(bptable,bp->addr) == NULL) + { + simClearBP (bp->addr); + Dprintf(D_break, ("break: simClearBP 0x%x\n", bp->addr)); + + } + userBpPresent-- ; + freeUSERbp(bp); + } return 1; } diff --git a/debugger/mcs51/break.h b/debugger/mcs51/break.h index e856d0dc..727fd14e 100644 --- a/debugger/mcs51/break.h +++ b/debugger/mcs51/break.h @@ -47,24 +47,23 @@ typedef struct breakp char *filename; /* file name */ int lineno ; /* lineno */ int (*callBack) - (unsigned,char,char,int,context *);/* address of call back + (unsigned,struct breakp *,context *);/* address of call back * function */ char *commands; + int ignoreCnt; + int hitCnt; + char *condition; } breakp; #define BP_CALLBACK(func) \ int func (unsigned addr, \ - char addrType, \ - char bpType , \ - int bpnum ,\ + breakp *bp, \ context *ctxt) #define EXTERN_BP_CALLBACK(func) \ extern int func (unsigned addr, \ - char addrType, \ - char bpType , \ - int bpnum ,\ + breakp *bp, \ context *ctxt) extern char userBpPresent; @@ -72,9 +71,13 @@ extern char doingSteps; int setBreakPoint (unsigned , char , char, - int (*callBack)(unsigned,char,char,int,context *),char *, int); + int (*callBack)(unsigned,breakp *bp,context *),char *, int); -extern long getLastBreakptNumber(void); +long getLastBreakptNumber(void); +void resetHitCount(void); +void setUserbpCommand (int , char *); +void setUserbpCondition (int , char *); +void setUserbpIgnCount (int , int ); void clearUSERbp ( unsigned int ); void deleteSTEPbp(); diff --git a/debugger/mcs51/cmd.c b/debugger/mcs51/cmd.c index 86c17d2c..0ef1b481 100644 --- a/debugger/mcs51/cmd.c +++ b/debugger/mcs51/cmd.c @@ -330,8 +330,9 @@ static char *warranty= 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 */ @@ -1272,7 +1273,7 @@ int cmdSetOption (char *s, context *cctxt) 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 @@ -1301,6 +1302,52 @@ int cmdContinue (char *s, context *cctxt) 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 */ /*-----------------------------------------------------------------*/ @@ -1566,6 +1613,7 @@ int cmdRun (char *s, context *cctxt) fprintf(stdout,"No executable file specified.\nUse the \"file\" command.\n"); return 0; } + resetHitCount(); simGo(0); } else { @@ -1577,6 +1625,7 @@ int cmdRun (char *s, context *cctxt) fgets(buff,sizeof(buff),stdin); if (toupper(buff[0]) == 'Y') { simReset(); + resetHitCount(); simGo(0); } } @@ -2260,8 +2309,7 @@ int cmdListSrc (char *s, context *cctxt) 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 @@ -2316,7 +2364,7 @@ static void setValBasic(symbol *sym, link *type, else v.val = strtol(val,NULL,0); } - simSetValue(addr,mem,size,v.val); + return v.val; } /*-----------------------------------------------------------------*/ @@ -2540,8 +2588,9 @@ static void printValAggregates (symbol *sym, link *type, /*-----------------------------------------------------------------*/ /* 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; @@ -2559,7 +2608,7 @@ static void printOrSetSymValue (symbol *sym, context *cctxt, if (!bp) { fprintf(stdout,"cannot determine stack frame\n"); - return ; + return 1; } sym->addr = simGetValue(bp->addr,bp->addrspace,bp->size) @@ -2607,14 +2656,14 @@ static void printOrSetSymValue (symbol *sym, context *cctxt, *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)); } @@ -2625,7 +2674,7 @@ static void printOrSetSymValue (symbol *sym, context *cctxt, if ( n < 0 || n >= DCL_ELEM(type)) { fprintf(stdout,"Wrong index %d.\n", n); - return; + return 1; } type = type->next; size = getSize(type); @@ -2649,7 +2698,7 @@ static void printOrSetSymValue (symbol *sym, context *cctxt, if ( ! fields ) { fprintf(stdout,"Unknown field \"%s\" of structure\n", s); - return; + return 1; } type = fields->type; size = getSize(type); @@ -2663,7 +2712,10 @@ static void printOrSetSymValue (symbol *sym, context *cctxt, 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); } @@ -2673,16 +2725,41 @@ static void printOrSetSymValue (symbol *sym, context *cctxt, { 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; } /*-----------------------------------------------------------------*/ @@ -2785,6 +2862,42 @@ static void printTypeInfo(link *p) } } +/*-----------------------------------------------------------------*/ +/* 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 */ /*-----------------------------------------------------------------*/ @@ -2798,7 +2911,7 @@ int cmdPrint (char *s, context *cctxt) if ( sym ) { - printOrSetSymValue(sym,cctxt,1,0,fmt,rs,NULL); + printOrSetSymValue(sym,cctxt,1,0,fmt,rs,NULL,'\0'); } return 0; } @@ -2816,7 +2929,7 @@ int cmdOutput (char *s, context *cctxt) if ( sym ) { - printOrSetSymValue(sym,cctxt,0,0,fmt,rs,NULL); + printOrSetSymValue(sym,cctxt,0,0,fmt,rs,NULL,'\0'); } return 0; } @@ -2851,7 +2964,8 @@ void displayAll(context *cctxt) 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'); } } diff --git a/debugger/mcs51/cmd.h b/debugger/mcs51/cmd.h index ce0d165e..25c65f4e 100644 --- a/debugger/mcs51/cmd.h +++ b/debugger/mcs51/cmd.h @@ -32,6 +32,8 @@ extern int cmdJump (char *, context *); extern int cmdListSrc (char *, context *); extern int cmdListAsm (char *, context *); extern int cmdSetOption (char *, context *); +extern int cmdCondition (char *, context *); +extern int cmdIgnore (char *, context *); extern int cmdContinue (char *, context *); extern int cmdDelUserBp (char *, context *); extern int cmdStep (char *, context *); @@ -65,5 +67,6 @@ extern int cmdListFunctions (char *s, context *cctxt); extern int cmdListSymbols (char *s, context *cctxt); extern void setMainContext( void); +int conditionIsTrue( char *s, context *cctxt); #endif diff --git a/debugger/mcs51/sdcdb.c b/debugger/mcs51/sdcdb.c index 328de243..9c91115b 100644 --- a/debugger/mcs51/sdcdb.c +++ b/debugger/mcs51/sdcdb.c @@ -89,8 +89,14 @@ struct cmdtab { "continue" , cmdContinue , "{c}ontinue\t\t Continue program being debugged, after breakpoint.\n" }, + { "condition" , cmdCondition , + "condition brkpoint_number expr\t\tSet condition for breakpoint.\n" + }, + { "ignore" , cmdIgnore , + "brkpoint_number count\t\tSet ignore count for breakpoint.\n" + }, { "commands" , cmdCommands , - "commands [brkpoint number]\t\tSetting commands for breakpoint.\n" + "commands [brkpoint_number]\t\tSetting commands for breakpoint.\n" }, { "c" , cmdContinue , NULL }, @@ -842,10 +848,17 @@ static int stopcmdlist; /*-----------------------------------------------------------------*/ char *getNextCmdLine() { + //fprintf(stderr,"getNextCmdLine() actualcmdfile=%p\n",actualcmdfile); if (!actualcmdfile) return NULL; + fprintf(stdout,">"); + fflush(stdout); if (fgets(cmdbuff,sizeof(cmdbuff),actualcmdfile) == NULL) + { + // fprintf(stderr,"getNextCmdLine() returns null\n"); return NULL; + } + //fprintf(stderr,"getNextCmdLine() returns: %s",cmdbuff); return cmdbuff; } @@ -877,6 +890,8 @@ static void commandLoop(FILE *cmdfile) fflush(stdout); } + //fprintf(stderr,"commandLoop actualcmdfile=%p cmdfile=%p\n", + // actualcmdfile,cmdfile); if (fgets(cmdbuff,sizeof(cmdbuff),cmdfile) == NULL) break; @@ -1091,7 +1106,8 @@ static void sigchld(int sig) static void setsignals() { - signal(SIGHUP , bad_signal); + signal(SIGHUP , SIG_IGN); + signal(SIGCONT, SIG_IGN); signal(SIGINT , sigintr ); signal(SIGTERM, bad_signal); signal(SIGCHLD, sigchld ); diff --git a/debugger/mcs51/sdcdb.h b/debugger/mcs51/sdcdb.h index f73335a0..5b1ce24b 100644 --- a/debugger/mcs51/sdcdb.h +++ b/debugger/mcs51/sdcdb.h @@ -263,6 +263,7 @@ void **resize (void **, int ); char *alloccpy(char *,int ); char *gc_strdup(const char *s); srcLine **loadFile (char *name, int *nlines); + extern short fullname; extern int srcMode; extern char contsim; -- 2.30.2