char *rs, char *val, char cmp);
int srcMode = SRC_CMODE ;
-static set *dispsymbols = NULL ; /* set of displayable symbols */
+set *dispsymbols = NULL ; /* set of displayable symbols */
static int currentFrame = 0; /* actual displayed frame */
/*-----------------------------------------------------------------*/
/* funcWithName - returns function with name */
/*-----------------------------------------------------------------*/
static char *preparePrint(char *s, context *cctxt, int *fmt, symbol **sym)
{
- char *bp = s+strlen(s) -1;
+ char *bp;
char save_ch ;
*fmt = FMT_NON;
*sym = NULL;
- while (isspace(*s)) s++;
+ s = trim(s);
if (!*s)
return (char *)0;
- while (isspace(*bp)) bp--;
- bp++ ;
- *bp = '\0';
-
if ( *s == '/' )
{
/* format of printout */
break;
}
s++;
- while (isspace(*s)) s++;
+ s = trim_left(s);
}
for ( bp = s; *bp && ( isalnum( *bp ) || *bp == '_' || *bp == '$'); bp++ );
save_ch = *bp;
if ( args > 0 )
{
- while (*s && isspace(*s)) s++;
+ s = trim_left(s);
if ( isdigit(*s))
{
saddr = strtol(s,&s,0);
if ( args > 1 )
{
- while (*s && isspace(*s)) s++;
+ s = trim_left(s);
if ( isdigit(*s))
eaddr = strtol(s,0,0);
else
{
if ( args > 1 )
- printf("Dump of assembler code from 0x%08x to 0x%08x:\n",saddr,eaddr);
+ printf("Dump of assembler code from 0x%08lx to 0x%08lx:\n",saddr,eaddr);
found = 0;
while ( saddr < eaddr )
{
fprintf(stdout,"No symbol table is loaded. Use the \"file\" command.\n");
return 0;
}
- /* white space skip */
- while (*s && isspace(*s)) s++;
-
- /* null terminate it after stripping trailing blanks*/
- bp = s + strlen(s);
- while (bp != s && isspace(*bp)) bp--;
- *bp = '\0';
+ /* trim left and right */
+ s = trim(s);
/* case a) nothing */
/* if nothing given then current location : we know
module *modul;
if (!applyToSet(modules,moduleLineWithAddr,braddr,&modul,&line))
{
- fprintf(stderr,"Address 0x%08x not exists in code.\n",braddr);
+ fprintf(stderr,"Address 0x%08lx not exists in code.\n",braddr);
}
else
{
- Dprintf(D_break, ("commonSetUserBp: g) addr:%x \n",braddr));
+ Dprintf(D_break, ("commonSetUserBp: g) addr:%lx \n",braddr));
setBreakPoint ( braddr , CODE , bpType , userBpCB ,
modul->c_name,line);
}
/*-----------------------------------------------------------------*/
int cmdJump (char *s, context *cctxt)
{
- char *bp ;
+ char *bp;
function *func = NULL;
if (STACK_EMPTY(callStack))
{
return 0;
}
- /* white space skip */
- while (*s && isspace(*s)) s++;
+ /* trim left and right */
+ s = trim(s);
- /* null terminate it after stripping trailing blanks*/
- bp = s + strlen(s);
- while (bp != s && isspace(*bp)) bp--;
- *bp = '\0';
if (! *s )
{
fprintf(stdout,"No argument: need line or *addr.\n");
/*-----------------------------------------------------------------*/
int cmdSetOption (char *s, context *cctxt)
{
- while (*s && isspace(*s)) s++;
+ s = trim_left(s);
if (strncmp(s,"srcmode",7) == 0 ) {
if (srcMode == SRC_CMODE)
srcMode = SRC_AMODE;
s = rs;
while (*s && *s != '=') s++;
*s++ = '\0';
- while (isspace(*s)) *s++ = '\0';
+ s = trim_left(s);
if (*s && sym)
{
printOrSetSymValue(sym,cctxt,0,0,0,rs,s,'\0');
int cmdIgnore (char *s, context *cctxt)
{
int bpnum, cnt ;
- while (isspace(*s)) s++;
+ s = trim_left(s);
if (!*s )
{
fprintf(stdout,"Argument required (breakpoint number).\n");
return 0;
}
bpnum = strtol(s,&s,10);
- while (isspace(*s)) s++;
+ s = trim_left(s);
if (!*s )
{
fprintf(stdout,"Second argument (specified ignore-count) is missing.");
int cmdCondition (char *s, context *cctxt)
{
int bpnum ;
- while (isspace(*s)) s++;
+ s = trim_left(s);
if (!*s )
{
fprintf(stdout,"Argument required (breakpoint number).\n");
return 0;
}
bpnum = strtol(s,&s,10);
- while (isspace(*s)) s++;
+ s = trim_left(s);
if (*s)
s = Safe_strdup(s);
else
{
int bpnum ;
char *cmds,*line;
- while (isspace(*s)) s++;
+ s = trim_left(s);
if (!*s )
bpnum = getLastBreakptNumber();
cmds = NULL;
while ((line = getNextCmdLine()))
{
- while (isspace(*line)) line++;
+ line = trim_left(line);
if (!strncmp(line,"end",3))
break;
if (! cmds )
int cmdDelUserBp (char *s, context *cctxt)
{
int bpnum ;
- while (isspace(*s)) s++;
+ s = trim_left(s);
if (!*s ) {
if (userBpPresent) {
for ( j = 0; j < 8 ; j++ )
{
val = simGetValue (j,'R',1);
- fprintf(stdout," 0x%02X",val);
+ fprintf(stdout," 0x%02lX",val);
}
fprintf(stdout,"\n");
val = simGetValue (0xe0,'I',1);
- fprintf(stdout,"ACC : 0x%02X %d %c\n",val,val,(isprint(val) ? val : '.'));
+ fprintf(stdout,"ACC : 0x%02lX %lu %c\n",val,val,(isprint(val) ? (char)val : '.'));
val = simGetValue (0xf0,'I',1);
- fprintf(stdout,"B : 0x%02X %d %c\n",val,val,(isprint(val) ? val : '.'));
+ fprintf(stdout,"B : 0x%02lX %lu %c\n",val,val,(isprint(val) ? (char)val : '.'));
val = simGetValue (0x82,'I',2);
- fprintf(stdout,"DPTR: 0x%04X %d\n",val,val);
+ fprintf(stdout,"DPTR: 0x%04lX %lu\n",val,val);
val = simGetValue (0x81,'I',1);
- fprintf(stdout,"SP : 0x%02X (0x%04X)\n",val,simGetValue (val-1,'B',2));
+ fprintf(stdout,"SP : 0x%02lX (0x%04lX)\n",val,simGetValue (val-1,'B',2));
fprintf(stdout,"PSW : 0x%02X | CY : %c | AC : %c | OV : %c | P : %c\n",
i,(i&0x80)?'1':'0',(i&0x40)?'1':'0',(i&4)?'1':'0',(i&1)?'1':'0');
if ( all )
if (applyToSetFTrue(sfrsymbols,symWithAddr,i,'I',&sym))
{
val = simGetValue (sym->addr,sym->addrspace,sym->size);
- fprintf(stdout,"%s : 0x%02x",sym->name,val);
+ fprintf(stdout,"%s : 0x%02lx",sym->name,val);
if ( !(i & 0x07 ))
{
for ( j = 0 ; j < 8 ; j++ )
/*-----------------------------------------------------------------*/
int cmdInfo (char *s, context *cctxt)
{
- while (isspace(*s)) s++;
+ /* trim left and_right*/
+ s = trim(s);
/* list all break points */
if (strncmp(s,"break",5) == 0) {
}
/* info frame same as frame */
- if (strcmp(s,"frame") == 0) {
- cmdFrame (s,cctxt);
+ if (strncmp(s,"frame",5) == 0) {
+ cmdFrame (s+5,cctxt);
return 0;
}
if (strncmp(s,"line",4) == 0) {
- infomode=1;
+ infomode=1;
cmdListSrc (s+4,cctxt);
return 0;
}
}
return 0;
}
- if (strncmp(s,"functions",7) == 0)
+ if (strcmp(s,"functions") == 0)
{
function *f;
module *m = NULL;
/* info stack display call stack */
if (strcmp(s,"stack") == 0) {
infoStack(cctxt);
- showfull = 1;
+ showfull = 1;
return 0;
}
function *func = NULL;
- while (*s && isspace(*s)) s++;
+ s = trim_left(s);
/* if the user has spcified line numer then the line number
can be of the following formats
fprintf(stdout,"%f",v.f);
else
if (IS_PTR(type))
- fprintf(stdout,"0x%*x",size<<1,v.val);
+ fprintf(stdout,"0x%*lx",size<<1,v.val);
else
if (IS_INTEGRAL(type))
{
if (IS_BITVAR(etype))
fprintf(stdout,"%c",(v.val?'1':'0'));
else
- fprintf(stdout,"0x%0*x",size<<1,v.val);
+ fprintf(stdout,"0x%0*lx",size<<1,v.val);
}
}
} else
- fprintf(stdout,"0x%0*x",size<<1,v.val);
+ fprintf(stdout,"0x%0*lx",size<<1,v.val);
}
/*-----------------------------------------------------------------*/
}
s++ ;
}
- while (isspace(*s)) *s++ = '\0';
+ s = trim_left(s);
fmt = printOrSetSymValue(sym,cctxt,0,0,0,rs,s,cmp_char);
}
Safe_free(dup);
dsymbol *dsym;
int dnum;
- while (isspace(*s)) s++;
+ s = trim_left(s);
if (!*s)
{
for (dsym = setFirstItem(dispsymbols);
/*-----------------------------------------------------------------*/
int cmdPrintType (char *s, context *cctxt)
{
- symbol *sym ;
- char *bp = s+strlen(s) -1;
+ symbol *sym ;
- while (isspace(*s)) s++;
+ /* trim left and right */
+ s = trim(s);
if (!*s) return 0;
- while (isspace(*bp)) bp--;
- bp++ ;
- *bp = '\0';
if ((sym = symLookup(s,cctxt))) {
printTypeInfo(sym->type);
return 0;
}
- /* white space skip */
- while (*s && isspace(*s)) s++;
-
- /* null terminate it after stripping trailing blanks*/
- bp = s + strlen(s);
- while (bp != s && isspace(*bp)) bp--;
- *bp = '\0';
+ /* trim left and right */
+ s = trim(s);
/* case a) nothing */
/* if nothing given then current location : we know
/*-----------------------------------------------------------------*/
int cmdUp(char *s, context *cctxt)
{
- while (isspace(*s)) s++;
+ s = trim_left(s);
if ( *s )
currentFrame += strtol(s,0,10);
else
/*-----------------------------------------------------------------*/
int cmdDown(char *s, context *cctxt)
{
- while (isspace(*s)) s++;
+ s = trim_left(s);
if ( *s )
currentFrame -= strtol(s,0,10);
else
function *func = NULL;
int framenr = 0;
- while (isspace(*s)) s++;
+ s = trim_left(s);
if ( *s )
currentFrame = strtol(s,0,10);
printFrame();
int cmdShow (char *s, context *cctxt)
{
/* skip white space */
- while (*s && isspace(*s)) s++ ;
+ s = trim_left(s);
if (strcmp(s,"copying") == 0) {
fputs(copying,stdout);