X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=debugger%2Fmcs51%2Fsdcdb.c;h=a5b77d5df18bd829d45a4d41649ed7427dc3f74a;hb=430335203e350c61246e703a2b01d559b9978b37;hp=53a1a38cf253044b872a34211ed4e932213a4a65;hpb=1e821843694decea299c2e76da6a0e7d3e5dfb91;p=fw%2Fsdcc diff --git a/debugger/mcs51/sdcdb.c b/debugger/mcs51/sdcdb.c index 53a1a38c..a5b77d5d 100644 --- a/debugger/mcs51/sdcdb.c +++ b/debugger/mcs51/sdcdb.c @@ -39,6 +39,8 @@ int nLinkrecs = 0; linkrec **linkrecs = NULL; /* all linkage editor records */ context *currCtxt = NULL; short fullname = 0; +short showfull = 0; +short userinterrupt = 0; char *ssdirl = DATADIR LIB_DIR_SUFFIX ":" DATADIR LIB_DIR_SUFFIX "/small" ; char *simArgs[40]; int nsimArgs = 0; @@ -75,19 +77,20 @@ struct cmdtab }, { "c" , cmdContinue , NULL }, + { "disassemble",cmdDisasmF , "x disassemble asm commands\n" }, { "delete" , cmdDelUserBp , "{d}elete n\t\t clears break point number n\n" }, - { "d" , cmdDelUserBp , NULL }, - - { "help" , cmdHelp , - "{h|?}elp\t\t this message\n" + { "display" , cmdDisplay , + "display []\t print value of given variable each time the program stops\n" }, - { "?" , cmdHelp , NULL }, - { "h" , cmdHelp , NULL }, + { "undisplay" , cmdUnDisplay , + "undisplay []\t dont display this variable or all\n" + }, + { "d" , cmdDelUserBp , NULL }, { "info" , cmdInfo , - "info \n" + "info \n" "\t list all break points, call-stack, frame or register information\n" }, @@ -106,7 +109,7 @@ struct cmdtab "show" " \t copying & distribution terms, warranty\n" }, - { "set" , cmdSetOption , "set \t\t toggle between c/asm.\n" }, + { "set" , cmdSetOption , "set \t\t toggle between c/asm.\nset variable = >value\t\tset variable to new value\n" }, { "step" , cmdStep , "{s}tep\t\t\t Step program until it reaches a different source line.\n" }, @@ -126,6 +129,9 @@ struct cmdtab { "print" , cmdPrint , "{p}rint \t print value of given variable\n" }, + { "output" , cmdOutput , + "output \t print value of given variable without $ and newline \n" + }, { "p" , cmdPrint , NULL }, { "file" , cmdFile , "file \t\t load symbolic information from \n" @@ -137,14 +143,22 @@ struct cmdtab "{fi}nish\t\t execute till return of current function\n" }, { "fi" , cmdFinish , NULL }, + { "where" , cmdWhere , "where\t\t\t print stack\n" }, { "fr" , cmdFrame , NULL }, { "f" , cmdFrame , NULL }, + { "x /i" , cmdDisasm1 , "x\t\t disassemble one asm command\n" }, { "!" , cmdSimulator , "!\t send a command directly to the simulator\n" }, { "." , cmdSimulator , ".{cmd}\t switch from simulator or debugger command mode\n" }, + { "help" , cmdHelp , + "{h|?}elp\t [CMD_NAME | 0,1,2,3(help page)] (general help or specific help)\n" + }, + { "?" , cmdHelp , NULL }, + { "h" , cmdHelp , NULL }, + { "quit" , cmdQuit , "{q}uit\t\t\t \"Watch me now. Iam going Down. My name is Bobby Brown\"\n" }, @@ -581,7 +595,8 @@ int cmdFile (char *s,context *cctxt) functionPoints(); /* start the simulator & setup connection to it */ - openSimulator((char **)simArgs,nsimArgs); + if ( sock == -1 ) + openSimulator((char **)simArgs,nsimArgs); fprintf(stdout,"%s",simResponse()); /* now send the filename to be loaded to the simulator */ sprintf(buffer,"%s.ihx",s); @@ -614,6 +629,15 @@ int cmdHelp (char *s, context *cctxt) if (endline > 0) startline = endline - 20; } + else if (*s) + { + for (i = 0 ; i < (sizeof(cmdTab)/sizeof(struct cmdtab)) ; i++) + { + if ((cmdTab[i].htxt) && !strcmp(cmdTab[i].cmd,s)) + fprintf(stdout,"%s",cmdTab[i].htxt); + } + return 0; + } for (i = 0 ; i < (sizeof(cmdTab)/sizeof(struct cmdtab)) ; i++) { @@ -693,15 +717,17 @@ int interpretCmd (char *s) rv = (*cmdTab[i].cmdfunc)(s + strlen(cmdTab[i].cmd),currCtxt); /* if full name then give the file name & position */ - if (fullname && currCtxt && currCtxt->func) { + if (fullname && showfull && currCtxt && currCtxt->func) { + showfull = 0; if (srcMode == SRC_CMODE) - fprintf(stdout,"\032\032%s:%d:1\n", + fprintf(stdout,"\032\032%s:%d:1:beg:0x%08x\n", currCtxt->func->mod->cfullname, - currCtxt->cline+1); + currCtxt->cline,currCtxt->addr); else - fprintf(stdout,"\032\032%s:%d:1\n", + fprintf(stdout,"\032\032%s:%d:1:beg:0x%08x\n", currCtxt->func->mod->afullname, - currCtxt->asmline+1); + currCtxt->asmline,currCtxt->addr); + displayAll(currCtxt); } goto ret; } @@ -874,6 +900,53 @@ static void parseCmdLine (int argc, char **argv) cmdFile(filename,NULL); } +/*-----------------------------------------------------------------*/ +/* setsignals - catch some signals */ +/*-----------------------------------------------------------------*/ +#include +static void +bad_signal(int sig) +{ + if ( simactive ) + closeSimulator(); + exit(1); +} + +static void +sigintr(int sig) +{ + /* may be interrupt from user: stop debugger ( also simulator ??) */ + userinterrupt = 1; +} + +/* the only child can be the simulator */ +static void sigchld(int sig) +{ + /* the only child can be the simulator */ + int status, retpid; + retpid = wait ( &status ); + /* if ( retpid == simPid ) */ + simactive = 0; +} + +static void +setsignals() +{ + signal(SIGHUP , bad_signal); + signal(SIGINT , sigintr ); + signal(SIGTERM, bad_signal); + signal(SIGCHLD, sigchld ); + + signal(SIGPIPE, SIG_IGN); + signal(SIGABRT, bad_signal); + signal(SIGALRM, bad_signal); + signal(SIGFPE, bad_signal); + signal(SIGILL, bad_signal); + signal(SIGPIPE, bad_signal); + signal(SIGQUIT, bad_signal); + signal(SIGSEGV, bad_signal); +} + /*-----------------------------------------------------------------*/ /* main - */ /*-----------------------------------------------------------------*/ @@ -888,6 +961,7 @@ int main ( int argc, char **argv) simArgs[nsimArgs++] = "-r 9756"; /* parse command line */ + setsignals(); parseCmdLine(argc,argv); commandLoop();