📄 main.c
字号:
* we read the temp file as commands. This isn't always the right thing; * if a procedure that was being traced is deleted, an error message * will be generated. * * If the argument vector is not nil, then this is re-initialize is being * done in preparation for running the program. Since we want to process * the commands in the temp file before running the program, we add the * run command at the end of the temp file. In this case, reinit longjmps * back to parsing rather than returning. */public reinit(argv, infile, outfile)String *argv;String infile;String outfile;{ register Integer i; String tmpfile; extern String mktemp(); tmpfile = mktemp("/tmp/dbxXXXX"); setout(tmpfile); alias(nil, nil, nil, false); /* the vpdeclare command was removed lrm 9/26/90 if(vectorcapable && vector_context()) printf("vpdeclare\n"); */ if(needruncmd){ if (argv != nil) { printf("run"); for (i = 1; argv[i] != nil; i++) { printf(" %s", argv[i]); } if (infile != nil) { printf(" < %s", infile); } if (outfile != nil) { printf(" > %s", outfile); } putchar('\n'); } } unsetout(); objfree(); OpInit(); symbols_init(); process_init(); enterkeywords(); scanner_init(); readobj(objname); bpinit(needruncmd); fflush(stdout); setinput(tmpfile); unlink(tmpfile); if (argv != nil) { longjmp(env, 1); /* NOTREACHED */ }}/* * After a non-fatal error we skip the rest of the current input line, and * jump back to command parsing. */public erecover(){ if (initdone) { gobble(); longjmp(env, 1); }}/* * This routine is called when an interrupt occurs. */private void catchintr(){ if (isredirected()) { fflush(stdout); unsetout(); } putchar('\n'); longjmp(env, 1);}/* * Scan the argument list. */private scanargs(argc, argv)int argc;String argv[];{ register int i, j; register Boolean foundfile; register File f; char *tmp; runfirst = false; interactive = false; lexdebug = false; tracebpts = false; traceexec = false; traceeval = false; tracesyms = false; tracefuncs = false; traceblocks = false; xdb = false; /* 007 - DNM */ vaddrs = false; foundfile = false; corefile = nil; coredump = true; vectorcapable = true; is_vector_capable(); found_a_vec_inst = false; sourcepath = list_alloc(); list_append(list_item("."), nil, sourcepath); i = 1; while (i < argc and (not foundfile or (coredump and corefile == nil))) { if (argv[i][0] == '-') { if (streq(argv[i], "-I")) { ++i; if (i >= argc) { fatal("missing directory for -I"); } list_append(list_item(argv[i]), nil, sourcepath); } else if (streq(argv[i], "-c")) { ++i; if (i >= argc) { fatal("missing command file name for -c"); } initfile = argv[i]; } else if (streq(argv[i], "-x")) { /* 009 - DNM */ ++i; if (i >= argc) { fatal("missing terminal emulator name for -x"); } xdb = true; interactive = true; xdbpath = argv[i]; } else { for (j = 1; argv[i][j] != '\0'; j++) { setoption(argv[i][j]); } } } else if (not foundfile) { objname = argv[i]; foundfile = true; } else if (coredump and corefile == nil) { corefile = fopen(argv[i], "r"); corename = argv[i]; if (corefile == nil) { coredump = false; } } ++i; } if (i < argc and not runfirst) { fatal("extraneous argument %s", argv[i]); } firstarg = i; if (not foundfile and isatty(0)) { printf("enter object file name (default is `%s'): ", objname);noobj: fflush(stdout); gets(namebuf); if (namebuf[0] != '\0') { objname = namebuf; } else { if(objname[0] == '\0') { exit(0); } } } f = fopen(objname, "r"); if (f == nil) { printf("can't read %s\n", objname); strcpy(objname, ""); printf("enter object file name (<cr> to exit): "); goto noobj; } else { fclose(f); } if (rindex(objname, '/') != nil) { tmp = strdup(objname); *(rindex(tmp, '/')) = '\0'; list_append(list_item(tmp), nil, sourcepath); } if (coredump and corefile == nil) { if (vaddrs) { corefile = fopen("/dev/mem", "r"); corename = "/dev/mem"; if (corefile == nil) { panic("can't open /dev/mem"); } } else { corefile = fopen("core", "r"); corename = "core"; if (corefile == nil) { coredump = false; } } }}/* * Take appropriate action for recognized command argument. */private setoption(c)char c;{ switch (c) { case 'r': /* run program before accepting commands */ runfirst = true; coredump = false; break; case 'i': interactive = true; break;# ifdef INHOUSE /* inhouse debugging switches */ case 'b': tracebpts = true; break; case 'e': traceexec = true; break; case 'v': traceeval = true; break; case 's': tracesyms = true; break; case 'n': traceblocks = true; break; case 'f': tracefuncs = true; break;# endif case 'k': vaddrs = true; break; case 'l':# ifdef LEXDEBUG lexdebug = true;# else fatal("\"-l\" only applicable when compiled with LEXDEBUG");# endif break; default: fatal("unknown option '%c'", c); }}/* * Save/restore the state of a tty. */public savetty(f, t)File f;Ttyinfo *t;{ ioctl(fileno(f), TIOCGETP, &(t->sg)); ioctl(fileno(f), TIOCGETC, &(t->tc)); ioctl(fileno(f), TIOCGLTC, &(t->ltc)); ioctl(fileno(f), TIOCGETD, &(t->ldisc)); ioctl(fileno(f), TIOCLGET, &(t->local)); t->fcflags = fcntl(fileno(f), F_GETFL, 0);}public restoretty(f, t)File f;Ttyinfo *t;{ ioctl(fileno(f), TIOCSETN, &(t->sg)); ioctl(fileno(f), TIOCSETC, &(t->tc)); ioctl(fileno(f), TIOCSLTC, &(t->ltc)); ioctl(fileno(f), TIOCSETD, &(t->ldisc)); ioctl(fileno(f), TIOCLSET, &(t->local)); (void) fcntl(fileno(f), F_SETFL, t->fcflags);}/* * Exit gracefully. */public quit(r)Integer r;{ pterm(process); exit(r);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -