- for ( ; next_line < (srcMode == SRC_CMODE ? mod->ncLines : mod->nasmLines ) ;
- next_line++ ) {
- if (srcMode == SRC_CMODE) {
- if (mod->cLines[next_line]->addr) {
- setBreakPoint (mod->cLines[next_line]->addr, CODE, USER,
- userBpCB, mod->c_name, next_line);
- return;
-// break;
- }
- }
- else {
- if (mod->asmLines[next_line]->addr) {
- setBreakPoint (mod->asmLines[next_line]->addr, CODE, USER,
- userBpCB, mod->asm_name, next_line);
- return;
-// break;
- }
- }
- }
-
- fprintf(stderr,"No line %d or after in file \"%s\"..\n",
- line,mod->c_name);
+ for ( ; next_line < (srcMode == SRC_CMODE ? mod->ncLines : mod->nasmLines ) ;
+ next_line++ ) {
+ if (srcMode == SRC_CMODE) {
+ if (mod->cLines[next_line]->addr != INT_MAX) {
+ setBreakPoint (mod->cLines[next_line]->addr, CODE, bpType,
+ userBpCB, mod->c_name, next_line);
+ return;
+// break;
+ }
+ }
+ else {
+ if (mod->asmLines[next_line]->addr != INT_MAX) {
+ setBreakPoint (mod->asmLines[next_line]->addr, CODE, bpType,
+ userBpCB, mod->asm_name, next_line);
+ return;
+// break;
+ }
+ }
+ }
+
+ fprintf(stderr,"No line %d or after in file \"%s\"..\n",
+ line,mod->c_name);
- /* if current context is known */
- if (cctxt->func) {
- if (srcMode == SRC_CMODE)
- /* set the break point */
- setBreakPoint ( cctxt->addr , CODE , USER , userBpCB ,
- cctxt->func->mod->c_name, cctxt->cline);
- else
- setBreakPoint ( cctxt->addr , CODE , USER , userBpCB ,
- cctxt->func->mod->asm_name, cctxt->asmline);
-
- }
- else
- fprintf(stderr,"No default breakpoint address now.\n");
-
- goto ret ;
+ /* 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 ,
+ cctxt->func->mod->c_name, cctxt->cline);
+ else
+ setBreakPoint ( cctxt->addr , CODE , bpType , userBpCB ,
+ cctxt->func->mod->asm_name, cctxt->asmline);
+
+ }
+ else
+ fprintf(stderr,"No default breakpoint address now.\n");
+
+ goto ret ;
- if (isdigit(*s)) {
- /* get the lineno */
- int line = atoi(s) -1;
-
- /* if current context not present then we must get the module
- which has main & set the break point @ line number provided
- of that module : if current context known then set the bp
- at the line number given for the current module
- */
- if (cctxt->func) {
- if (!cctxt->func->mod) {
- if (!applyToSet(functions,funcWithName,"main"))
- fprintf(stderr,"Function \"main\" not defined.\n");
- else
- setBPatModLine(func->mod,line);
- } else
- setBPatModLine(cctxt->func->mod,line);
- } else {
- if (list_mod) {
- setBPatModLine(list_mod,line);
- } else {
- fprintf(stdout,"Sdcdb fails to have module symbol context at %d\n", __LINE__);
- }
- }
-
- goto ret;
+ if ( !strchr(s,':') && isdigit(*s)) {
+ /* get the lineno */
+ int line = atoi(s) -1;
+ Dprintf(D_break, ("commonSetUserBp: b) line:%d \n",line));
+ if ( line < 0 )
+ {
+ fprintf(stdout,"linenumber <= 0\n");
+ goto ret;
+ }
+ /* if current context not present then we must get the module
+ which has main & set the break point @ line number provided
+ of that module : if current context known then set the bp
+ at the line number given for the current module
+ */
+ if (cctxt->func) {
+ if (!cctxt->func->mod) {
+ if (!applyToSet(functions,funcWithName,"main"))
+ fprintf(stderr,"Function \"main\" not defined.\n");
+ else
+ setBPatModLine(func->mod,line, bpType);
+ } else
+ setBPatModLine(cctxt->func->mod,line, bpType);
+ } else {
+ if (list_mod) {
+ setBPatModLine(list_mod,line, bpType);
+ } else {
+ fprintf(stdout,"Sdcdb fails to have module symbol context at %d\n", __LINE__);
+ }
+ }
+
+ goto ret;
-
- module *mod = NULL;
- *bp = '\0';
-
- if (srcMode == SRC_CMODE) {
- if (!applyToSet(modules,moduleWithCName,s,&mod)) {
- fprintf (stderr,"No source file named %s.\n",s);
- goto ret;
- }
- } else {
- if (!applyToSet(modules,moduleWithAsmName,s,&mod)) {
- fprintf (stderr,"No source file named %s.\n",s);
- goto ret;
- }
- }
-
- /* case c) filename:lineno */
- if (isdigit(*(bp +1))) {
-
- setBPatModLine (mod,atoi(bp+1)-1);
- goto ret;
-
- }
- /* case d) filename:function */
- if (!applyToSet(functions,funcWithNameModule,bp+1,s,&func))
- fprintf(stderr,"Function \"%s\" not defined.\n",bp+1);
- else
- setBPatModLine (mod,
- (srcMode == SRC_CMODE ?
- func->entryline :
- func->aentryline));
-
- goto ret;
- }
-
+
+ module *mod = NULL;
+ *bp = '\0';
+
+ if (srcMode == SRC_CMODE) {
+ if (!applyToSet(modules,moduleWithCName,s,&mod)) {
+ fprintf (stderr,"No source file named %s.\n",s);
+ goto ret;
+ }
+ } else {
+ if (!applyToSet(modules,moduleWithAsmName,s,&mod)) {
+ fprintf (stderr,"No source file named %s.\n",s);
+ goto ret;
+ }
+ }
+
+ /* case c) filename:lineno */
+ if (isdigit(*(bp +1))) {
+ Dprintf(D_break, ("commonSetUserBp: c) line:%d \n",atoi(bp+1)));
+ setBPatModLine (mod,atoi(bp+1)-1,bpType);
+ goto ret;
+
+ }
+ /* case d) filename:function */
+ 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 :
+ func->aentryline),bpType);
+
+ goto ret;
+ }
+
- setBPatModLine(func->mod,
- (srcMode == SRC_CMODE ?
- func->entryline :
- func->aentryline));
+ setBPatModLine(func->mod,
+ (srcMode == SRC_CMODE ?
+ func->entryline :
+ func->aentryline),bpType);
+
+ ret:
+ return 0;
+}
+
+/*-----------------------------------------------------------------*/
+/* cmdSetTmpUserBp - settempory break point at the user specified location */
+/*-----------------------------------------------------------------*/
+int cmdSetTmpUserBp (char *s, context *cctxt)
+{
+ return commonSetUserBp(s, cctxt, TMPUSER );
+}
+
+/*-----------------------------------------------------------------*/
+/* cmdSetUserBp - set break point at the user specified location */
+/*-----------------------------------------------------------------*/
+int cmdSetUserBp (char *s, context *cctxt)
+{
+ return commonSetUserBp(s, cctxt, USER );
+}
+
+/*-----------------------------------------------------------------*/
+/* cmdJump - set program counter */
+/*-----------------------------------------------------------------*/
+int cmdJump (char *s, context *cctxt)
+{
+ char *bp;
+ function *func = NULL;
+ if (STACK_EMPTY(callStack))
+ {
+ fprintf(stdout,"The program is not running.\n");
+ return 0;
+ }
+
+ /* trim left and right */
+ s = trim(s);
+ if (! *s )
+ {
+ fprintf(stdout,"No argument: need line or *addr.\n");
+ return 0;
+ }
+ if ( *s == '*' && isdigit(*(s+1)))
+ {
+ unsigned int addr = atoi(s);
+ if (cctxt && cctxt->func &&
+ cctxt->func->sym->addr <= addr &&
+ cctxt->func->sym->eaddr >= addr)
+ {
+ simSetPC(addr);
+ return 0;
+ }
+ fprintf(stdout,"Warning addr 0x%x outside actual function.\n",addr);
+ simSetPC(addr);
+ return 0;
+ }
+ if (isdigit(*s))
+ {
+ /* get the lineno */
+ int line = atoi(s) -1;
+ if (!cctxt || !cctxt->func || !cctxt->func->mod)
+ {
+ fprintf(stderr,"Function not defined.\n");
+ return 0;
+ }
+ if (line >= cctxt->func->entryline &&
+ line <= cctxt->func->exitline )
+ {
+ simSetPC(cctxt->func->mod->cLines[line]->addr);
+ return 0;
+ }
+ if (line >= cctxt->func->mod->ncLines )
+ {
+ fprintf(stderr,"line not in module.\n");
+ return 0;
+ }
+ fprintf(stdout,"Warning line %d outside actual function.\n",line+1);
+ simSetPC(cctxt->func->mod->cLines[line]->addr);
+ return 0;
+ }
+ if ((bp = strchr(s,':')))
+ {
+ int line;
+ module *mod = NULL;
+ *bp++ = '\0';
+ if (!applyToSet(modules,moduleWithCName,s,&mod))
+ {
+ fprintf (stderr,"No source file named %s.\n",s);
+ return 0;
+ }
+ if (!isdigit(*bp))
+ {
+ fprintf (stderr,"No line number.\n");
+ return 0;
+ }
+ line = atoi(bp) -1;
+ if (line >= mod->ncLines )
+ {
+ fprintf(stderr,"line not in module.\n");
+ return 0;
+ }
+ if ( mod != cctxt->func->mod ||
+ line < cctxt->func->entryline ||
+ line > cctxt->func->exitline )
+ {
+ fprintf(stdout,"Warning line %d outside actual function.\n",
+ line+1);
+ }
+ simSetPC(mod->cLines[line]->addr);
+ }
+/*-----------------------------------------------------------------*/
+/* cmdIgnore - set ignorecount for breakpoint */
+/*-----------------------------------------------------------------*/
+int cmdIgnore (char *s, context *cctxt)
+{
+ int bpnum, cnt ;
+ s = trim_left(s);
+ if (!*s )
+ {
+ fprintf(stdout,"Argument required (breakpoint number).\n");
+ return 0;
+ }
+ bpnum = strtol(s,&s,10);
+ s = trim_left(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 ;
+ s = trim_left(s);
+ if (!*s )
+ {
+ fprintf(stdout,"Argument required (breakpoint number).\n");
+ return 0;
+ }
+ bpnum = strtol(s,&s,10);
+ s = trim_left(s);
+ if (*s)
+ s = Safe_strdup(s);
+ else
+ s = NULL;
+ setUserbpCondition(bpnum,s);
+ return 0;
+}
+
+/*-----------------------------------------------------------------*/
+/* cmdCommands - set commands for breakpoint */
+/*-----------------------------------------------------------------*/
+int cmdCommands (char *s, context *cctxt)
+{
+ int bpnum ;
+ char *cmds,*line;
+ s = trim_left(s);
+
+ if (!*s )
+ bpnum = getLastBreakptNumber();
+ else
+ bpnum = strtol(s,0,10);
+
+ cmds = NULL;
+ while ((line = getNextCmdLine()))
+ {
+ line = trim_left(line);
+ if (!strncmp(line,"end",3))
+ break;
+ if (! cmds )
+ {
+ cmds = Safe_strdup(line);
+ }
+ else
+ {
+ cmds = Safe_realloc( cmds, strlen(cmds) + 1 + strlen(line));
+ strcat(cmds,line);
+ }
+ }
+ setUserbpCommand(bpnum,cmds);
+ return 0;
+}
+
- /* if we are @ the end of a function then set
- break points at execution points of the
- function in the call stack... */
- if (cctxt->addr == cctxt->func->sym->eaddr) {
- if ((func = STACK_PEEK(callStack))) {
- if (srcMode == SRC_CMODE)
- applyToSet (func->cfpoints,setStepEPBp,STEP,
- func->mod->c_name);
- else
- applyToSet (func->afpoints,setStepEPBp,STEP,
- func->mod->asm_name);
- }
- } else {
- /* set breakpoints at all function entry points
- and all exepoints of this functions & for
- all functions one up in the call stack */
-
- /* all function entry points */
- applyToSet(functions,setStepBp);
-
- if (srcMode == SRC_CMODE) {
- /* for all execution points in this function */
- applyToSet(cctxt->func->cfpoints,setStepEPBp,STEP,
- cctxt->func->mod->c_name);
-
- /* set a break point @ the current function's
- exit */
- setBreakPoint (cctxt->func->sym->eaddr, CODE, STEP ,
- stepBpCB, cctxt->func->mod->c_name,
- cctxt->func->exitline);
-
- /* now break point @ callers execution points */
- if ((func = STACK_PPEEK(callStack))) {
- applyToSet (func->cfpoints,setStepEPBp,STEP,
- func->mod->c_name);
- /* set bp @ callers exit point */
- setBreakPoint (func->sym->eaddr, CODE, STEP ,
- stepBpCB, func->mod->c_name,
- func->exitline);
- }
- } else {
- /* for all execution points in this function */
- applyToSet(cctxt->func->afpoints,setStepEPBp,STEP,
- cctxt->func->mod->asm_name);
-
- /* set a break point @ the current function's
- exit */
- setBreakPoint (cctxt->func->sym->eaddr, CODE, STEP ,
- stepBpCB, cctxt->func->mod->asm_name,
- cctxt->func->aexitline);
-
- /* now break point @ callers execution points */
- if ((func = STACK_PPEEK(callStack))) {
-
- applyToSet (func->afpoints,setStepEPBp,STEP,
- func->mod->asm_name);
-
- /* set bp @ callers exit point */
- setBreakPoint (func->sym->eaddr, CODE, STEP ,
- stepBpCB, func->mod->asm_name,
- func->aexitline);
- }
- }
- }
-
- doingSteps = 1;
- simGo(2);
- doingSteps = 0;
- showfull = 1;
+ /* if we are @ the end of a function then set
+ break points at execution points of the
+ function in the call stack... */
+ if (cctxt->addr == cctxt->func->sym->eaddr) {
+ if ((func = STACK_PEEK(callStack))) {
+ if (srcMode == SRC_CMODE)
+ applyToSet (func->cfpoints,setStepEPBp,STEP,
+ func->mod->c_name);
+ else
+ applyToSet (func->afpoints,setStepEPBp,STEP,
+ func->mod->asm_name);
+ }
+ } else {
+ /* set breakpoints at all function entry points
+ and all exepoints of this functions & for
+ all functions one up in the call stack */
+
+ /* all function entry points */
+ applyToSet(functions,setStepBp);
+
+ if (srcMode == SRC_CMODE) {
+ /* for all execution points in this function */
+ applyToSet(cctxt->func->cfpoints,setStepEPBp,STEP,
+ cctxt->func->mod->c_name);
+
+ /* set a break point @ the current function's
+ exit */
+ setBreakPoint (cctxt->func->sym->eaddr, CODE, STEP ,
+ stepBpCB, cctxt->func->mod->c_name,
+ cctxt->func->exitline);
+
+ /* now break point @ callers execution points */
+ if ((func = STACK_PPEEK(callStack))) {
+ applyToSet (func->cfpoints,setStepEPBp,STEP,
+ func->mod->c_name);
+ /* set bp @ callers exit point */
+ setBreakPoint (func->sym->eaddr, CODE, STEP ,
+ stepBpCB, func->mod->c_name,
+ func->exitline);
+ }
+ } else {
+ /* for all execution points in this function */
+ applyToSet(cctxt->func->afpoints,setStepEPBp,STEP,
+ cctxt->func->mod->asm_name);
+
+ /* set a break point @ the current function's
+ exit */
+ setBreakPoint (cctxt->func->sym->eaddr, CODE, STEP ,
+ stepBpCB, cctxt->func->mod->asm_name,
+ cctxt->func->aexitline);
+
+ /* now break point @ callers execution points */
+ if ((func = STACK_PPEEK(callStack))) {
+
+ applyToSet (func->afpoints,setStepEPBp,STEP,
+ func->mod->asm_name);
+
+ /* set bp @ callers exit point */
+ setBreakPoint (func->sym->eaddr, CODE, STEP ,
+ stepBpCB, func->mod->asm_name,
+ func->aexitline);
+ }
+ }
+ }
+
+ doingSteps = 1;
+ simGo(2);
+ doingSteps = 0;
+ showfull = 1;
- /* if we are @ the end of a function then set
- break points at execution points of the
- function in the call stack... */
- if (cctxt->addr == cctxt->func->sym->eaddr) {
- if ((func = STACK_PEEK(callStack))) {
- if (srcMode == SRC_CMODE)
- applyToSet (func->cfpoints,setStepEPBp,STEP,
- func->mod->c_name);
- else
- applyToSet (func->afpoints,setStepEPBp,STEP,
- func->mod->asm_name);
- }
- } else {
- if (srcMode == SRC_CMODE) {
- /* for all execution points in this function */
- applyToSet(cctxt->func->cfpoints,setNextEPBp,NEXT,
- cctxt->func->mod->c_name);
- /* set a break point @ the current function's
- exit */
- setBreakPoint (cctxt->func->sym->eaddr, CODE, NEXT ,
- nextBpCB, cctxt->func->mod->c_name,
- cctxt->func->exitline);
-
- /* now break point @ callers execution points */
- if ((func = STACK_PPEEK(callStack))) {
- applyToSet (func->cfpoints,setNextEPBp,NEXT ,
- func->mod->c_name);
- /* set bp @ callers exit point */
- setBreakPoint (func->sym->eaddr, CODE, NEXT ,
- stepBpCB, func->mod->c_name,
- func->exitline);
- }
- } else {
- /* for all execution points in this function */
- applyToSet(cctxt->func->afpoints,setNextEPBp,NEXT,
- cctxt->func->mod->asm_name);
- /* set a break point @ the current function's
- exit */
- setBreakPoint (cctxt->func->sym->eaddr, CODE, NEXT ,
- nextBpCB, cctxt->func->mod->asm_name,
- cctxt->func->aexitline);
-
- /* now break point @ callers execution points */
- if ((func = STACK_PPEEK(callStack))) {
- applyToSet (func->cfpoints,setNextEPBp,NEXT ,
- func->mod->asm_name);
- /* set bp @ callers exit point */
- setBreakPoint (func->sym->eaddr, CODE, NEXT ,
- stepBpCB, func->mod->asm_name,
- func->aexitline);
- }
- }
- doingSteps = 1;
- simGo(1);
- doingSteps = 0;
+ /* if we are @ the end of a function then set
+ break points at execution points of the
+ function in the call stack... */
+ if (cctxt->addr == cctxt->func->sym->eaddr) {
+ if ((func = STACK_PEEK(callStack))) {
+ if (srcMode == SRC_CMODE)
+ applyToSet (func->cfpoints,setStepEPBp,NEXT,
+ func->mod->c_name);
+ else
+ applyToSet (func->afpoints,setStepEPBp,NEXT,
+ func->mod->asm_name);
+ }
+ } else {
+ if (srcMode == SRC_CMODE) {
+ /* for all execution points in this function */
+ applyToSet(cctxt->func->cfpoints,setNextEPBp,NEXT,
+ cctxt->func->mod->c_name);
+ /* set a break point @ the current function's
+ exit */
+ setBreakPoint (cctxt->func->sym->eaddr, CODE, NEXT ,
+ nextBpCB, cctxt->func->mod->c_name,
+ cctxt->func->exitline);
+
+ /* now break point @ callers execution points */
+ if ((func = STACK_PPEEK(callStack))) {
+ applyToSet (func->cfpoints,setNextEPBp,NEXT ,
+ func->mod->c_name);
+ /* set bp @ callers exit point */
+ setBreakPoint (func->sym->eaddr, CODE, NEXT ,
+ stepBpCB, func->mod->c_name,
+ func->exitline);
+ }
+ } else {
+ /* for all execution points in this function */
+ applyToSet(cctxt->func->afpoints,setNextEPBp,NEXT,
+ cctxt->func->mod->asm_name);
+ /* set a break point @ the current function's
+ exit */
+ setBreakPoint (cctxt->func->sym->eaddr, CODE, NEXT ,
+ nextBpCB, cctxt->func->mod->asm_name,
+ cctxt->func->aexitline);
+
+ /* now break point @ callers execution points */
+ if ((func = STACK_PPEEK(callStack))) {
+ applyToSet (func->cfpoints,setNextEPBp,NEXT ,
+ func->mod->asm_name);
+ /* set bp @ callers exit point */
+ setBreakPoint (func->sym->eaddr, CODE, NEXT ,
+ stepBpCB, func->mod->asm_name,
+ func->aexitline);
+ }
+ }
+ }
+ doingSteps = 1;
+ simGo(1);
+ doingSteps = 0;
- infomode=1;
- cmdListSrc (s+4,cctxt);
- return 0;
+ infomode=1;
+ cmdListSrc (s+4,cctxt);
+ return 0;
+ }
+ if (strncmp(s,"source",6) == 0)
+ {
+ module *m;
+ if ( s[6] == 's' )
+ {
+ int k = 0;
+ fprintf(stdout,"Source files for which symbols have been read in:\n\n");
+ for (m = setFirstItem(modules); m ; m = setNextItem(modules))
+ {
+ fprintf(stdout,"%s%s, %s",k ? ", ":"",m->cfullname, m->afullname);
+ k = 1;
+ }
+ fprintf(stdout,"\n");
+ }
+ else
+ {
+ if (!cctxt || !cctxt->func || !cctxt->func->mod)
+ {
+ fprintf(stdout,"No source file loaded\n");
+ return 0;
+ }
+ m = cctxt->func->mod;
+ fprintf(stdout,"Current source file is %s\n",m->c_name);
+ fprintf(stdout,"Located in %s\n",m->cfullname);
+ fprintf(stdout,"Contains %d lines.\nSource language is c.\n",
+ m->ncLines);
+ }
+ return 0;
+ }
+ if (strcmp(s,"functions") == 0)
+ {
+ function *f;
+ module *m = NULL;
+ fprintf(stdout,"All defined functions:\n");
+ for ( f = setFirstItem(functions); f ; f = setNextItem(functions))
+ {
+ if ( f->mod != m )
+ {
+ m = f->mod;
+ fprintf(stdout,"\nFile %s\n", m->c_name);
+ }
+ fprintf(stdout,"%s();\n",f->sym->name);
+ }
+ return 0;
- /* case a) LINE */
- if (isdigit(*s)) {
- pline = strtol(s,0,10) - 1;
- if (!cctxt || !cctxt->func || !cctxt->func->mod) {
- if (!list_mod) {
- fprintf(stdout,"Sdcdb fails to have a proper context at %d.\n", __LINE__);
- return 0;
- }
- }
- else
- list_mod = cctxt->func->mod;
- }
- else {
- char *bp;
- function *func = NULL;
-
- /* if ':' present then FILE:LINE || FILE:FUNCTION */
- if ((bp = strchr(s,':'))) {
- *bp = '\0';
- bp ++;
- if (isdigit(*bp)) {
- /* FILE:LINE */
- list_mod=NULL; /* bug fix 2-09-02, moduleWithCName expects mod to be null */
- if (srcMode == SRC_CMODE) {
- if (!applyToSet(modules,moduleWithCName,s,&list_mod)) {
- fprintf (stderr,"No c source file named %s.\n",s);
- return 0;
- }
- } else {
- if (!applyToSet(modules,moduleWithAsmName,s,&list_mod)) {
- fprintf (stderr,"No source file named %s.\n",s);
- return 0;
- }
- }
- pline = strtol(bp,0,10) - 1;
- } else {
- /* FILE:FUCTION */
- if (!applyToSet(functions,funcWithNameModule,bp,s,&func)) {
- fprintf(stdout,"Function \"%s\" not defined.\n",bp);
- return 0;
- }
- list_mod = func->mod;
- if (srcMode == SRC_CMODE) {
- pline = func->entryline;
- llines = func->exitline - func->entryline + 1;
- } else {
- pline = func->aentryline;
- llines = func->aexitline - func->aentryline + 1;
- }
- }
- }
- else {
- /* FUNCTION */
- if (*s == '\'')
+ /* case a) LINE */
+ if (isdigit(*s)) {
+ if (!cctxt || !cctxt->func || !cctxt->func->mod) {
+ if (!list_mod) {
+ fprintf(stdout,"Sdcdb fails to have a proper context at %d.\n", __LINE__);
+ return 0;
+ }
+ }
+ else
+ list_mod = cctxt->func->mod;
+ pline = strtol(s,&s,10) - 1;
+ if (s && (s = strchr(s,',')))
+ {
+ /* LINE,LASTLINE */
+ llines = strtol(s+1,0,10);
+ if ( llines > 0 )
+ llines -= pline+1;
+ else
+ llines = listlines;
+ }
+ }
+ else {
+ char *bp;
+
+ /* if ':' present then FILE:LINE || FILE:FUNCTION */
+ if ((bp = strchr(s,':'))) {
+ *bp = '\0';
+ bp ++;
+ if (isdigit(*bp)) {
+ /* FILE:LINE */
+ list_mod=NULL; /* bug fix 2-09-02, moduleWithCName expects mod to be null */
+ if (srcMode == SRC_CMODE) {
+ if (!applyToSet(modules,moduleWithCName,s,&list_mod)) {
+ fprintf (stderr,"No c source file named %s.\n",s);
+ return 0;
+ }
+ } else {
+ if (!applyToSet(modules,moduleWithAsmName,s,&list_mod)) {
+ fprintf (stderr,"No source file named %s.\n",s);
+ return 0;
+ }
+ }
+ pline = strtol(bp,&bp,10) - 1;
+ if (bp && (bp = strchr(bp,',')))
+ {
+ /* FILE:LINE,LASTLINE */
+ llines = strtol(bp+1,0,10);
+ if ( llines > 0 )
+ llines -= pline+1;
+ else
+ llines = listlines;
+ }
+ } else {
+ /* FILE:FUCTION */
+ if (!applyToSet(functions,funcWithNameModule,bp,s,&func)) {
+ fprintf(stdout,"Function \"%s\" not defined.\n",bp);
+ return 0;
+ }
+ list_mod = func->mod;
+ if (srcMode == SRC_CMODE) {
+ pline = func->entryline;
+ llines = func->exitline - func->entryline + 1;
+ } else {
+ pline = func->aentryline;
+ llines = func->aexitline - func->aentryline + 1;
+ }
+ }
+ }
+ else {
+ /* FUNCTION */
+ if (*s == '\'')
- fprintf(stdout,"Line %d of \"%s\" starts at address 0x%08x.\n",pline+1,
- list_mod->c_name, list_mod->cLines[pline]->addr);
+ unsigned firstaddr , lastaddr ;
+ if ( pline >= list_mod->ncLines )
+ pline = cctxt->cline;
+ firstaddr = lastaddr = list_mod->cLines[pline]->addr;
+ if (!func && cctxt && cctxt->func )
+ func = cctxt->func;
+ fprintf(stdout,"Line %d of \"%s\" starts at address 0x%08x <%s+%d>",
+ pline+1,
+ list_mod->c_name, lastaddr,
+ func ? func->sym->name : "?",
+ func ? lastaddr -func->sym->addr : 0);
+ llines = pline +1;
+ for ( ; pline < list_mod->ncLines; pline++ )
+ {
+ if ( list_mod->cLines[pline]->addr > lastaddr )
+ {
+ lastaddr = list_mod->cLines[pline]->addr -1;
+ break;
+ }
+ }
+ fprintf(stdout," and ends at 0x%08x <%s+%d>.\n",
+ lastaddr,
+ func ? func->sym->name : "?",
+ func ? lastaddr -func->sym->addr : 0);
- link *elem_type = type->next;
- int i;
-
- fprintf(stdout,"{");
- for (i = 0 ; i < DCL_ELEM(type) ; i++) {
- if (IS_AGGREGATE(elem_type)) {
- printValAggregates(sym,elem_type,space,addr,fmt);
- } else {
- printValBasic(sym,elem_type,space,addr,getSize(elem_type),fmt);
- }
- addr += getSize(elem_type);
- if (i != DCL_ELEM(type) -1)
- fprintf(stdout,",");
- }
+ link *elem_type = type->next;
+ int i;
+
+ fprintf(stdout,"{");
+ for (i = 0 ; i < DCL_ELEM(type) ; i++) {
+ if (IS_AGGREGATE(elem_type)) {
+ printValAggregates(sym,elem_type,space,addr,fmt);
+ } else {
+ printValBasic(sym,elem_type,space,addr,getSize(elem_type),fmt);
+ }
+ addr += getSize(elem_type);
+ if (i != DCL_ELEM(type) -1)
+ fprintf(stdout,",");
+ }
- switch (DCL_TYPE(p)) {
- case FUNCTION:
- printTypeInfo (p->next);
- fprintf(stdout,"()");
- break;
- case ARRAY:
- printTypeInfo (p->next);
- fprintf(stdout,"[%d]",DCL_ELEM(p));
- break;
-
- case IPOINTER:
- case PPOINTER:
- case POINTER:
- printTypeInfo (p->next);
- fprintf(stdout,"(_near *)");
- break;
-
- case FPOINTER:
- printTypeInfo (p->next);
- fprintf(stdout,"(_xdata *)");
- break;
-
- case CPOINTER:
- printTypeInfo( p->next);
- fprintf(stdout,"(_code *)");
- break;
-
- case GPOINTER:
- printTypeInfo( p->next);
- fprintf(stdout,"(_generic *)");
- break;
- }
+ switch (DCL_TYPE(p)) {
+ case FUNCTION:
+ printTypeInfo (p->next);
+ fprintf(stdout,"()");
+ break;
+ case ARRAY:
+ printTypeInfo (p->next);
+ fprintf(stdout,"[%d]",DCL_ELEM(p));
+ break;
+
+ case IPOINTER:
+ case PPOINTER:
+ case POINTER:
+ printTypeInfo (p->next);
+ fprintf(stdout,"(_near *)");
+ break;
+
+ case FPOINTER:
+ printTypeInfo (p->next);
+ fprintf(stdout,"(_xdata *)");
+ break;
+
+ case CPOINTER:
+ printTypeInfo( p->next);
+ fprintf(stdout,"(_code *)");
+ break;
+
+ case GPOINTER:
+ printTypeInfo( p->next);
+ fprintf(stdout,"(_generic *)");
+ break;
+ }
- /* get the lineno */
- int line = atoi(s);
-
- /* if current context not present then we must get the module
- which has main & set the break point @ line number provided
- of that module : if current context known then set the bp
- at the line number given for the current module
- */
- if (cctxt->func) {
- if (!cctxt->func->mod) {
- if (!applyToSet(functions,funcWithName,"main"))
- fprintf(stderr,"Function \"main\" not defined.\n");
- else
- clearBPatModLine(func->mod,line);
- } else
- clearBPatModLine(cctxt->func->mod,line);
- }
-
- goto ret;
+ /* get the lineno */
+ int line = atoi(s);
+
+ /* if current context not present then we must get the module
+ which has main & set the break point @ line number provided
+ of that module : if current context known then set the bp
+ at the line number given for the current module
+ */
+ if (cctxt->func) {
+ if (!cctxt->func->mod) {
+ if (!applyToSet(functions,funcWithName,"main"))
+ fprintf(stderr,"Function \"main\" not defined.\n");
+ else
+ clearBPatModLine(func->mod,line);
+ } else
+ clearBPatModLine(cctxt->func->mod,line);
+ }
+
+ goto ret;
-
- module *mod = NULL;
- *bp = '\0';
-
- if (!applyToSet(modules,moduleWithCName,s,&mod)) {
- fprintf (stderr,"No source file named %s.\n",s);
- goto ret;
- }
-
- /* case c) filename:lineno */
- if (isdigit(*(bp +1))) {
-
- clearBPatModLine (mod,atoi(bp+1));
- goto ret;
-
- }
- /* case d) filename:function */
- if (!applyToSet(functions,funcWithNameModule,bp+1,s,&func))
- fprintf(stderr,"Function \"%s\" not defined.\n",bp+1);
- else
- clearBPatModLine (mod,func->entryline);
-
- goto ret;
- }
-
+
+ module *mod = NULL;
+ *bp = '\0';
+
+ if (!applyToSet(modules,moduleWithCName,s,&mod)) {
+ fprintf (stderr,"No source file named %s.\n",s);
+ goto ret;
+ }
+
+ /* case c) filename:lineno */
+ if (isdigit(*(bp +1))) {
+
+ clearBPatModLine (mod,atoi(bp+1));
+ goto ret;
+
+ }
+ /* case d) filename:function */
+ if (!applyToSet(functions,funcWithNameModule,bp+1,s,&func))
+ fprintf(stderr,"Function \"%s\" not defined.\n",bp+1);
+ else
+ clearBPatModLine (mod,func->entryline);
+
+ goto ret;
+ }
+