setup() { close(fsym); fsym = -1; #ifndef VFORK IF (pid = fork()) == 0 #else IF (pid = vfork()) == 0 #endif THEN ptrace(PT_TRACE_ME,0,0,0); #ifdef VFORK signal(SIGTRAP,nullsig); #endif signal(SIGINT,sigint); signal(SIGQUIT,sigqit); doexec(); exit(0); ELIF pid == -1 THEN error(NOFORK); ELSE bpwait(); readregs(); lp[0]=EOR; lp[1]=0; fsym=open(symfil,wtflag); IF errflg THEN printf("%s: cannot execute\n",symfil); endpcs(); error(0); FI FI bpstate=BPOUT; }
void grab(void) { flush(); msgpcs("stop"); bpwait(); }
runpcs(runmode,execsig) { INT rc; REG BKPTR bkpt; IF adrflg THEN userpc=dot; FI printf("%s: running\n", symfil); WHILE --loopcnt>=0 DO #ifdef DEBUG printf("\ncontinue %x %d\n",userpc,execsig); #endif IF runmode==SINGLE THEN delbp(); /* hardware handles single-stepping */ ELSE /* continuing from a breakpoint is hard */ IF bkpt=scanbkpt(userpc) THEN execbkpt(bkpt,execsig); execsig=0; FI setbp(); FI ptrace(runmode,pid,userpc,execsig); bpwait(); chkerr(); execsig=0; delbp(); readregs(); IF signo==0 ANDF runmode != SINGLE #ifdef mc68000 ANDF (bkpt=scanbkpt(userpc - 2)) /* argh */ #else ANDF (bkpt=scanbkpt(userpc)) #endif THEN /* stopped by BPT instruction */ #ifdef DEBUG printf("\n BPT code; '%s'%o'%o'%d", bkpt->comm,bkpt->comm[0],EOR,bkpt->flag); #endif dot=bkpt->loc; userpc = dot; *(ADDR *)(((ADDR)&u)+PC-getradj(1)) = userpc; IF bkpt->flag==BKPTEXEC ORF ((bkpt->flag=BKPTEXEC) ANDF bkpt->comm[0]!=EOR ANDF command(bkpt->comm,':') ANDF --bkpt->count) THEN execbkpt(bkpt,execsig); execsig=0; loopcnt++; ELSE bkpt->count=bkpt->initcnt; rc=1; FI ELSE execsig=signo; rc=0; FI OD return(rc); }
void runrun(int keepnote) { int on; on = nnote; unloadnote(); if(on != nnote){ notes(); error("not running: new notes pending"); } if(keepnote) loadnote(); else nnote = 0; flush(); msgpcs("startstop"); bpwait(); }
void startpcs(void) { if ((pid = fork()) == 0) { pid = getpid(); msgpcs("hang"); doexec(); exits(0); } if (pid == -1) error("can't fork"); child++; sprint(procname, "/proc/%d/mem", pid); corfil = procname; msgpcs("waitstop"); bpwait(); if (adrflg) rput(cormap, mach->pc, adrval); while (rdc() != EOR) ; reread(); }