1 /*-------------------------------------------------------------------------
2 sdcdb.c - main source file for sdcdb debugger
3 Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999)
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2, or (at your option) any
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 In other words, you are welcome to use, share and improve this program.
20 You are forbidden to forbid anyone else to use, share and improve
21 what you give them. Help stamp out software-hoarding!
22 -------------------------------------------------------------------------*/
35 char *currModName = NULL;
36 cdbrecs *recsRoot = NULL ;
37 set *modules = NULL; /* set of all modules */
38 set *functions = NULL ; /* set of functions */
39 set *symbols = NULL ; /* set of symbols */
40 set *sfrsymbols= NULL ; /* set of symbols of sfr or sbit */
42 structdef **structs = NULL ; /* all structures */
44 linkrec **linkrecs = NULL; /* all linkage editor records */
45 context *currCtxt = NULL;
48 char userinterrupt = 0;
51 char *ssdirl = DATADIR LIB_DIR_SUFFIX ":" DATADIR LIB_DIR_SUFFIX "/small" ;
55 /* fake filename & lineno to make linker */
60 static void commandLoop(FILE *cmdfile);
65 char *cmd ; /* command the user will enter */
66 int (*cmdfunc)(char *,context *); /* function to execute when command is entered */
67 char *htxt ; /* short help text */
70 /* NOTE:- the search is done from the top, so "break" should
71 precede the synonym "b" */
73 { "break" , cmdSetUserBp ,
74 "{b}reak\t\t\t [LINE | FILE:LINE | FILE:FUNCTION | FUNCTION | *<address>]\n",
76 { "tbreak" , cmdSetTmpUserBp ,
77 "tbreak\t\t\t [LINE | FILE:LINE | FILE:FUNCTION | FUNCTION | *<address>]\n",
79 { "b" , cmdSetUserBp , NULL },
82 "jump\t\t\tContinue program being debugged at specified line or address\n [LINE | FILE:LINE | *<address>]\n",
84 { "clear" , cmdClrUserBp ,
85 "{cl}ear\t\t\t [LINE | FILE:LINE | FILE:FUNCTION | FUNCTION]\n"
87 { "cl" , cmdClrUserBp , NULL },
89 { "continue" , cmdContinue ,
90 "{c}ontinue\t\t Continue program being debugged, after breakpoint.\n"
92 { "commands" , cmdCommands ,
93 "commands [brkpoint number]\t\tSetting commands for breakpoint.\n"
95 { "c" , cmdContinue , NULL },
97 { "disassemble",cmdDisasmF , "disassemble [startaddr [endaddress]]\tdisassemble asm commands\n" },
98 { "delete" , cmdDelUserBp ,
99 "{d}elete n\t\t clears break point number n\n"
101 { "display" , cmdDisplay ,
102 "display [/<fmt>] [<variable>]\t print value of given variable each time the program stops\n"
104 { "undisplay" , cmdUnDisplay ,
105 "undisplay [<variable>]\t dont display this variable or all\n"
108 "down\t\tSelect and print stack frame called by this one.\nAn argument says how many frames down to go.\n"
111 "up\t\tSelect and print stack frame that called this one.\nAn argument says how many frames up to go.\n"
113 { "d" , cmdDelUserBp , NULL },
116 "info <break stack frame registers all-registers>\n"
117 "\t list all break points, call-stack, frame or register information\n"
120 { "listasm" , cmdListAsm ,
121 "listasm {la}\t\t list assembler code for the current C line\n"
123 { "la" , cmdListAsm , NULL },
124 { "ls" , cmdListSymbols , "ls,lf,lm\t\t list symbols,functions,modules\n" },
125 { "lf" , cmdListFunctions, NULL },
126 { "lm" , cmdListModules , NULL },
127 { "list" , cmdListSrc ,
128 "{l}ist\t\t\t [LINE | FILE:LINE | FILE:FUNCTION | FUNCTION]\n"
130 { "l" , cmdListSrc , NULL },
133 " <copying warranty>\t copying & distribution terms, warranty\n"
135 { "set" , cmdSetOption , "set <srcmode>\t\t toggle between c/asm.\nset variable <var> = >value\t\tset variable to new value\n" },
136 { "stepi" , cmdStepi ,
137 "stepi\t\t\tStep one instruction exactly.\n"
140 "{s}tep\t\t\tStep program until it reaches a different source line.\n"
142 { "source" , cmdSource ,
143 "source <FILE>\t\t\tRead commands from a file named FILE.\n"
145 { "s" , cmdStep , NULL },
146 { "nexti" , cmdNexti ,
147 "nexti\t\t\tStep one instruction, but proceed through subroutine calls.\n"
150 "{n}ext\t\t\tStep program, proceeding through subroutine calls.\n"
152 { "n" , cmdNext , NULL },
154 "{r}un\t\t\tStart debugged program. \n"
156 { "r" , cmdRun , NULL },
157 { "ptype" , cmdPrintType ,
158 "{pt}ype <variable>\tprint type information of a variable\n"
160 { "pt" , cmdPrintType , NULL },
161 { "print" , cmdPrint ,
162 "{p}rint <variable>\t print value of given variable\n"
164 { "output" , cmdOutput ,
165 "output <variable>\t print value of given variable without $ and newline \n"
167 { "p" , cmdPrint , NULL },
169 "file <filename>\t\t load symbolic information from <filename>\n"
171 { "frame" , cmdFrame ,
172 "{fr}ame\t\t print information about the current Stack\n"
174 { "finish" , cmdFinish ,
175 "{fi}nish\t\t execute till return of current function\n"
177 { "fi" , cmdFinish , NULL },
178 { "where" , cmdWhere , "where\t\t print stack\n" },
179 { "fr" , cmdFrame , NULL },
180 { "f" , cmdFrame , NULL },
181 { "x /i" , cmdDisasm1 , "x\t\t disassemble one asm command\n" },
182 { "!" , cmdSimulator ,
183 "!<simulator command>\t send a command directly to the simulator\n"
185 { "." , cmdSimulator ,
186 ".{cmd}\t switch from simulator or debugger command mode\n"
189 "{h|?}elp\t [CMD_NAME | 0,1,2,3(help page)] (general help or specific help)\n"
191 { "?" , cmdHelp , NULL },
192 { "h" , cmdHelp , NULL },
195 "{q}uit\t\t\t \"Watch me now. Iam going Down. My name is Bobby Brown\"\n"
197 { "q" , cmdQuit , NULL }
200 /*-----------------------------------------------------------------*/
201 /* gc_strdup - make a string duplicate garbage collector aware */
202 /*-----------------------------------------------------------------*/
203 char *gc_strdup(const char *s)
206 ret = Safe_malloc(strlen(s)+1);
211 /*-----------------------------------------------------------------*/
212 /* alloccpy - allocate copy and return a new string */
213 /*-----------------------------------------------------------------*/
214 char *alloccpy ( char *s, int size)
221 d = Safe_malloc(size+1);
228 /*-----------------------------------------------------------------*/
229 /* resize - resizes array of type with new size */
230 /*-----------------------------------------------------------------*/
231 void **resize (void **array, int newSize)
236 vptr = Safe_realloc(array,newSize*(sizeof(void **)));
238 vptr = calloc(1, sizeof(void **));
241 fprintf(stderr,"sdcdb: out of memory \n");
249 /*-----------------------------------------------------------------*/
250 /* readCdb - reads the cdb files & puts the records into cdbLine */
252 /*-----------------------------------------------------------------*/
253 static int readCdb (FILE *file)
259 if (!(bp = fgets(buffer,sizeof(buffer),file)))
262 currl = Safe_calloc(1,sizeof(cdbrecs));
267 /* make sure this is a cdb record */
268 if (strchr("STLFM",*bp) && *(bp+1) == ':') {
269 /* depending on the record type */
274 currl->type = SYM_REC;
277 currl->type = STRUCT_REC;
280 currl->type = LNK_REC;
283 currl->type = FUNC_REC;
286 currl->type = MOD_REC ;
290 currl->line = Safe_malloc(strlen(bp));
291 strncpy(currl->line,bp,strlen(bp)-1);
292 currl->line[strlen(bp)-1] = '\0';
295 if (!(bp = fgets(buffer,sizeof(buffer),file)))
301 currl->next = Safe_calloc(1,sizeof(cdbrecs));
305 return (recsRoot->line ? 1 : 0);
308 /*-----------------------------------------------------------------*/
309 /* searchDirsFname - search directory list & return the filename */
310 /*-----------------------------------------------------------------*/
311 char *searchDirsFname (char *fname)
317 /* first try the current directory */
318 if ((rfile = fopen(fname,"r"))) {
320 return strdup(fname) ;
324 return strdup(fname);
326 /* make a copy of the source directories */
327 dirs = sdirs = strdup(ssdirl);
329 /* assume that the separator is ':'
330 and try for each directory in the search list */
331 dirs = strtok(dirs,":");
333 if (dirs[strlen(dirs)] == '/')
334 sprintf(buffer,"%s%s",dirs,fname);
336 sprintf(buffer,"%s/%s",dirs,fname);
337 if ((rfile = fopen(buffer,"r")))
339 dirs = strtok(NULL,":");
345 return strdup(buffer);
347 return strdup(fname);
350 /*-----------------------------------------------------------------*/
351 /* searchDirsFopen - go thru list of directories for filename given*/
352 /*-----------------------------------------------------------------*/
353 FILE *searchDirsFopen(char *fname)
359 /* first try the current directory */
360 if ((rfile = fopen(fname,"r")))
365 /* make a copy of the source directories */
366 dirs = sdirs = strdup(ssdirl);
368 /* assume that the separator is ':'
369 and try for each directory in the search list */
370 dirs = strtok(dirs,":");
372 sprintf(buffer,"%s/%s",dirs,fname);
373 if ((rfile = fopen(buffer,"r")))
375 dirs = strtok(NULL,":");
383 /*-----------------------------------------------------------------*/
384 /* loadFile - loads a file into module buffer */
385 /*-----------------------------------------------------------------*/
386 srcLine **loadFile (char *name, int *nlines)
391 srcLine **slines = NULL;
394 if (!(mfile = searchDirsFopen(name))) {
395 fprintf(stderr,"sdcdb: cannot open module %s -- use '--directory=<source directory> option\n",name);
399 while ((bp = fgets(buffer,sizeof(buffer),mfile))) {
402 slines = (srcLine **)resize((void **)slines,*nlines);
404 slines[(*nlines)-1] = Safe_calloc(1,sizeof(srcLine));
405 slines[(*nlines)-1]->src = alloccpy(bp,strlen(bp));
413 /*-----------------------------------------------------------------*/
414 /* loadModules - reads the source files into module structure */
415 /*-----------------------------------------------------------------*/
416 static void loadModules ()
422 /* go thru the records & find out the module
423 records & load the modules specified */
424 for ( loop = recsRoot ; loop ; loop = loop->next ) {
426 switch (loop->type) {
427 /* for module records do */
429 currMod = parseModule(loop->line,TRUE);
430 currModName = currMod->name ;
432 currMod->cfullname = searchDirsFname(currMod->c_name);
434 /* load it into buffer */
435 currMod->cLines = loadFile (currMod->c_name,
438 /* do the same for the assembler file */
439 currMod->afullname = searchDirsFname(currMod->asm_name);
440 currMod->asmLines=loadFile (currMod->asm_name,
441 &currMod->nasmLines);
444 /* if this is a function record */
446 parseFunc(loop->line);
449 /* if this is a structure record */
451 parseStruct(loop->line);
454 /* if symbol then parse the symbol */
456 parseSymbol(loop->line,&rs,2);
460 parseLnkRec(loop->line);
466 /*-----------------------------------------------------------------*/
467 /* generate extra sets of sfr and sbit symbols */
468 /*-----------------------------------------------------------------*/
469 static void specialFunctionRegs ()
472 for (sym = setFirstItem(symbols);
474 sym = setNextItem(symbols))
476 if ( sym->addrspace == 'I' ||
477 sym->addrspace == 'J')
479 addSet(&sfrsymbols,sym);
483 /*-----------------------------------------------------------------*/
484 /* functionPoints - determine the execution points within a func */
485 /*-----------------------------------------------------------------*/
486 static void functionPoints ()
492 /* for all functions do */
493 for ( func = setFirstItem(functions); func;
494 func = setNextItem(functions)) {
500 Dprintf(D_sdcdb, ("sdcdb: func '%s' has entry '0x%x' exit '0x%x'\n",
505 if (!func->sym->addr && !func->sym->eaddr)
508 /* for all source lines in the module find
509 the ones with address >= start and <= end
510 and put them in the point */
512 if (! applyToSet(modules,moduleWithName,func->modName,&mod))
515 func->entryline= INT_MAX;
517 func->aentryline = INT_MAX ;
520 /* do it for the C Lines first */
521 for ( j = 0 ; j < mod->ncLines ; j++ ) {
522 if (mod->cLines[j]->addr >= sym->addr &&
523 mod->cLines[j]->addr <= sym->eaddr ) {
526 /* add it to the execution point */
527 if (func->entryline > j)
530 if (func->exitline < j)
533 ep = Safe_calloc(1,sizeof(exePoint));
534 ep->addr = mod->cLines[j]->addr ;
536 ep->block= mod->cLines[j]->block;
537 ep->level= mod->cLines[j]->level;
538 addSet(&func->cfpoints,ep);
541 /* check double line execution points of module */
542 for (ep = setFirstItem(mod->cfpoints); ep;
543 ep = setNextItem(mod->cfpoints))
545 if (ep->addr >= sym->addr &&
546 ep->addr <= sym->eaddr )
548 addSet(&func->cfpoints,ep);
551 /* do the same for asm execution points */
552 for ( j = 0 ; j < mod->nasmLines ; j++ ) {
553 if (mod->asmLines[j]->addr >= sym->addr &&
554 mod->asmLines[j]->addr <= sym->eaddr ) {
557 /* add it to the execution point */
558 if (func->aentryline > j)
559 func->aentryline = j;
561 if (func->aexitline < j)
564 /* add it to the execution point */
565 ep = Safe_calloc(1,sizeof(exePoint));
566 ep->addr = mod->asmLines[j]->addr ;
568 addSet(&func->afpoints,ep);
573 if (!( D_sdcdb & sdcdbDebug))
576 Dprintf(D_sdcdb, ("sdcdb: function '%s' has the following C exePoints\n",
581 for (ep = setFirstItem(func->cfpoints); ep;
582 ep = setNextItem(func->cfpoints))
583 Dprintf(D_sdcdb, ("sdcdb: {0x%x,%d} %s",
584 ep->addr,ep->line+1,mod->cLines[ep->line]->src));
586 Dprintf(D_sdcdb, ("sdcdb: and the following ASM exePoints\n"));
587 for (ep = setFirstItem(func->afpoints); ep;
588 ep = setNextItem(func->afpoints))
589 Dprintf (D_sdcdb, ("sdcdb: {0x%x,%d} %s",
590 ep->addr,ep->line+1,mod->asmLines[ep->line]->src));
597 /*-----------------------------------------------------------------*/
598 /* setEntryExitBP - set the entry & exit Break Points for functions*/
599 /*-----------------------------------------------------------------*/
600 DEFSETFUNC(setEntryExitBP)
602 function *func = item;
604 if (func->sym && func->sym->addr && func->sym->eaddr) {
606 /* set the entry break point */
607 setBreakPoint (func->sym->addr , CODE , FENTRY ,
608 fentryCB ,func->mod->c_name , func->entryline);
610 /* set the exit break point */
611 setBreakPoint (func->sym->eaddr , CODE , FEXIT ,
612 fexitCB ,func->mod->c_name , func->exitline );
618 /*-----------------------------------------------------------------*/
619 /* cmdFile - load file into the debugger */
620 /*-----------------------------------------------------------------*/
621 int cmdFile (char *s,context *cctxt)
627 while (isspace(*s)) s++;
629 fprintf(stdout,"No exec file now.\nNo symbol file now.\n");
633 sprintf(buffer,"%s.cdb",s);
634 /* try creating the cdbfile */
635 if (!(cdbFile = searchDirsFopen(buffer))) {
636 fprintf(stdout,"Cannot open file\"%s\", no symbolic information loaded\n",buffer);
640 /* allocate for context */
641 currCtxt = Safe_calloc(1,sizeof(context));
644 /* readin the debug information */
645 if (!readCdb (cdbFile)) {
646 fprintf(stdout,"No symbolic information found in file %s.cdb\n",s);
651 /* parse and load the modules required */
654 /* determine the execution points for this
658 /* extract known special function registers */
659 specialFunctionRegs();
661 /* start the simulator & setup connection to it */
663 openSimulator((char **)simArgs,nsimArgs);
664 fprintf(stdout,"%s",simResponse());
665 /* now send the filename to be loaded to the simulator */
666 sprintf(buffer,"%s.ihx",s);
667 bp=searchDirsFname(buffer);
671 /*set the break points
672 required by the debugger . i.e. the function entry
673 and function exit break points */
674 applyToSet(functions,setEntryExitBP);
680 /*-----------------------------------------------------------------*/
681 /* cmdSource - read commands from file */
682 /*-----------------------------------------------------------------*/
683 int cmdSource (char *s, context *cctxt)
686 char *bp = s+strlen(s) -1;
691 while (isspace(*bp)) bp--;
694 if (!( cmdfile = searchDirsFopen(s)))
696 fprintf(stderr,"commandfile '%s' not found\n",s);
699 commandLoop( cmdfile );
704 /*-----------------------------------------------------------------*/
705 /* cmdHelp - help command */
706 /*-----------------------------------------------------------------*/
707 int cmdHelp (char *s, context *cctxt)
716 endline = ((*s - '0') * 20) + 20;
718 startline = endline - 20;
722 for (i = 0 ; i < (sizeof(cmdTab)/sizeof(struct cmdtab)) ; i++)
724 if ((cmdTab[i].htxt) && !strcmp(cmdTab[i].cmd,s))
726 s = strrchr(cmdTab[i].htxt,'\t');
731 fprintf(stdout,"%s",s);
738 for (i = 0 ; i < (sizeof(cmdTab)/sizeof(struct cmdtab)) ; i++) {
740 /* command string matches */
742 if ((cmdTab[i].htxt) && (i >= startline))
743 fprintf(stdout,"%s",cmdTab[i].htxt);
751 #define MAX_CMD_LEN 512
752 static char cmdbuff[MAX_CMD_LEN];
753 static int sim_cmd_mode = 0;
755 /*-----------------------------------------------------------------
756 interpretCmd - interpret and do the command. Return 0 to continue,
757 return 1 to exit program.
758 |-----------------------------------------------------------------*/
759 int interpretCmd (char *s)
761 static char *pcmd = NULL;
765 /* if nothing & previous command exists then
766 execute the previous command again */
767 if (*s == '\n' && pcmd)
770 /* if previous command exists & is different
771 from the current command then copy it */
773 if (strcmp(pcmd,s)) {
780 /* lookup the command table and do the task required */
784 if (strcmp(s,".") == 0) {
788 else if (s[0] == '.') {
789 /* kill the preceeding '.' and pass on as SDCDB command */
796 cmdSimulator (s, currCtxt);
800 if (strcmp(s,".") ==0) {
806 for (i = 0 ; i < (sizeof(cmdTab)/sizeof(struct cmdtab)) ; i++) {
808 /* command string matches */
809 if (strncmp(s,cmdTab[i].cmd,strlen(cmdTab[i].cmd)) == 0) {
810 if (!cmdTab[i].cmdfunc)
813 rv = (*cmdTab[i].cmdfunc)(s + strlen(cmdTab[i].cmd),currCtxt);
815 /* if full name then give the file name & position */
816 if (fullname && showfull && currCtxt && currCtxt->func) {
818 if (srcMode == SRC_CMODE)
819 fprintf(stdout,"\032\032%s:%d:1:beg:0x%08x\n",
820 currCtxt->func->mod->cfullname,
821 currCtxt->cline+1,currCtxt->addr);
823 fprintf(stdout,"\032\032%s:%d:1:beg:0x%08x\n",
824 currCtxt->func->mod->afullname,
825 currCtxt->asmline,currCtxt->addr);
826 displayAll(currCtxt);
832 fprintf(stdout,"Undefined command: \"%s\". Try \"help\".\n",s);
837 static FILE *actualcmdfile=NULL ;
838 static char *actualcmds=NULL;
839 static int stopcmdlist;
840 /*-----------------------------------------------------------------*/
841 /* getNextCmdLine get additional lines used by special commands */
842 /*-----------------------------------------------------------------*/
843 char *getNextCmdLine()
847 if (fgets(cmdbuff,sizeof(cmdbuff),actualcmdfile) == NULL)
852 void setCmdLine( char *cmds )
857 void stopCommandList()
862 /*-----------------------------------------------------------------*/
863 /* commandLoop - the main command loop or loop over command file */
864 /*-----------------------------------------------------------------*/
865 static void commandLoop(FILE *cmdfile)
867 char *line, save_ch, *s;
868 actualcmdfile = cmdfile;
871 if ( cmdfile == stdin )
876 fprintf(stdout,"(sdcdb) ");
880 if (fgets(cmdbuff,sizeof(cmdbuff),cmdfile) == NULL)
883 if (interpretCmd(cmdbuff))
888 strcpy(cmdbuff,actualcmds);
891 for ( line = cmdbuff; *line ; line = s )
893 if ( (s=strchr(line ,'\n')))
903 if (interpretCmd( line ))
916 /*-----------------------------------------------------------------*/
917 /* printVersionInfo - print the version information */
918 /*-----------------------------------------------------------------*/
919 static void printVersionInfo()
922 "SDCDB is free software and you are welcome to distribute copies of it\n"
923 "under certain conditions; type \"show copying\" to see the conditions.\n"
924 "There is absolutely no warranty for SDCDB; type \"show warranty\" for details.\n"
925 "SDCDB 0.8 . Copyright (C) 1999 Sandeep Dutta (sandeep.dutta@usa.net)\n"
926 "Type ? for help\n");
930 /*-----------------------------------------------------------------*/
931 /* parseCmdLine - parse the commandline arguments */
932 /*-----------------------------------------------------------------*/
933 static void parseCmdLine (int argc, char **argv)
936 char *filename = NULL;
937 int passon_args_flag = 0; /* if true, pass on args to simulator */
939 Dprintf(D_sdcdb, ("sdcdb: parseCmdLine\n"));
942 for ( i = 1; i < argc ; i++) {
943 //fprintf(stdout,"%s\n",argv[i]);
945 if (passon_args_flag) { /* if true, pass on args to simulator */
946 simArgs[nsimArgs++] = strdup(argv[i]);
950 /* if this is an option */
951 if (argv[i][0] == '-') {
953 /* if directory then mark directory */
954 if (strncmp(argv[i],"--directory=",12) == 0) {
956 ssdirl = &argv[i][12];
958 char *p = Safe_malloc(strlen(ssdirl)+strlen(&argv[i][12])+2);
959 strcat(strcat(strcpy(p,&argv[i][12]),":"),ssdirl);
965 if (strncmp(argv[i],"-fullname",9) == 0) {
970 if (strcmp(argv[i],"-cd") == 0) {
976 if (strncmp(argv[i],"-cd=",4) == 0) {
982 if (strncmp(argv[i],"-d=",3) == 0) {
983 sdcdbDebug = strtol(&argv[i][3],0,0);
987 if (strncmp(argv[i],"-contsim",8) == 0) {
991 if (strncmp(argv[i],"-q",2) == 0) {
996 if (strncmp(argv[i],"-m",2) == 0) {
997 strncpy(model_str, &argv[i][2], 15);
998 if (strcmp(model_str,"avr") == 0)
1000 else if (strcmp(model_str,"xa") == 0)
1002 else if (strcmp(model_str,"z80") == 0)
1003 simArgs[0] = "sz80";
1007 /* -z all remaining options are for simulator */
1008 if (strcmp(argv[i],"-z") == 0) {
1009 passon_args_flag = 1;
1013 /* the simulator arguments */
1016 if (strcmp(argv[i],"-t") == 0 ||
1017 strcmp(argv[i],"-cpu") == 0) {
1019 simArgs[nsimArgs++] = "-t";
1020 simArgs[nsimArgs++] = strdup(argv[++i]);
1024 /* XTAL Frequency */
1025 if (strcmp(argv[i],"-X") == 0 ||
1026 strcmp(argv[i],"-frequency") == 0) {
1027 simArgs[nsimArgs++] = "-X";
1028 simArgs[nsimArgs++] = strdup(argv[++i]);
1033 if ( (strcmp(argv[i],"-S") == 0) ||
1034 (strcmp(argv[i],"-s") == 0)) {
1035 simArgs[nsimArgs++] = strdup(argv[i]);
1036 simArgs[nsimArgs++] = strdup(argv[++i]);
1040 fprintf(stderr,"unknown option %s --- ignored\n",
1044 /* must be file name */
1046 fprintf(stderr,"too many filenames .. parameter '%s' ignored\n",
1051 filename = strtok(argv[i],".");
1057 cmdFile(filename,NULL);
1060 /*-----------------------------------------------------------------*/
1061 /* setsignals - catch some signals */
1062 /*-----------------------------------------------------------------*/
1075 /* may be interrupt from user: stop debugger and also simulator */
1081 /* the only child can be the simulator */
1082 static void sigchld(int sig)
1084 /* the only child can be the simulator */
1086 retpid = wait ( &status );
1087 /* if ( retpid == simPid ) */
1094 signal(SIGHUP , bad_signal);
1095 signal(SIGINT , sigintr );
1096 signal(SIGTERM, bad_signal);
1097 signal(SIGCHLD, sigchld );
1099 signal(SIGABRT, bad_signal);
1100 signal(SIGALRM, bad_signal);
1101 //signal(SIGFPE, bad_signal);
1102 //signal(SIGILL, bad_signal);
1103 signal(SIGPIPE, bad_signal);
1104 signal(SIGQUIT, bad_signal);
1105 //signal(SIGSEGV, bad_signal);
1108 /*-----------------------------------------------------------------*/
1110 /*-----------------------------------------------------------------*/
1112 int main ( int argc, char **argv)
1115 printf("WARNING: SDCDB is EXPERIMENTAL.\n");
1117 simArgs[nsimArgs++] = "s51";
1118 simArgs[nsimArgs++] = "-P";
1119 simArgs[nsimArgs++] = "-r 9756";
1120 /* parse command line */
1123 parseCmdLine(argc,argv);