From 13a625c70d50182aa136b970e419a7a7e50f282c Mon Sep 17 00:00:00 2001 From: kbongers Date: Tue, 6 May 2003 20:52:46 +0000 Subject: [PATCH] Martins changes for ddd git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2597 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- debugger/mcs51/break.c | 1 + debugger/mcs51/cmd.c | 230 ++++++++++++++++++++-------------------- debugger/mcs51/sdcdb.c | 19 +++- debugger/mcs51/sdcdb.h | 2 + debugger/mcs51/simi.c | 10 ++ debugger/mcs51/symtab.c | 28 +++-- 6 files changed, 166 insertions(+), 124 deletions(-) diff --git a/debugger/mcs51/break.c b/debugger/mcs51/break.c index 44d412d4..5e22f58f 100644 --- a/debugger/mcs51/break.c +++ b/debugger/mcs51/break.c @@ -295,6 +295,7 @@ int dispatchCB (unsigned addr, context *ctxt) if ((bp = hTabFirstItemWK(bptable,addr)) == NULL) { if ( doingSteps == 2 ) return 1; if ( doingSteps ) return 0; + if ( contsim ) return 0; return simStopBPCB(addr); } diff --git a/debugger/mcs51/cmd.c b/debugger/mcs51/cmd.c index 237c4a2a..ff1346cb 100644 --- a/debugger/mcs51/cmd.c +++ b/debugger/mcs51/cmd.c @@ -1262,77 +1262,77 @@ int cmdStep (char *s, context *cctxt) function *func = NULL; if (!cctxt || !cctxt->func || !cctxt->func->mod) - fprintf(stdout,"The program is not being run.\n"); + fprintf(stdout,"The program is not being run.\n"); else { - /* 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 */ + /* 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); + /* 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); + 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); + /* 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); + /* 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); + /* 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))) { + /* now break point @ callers execution points */ + if ((func = STACK_PPEEK(callStack))) { - applyToSet (func->afpoints,setStepEPBp,STEP, - func->mod->asm_name); + 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); - } - } - } + /* 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; + doingSteps = 1; + simGo(2); + doingSteps = 0; + showfull = 1; } return 0; } @@ -1364,65 +1364,65 @@ int cmdNext (char *s, context *cctxt) we don't set break point for all function entry points */ if (!cctxt || !cctxt->func || !cctxt->func->mod) - fprintf(stdout,"The program is not being run.\n"); + fprintf(stdout,"The program is not being run.\n"); else { - /* 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); + /* 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->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; + /* 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; + doingSteps = 0; showfull = 1; - } } return 0; } diff --git a/debugger/mcs51/sdcdb.c b/debugger/mcs51/sdcdb.c index 693e800f..5d9dbac0 100644 --- a/debugger/mcs51/sdcdb.c +++ b/debugger/mcs51/sdcdb.c @@ -46,6 +46,7 @@ context *currCtxt = NULL; short fullname = 0; short showfull = 0; short userinterrupt = 0; +char contsim = 0; char *ssdirl = DATADIR LIB_DIR_SUFFIX ":" DATADIR LIB_DIR_SUFFIX "/small" ; char *simArgs[40]; int nsimArgs = 0; @@ -472,6 +473,7 @@ static void functionPoints () { function *func; symbol *sym; + exePoint *ep ; /* for all functions do */ for ( func = setFirstItem(functions); func; @@ -506,7 +508,6 @@ static void functionPoints () if (mod->cLines[j]->addr >= sym->addr && mod->cLines[j]->addr <= sym->eaddr ) { - exePoint *ep ; /* add it to the execution point */ if (func->entryline > j) @@ -523,7 +524,16 @@ static void functionPoints () addSet(&func->cfpoints,ep); } } - + /* check double line execution points of module */ + for (ep = setFirstItem(mod->cfpoints); ep; + ep = setNextItem(mod->cfpoints)) + { + if (ep->addr >= sym->addr && + ep->addr <= sym->eaddr ) + { + addSet(&func->cfpoints,ep); + } + } /* do the same for asm execution points */ for ( j = 0 ; j < mod->nasmLines ; j++ ) { if (mod->asmLines[j]->addr >= sym->addr && @@ -843,6 +853,7 @@ static void parseCmdLine (int argc, char **argv) int passon_args_flag = 0; /* if true, pass on args to simulator */ Dprintf(D_sdcdb, ("sdcdb: parseCmdLine\n")); + contsim=0; for ( i = 1; i < argc ; i++) { //fprintf(stdout,"%s\n",argv[i]); @@ -889,6 +900,10 @@ static void parseCmdLine (int argc, char **argv) continue; } #endif + if (strncmp(argv[i],"-contsim",8) == 0) { + contsim=1; + continue; + } /* model string */ if (strncmp(argv[i],"-m",2) == 0) { diff --git a/debugger/mcs51/sdcdb.h b/debugger/mcs51/sdcdb.h index 80c42627..36a4bd2f 100644 --- a/debugger/mcs51/sdcdb.h +++ b/debugger/mcs51/sdcdb.h @@ -179,6 +179,7 @@ typedef struct module { int nasmLines; /* # of lines in the assembler file */ srcLine **cLines; /* actual source lines */ srcLine **asmLines; /* actual assembler source lines*/ + set *cfpoints; /* set of double line execution points */ } module; /*-----------------------------------------------------------------*/ @@ -261,6 +262,7 @@ char *gc_strdup(const char *s); srcLine **loadFile (char *name, int *nlines); extern short fullname; extern int srcMode; +extern char contsim; char *searchDirsFname (char *); #endif diff --git a/debugger/mcs51/simi.c b/debugger/mcs51/simi.c index 61133fa5..b4486d12 100644 --- a/debugger/mcs51/simi.c +++ b/debugger/mcs51/simi.c @@ -36,6 +36,7 @@ #endif FILE *simin ; /* stream for simulator input */ FILE *simout; /* stream for simulator output */ +typedef void (*sighandler_t)(int); int sock = -1; /* socket descriptor to comm with simulator */ pid_t simPid = -1; @@ -422,6 +423,7 @@ void simLoadFile (char *s) /*-----------------------------------------------------------------*/ unsigned int simGoTillBp ( unsigned int gaddr) { + sighandler_t oldsig; char *sr; unsigned addr ; char *sfmt; @@ -441,6 +443,8 @@ unsigned int simGoTillBp ( unsigned int gaddr) //sleep(1); //waitForSim(); + sendSim("reset\n"); + waitForSim(wait_ms, NULL); sendSim("run 0x0\n"); } else if (gaddr == -1) { /* resume */ sendSim ("run\n"); @@ -477,10 +481,16 @@ unsigned int simGoTillBp ( unsigned int gaddr) sr++ ; } + oldsig = signal(SIGINT,SIG_IGN); + /* get answer of stop command */ + if ( userinterrupt ) + waitForSim(wait_ms, NULL); + /* better solution: ask pc */ sendSim ("pc\n"); waitForSim(100, NULL); sr = simResponse(); + signal(SIGINT,oldsig); gaddr = strtol(sr+3,0,0); return gaddr; diff --git a/debugger/mcs51/symtab.c b/debugger/mcs51/symtab.c index b35e2d15..6d12e577 100644 --- a/debugger/mcs51/symtab.c +++ b/debugger/mcs51/symtab.c @@ -734,14 +734,28 @@ static void lnkCSrc (char *s) line--; /* one line can have more than one address : (for loops !)*/ - if (line < mod->ncLines && line > 0 && + if (line < mod->ncLines && line > 0 /*&& ( !mod->cLines[line]->addr || - mod->cLines[line]->level > level )) { - mod->cLines[line]->addr = addr; - mod->cLines[line]->block = block; - mod->cLines[line]->level = level; - Dprintf(D_symtab, ("symtab: ccc %s(%d:0x%x) %s",mod->c_name, - line+1,addr,mod->cLines[line]->src)); + mod->cLines[line]->level > level )*/ ) + { + if ( mod->cLines[line]->addr ) + { + /* save double line information for exepoints */ + exePoint *ep ; + ep = Safe_calloc(1,sizeof(exePoint)); + ep->addr = mod->cLines[line]->addr ; + ep->line = line; + ep->block= mod->cLines[line]->block; + ep->level= mod->cLines[line]->level; + addSet(&mod->cfpoints,ep); + Dprintf(D_symtab, ("symtab: exe %s(%d:0x%x) %s",mod->c_name, + line+1,addr,mod->cLines[line]->src)); + } + mod->cLines[line]->addr = addr; + mod->cLines[line]->block = block; + mod->cLines[line]->level = level; + Dprintf(D_symtab, ("symtab: ccc %s(%d:0x%x) %s",mod->c_name, + line+1,addr,mod->cLines[line]->src)); } return; -- 2.30.2