Annotation of researchv8dc/cmd/adb/runpcs.c, revision 1.1

1.1     ! root        1: #
        !             2: /*
        !             3:  *
        !             4:  *     UNIX debugger
        !             5:  *
        !             6:  */
        !             7: 
        !             8: #include "defs.h"
        !             9: #include <signal.h>
        !            10: #include "regs.h"
        !            11: 
        !            12: MSG    ENDPCS;
        !            13: 
        !            14: BKPT *bkpthead;
        !            15: 
        !            16: BOOL bpin;
        !            17: 
        !            18: int pid;
        !            19: int sigcode, signo;
        !            20: 
        !            21: /* service routines for sub process control */
        !            22: 
        !            23: runpcs(runmode, keepsig)
        !            24: {
        !            25:        register int rc;
        !            26:        register BKPT *bkpt;
        !            27: 
        !            28:        if (adrflg)
        !            29:                ;       /* something = dot */
        !            30:        printf("%s: running\n", symfil);
        !            31:        while (--loopcnt >= 0) {
        !            32:                rrest();
        !            33:                if (runmode == SINGLE)
        !            34:                        runstep(keepsig);
        !            35:                else {
        !            36:                        if ((bkpt = scanbkpt((ADDR)rtow(rget(PC)))) != NULL) {
        !            37:                                execbkpt(bkpt, keepsig);
        !            38:                                keepsig = 0;
        !            39:                        }
        !            40:                        setbp();
        !            41:                        runrun(keepsig);
        !            42:                }
        !            43:                bpwait();
        !            44:                chkerr();
        !            45:                keepsig = 0;
        !            46:                delbp();
        !            47:                if (signo != 0 || (bkpt = scanbkpt((ADDR)rtow(rget(PC)))) == NULL) {
        !            48:                        keepsig = 1;
        !            49:                        rc = 0;
        !            50:                        continue;
        !            51:                }
        !            52:                /* breakpoint */
        !            53:                dot = bkpt->loc;
        !            54:                if (bkpt->flag == BKPTSKIP) {
        !            55:                        execbkpt(bkpt, keepsig);
        !            56:                        keepsig = 0;
        !            57:                        loopcnt++;      /* we didn't really stop */
        !            58:                        continue;
        !            59:                }
        !            60:                bkpt->flag = BKPTSKIP;
        !            61:                if (bkpt->comm[0] != EOR
        !            62:                &&  command(bkpt->comm, ':') == 0
        !            63:                &&  --bkpt->count == 0) {
        !            64:                        execbkpt(bkpt, keepsig);
        !            65:                        keepsig = 0;
        !            66:                        loopcnt++;
        !            67:                        continue;
        !            68:                }
        !            69:                bkpt->count = bkpt->initcnt;
        !            70:                rc = 1;
        !            71:        }
        !            72:        return(rc);
        !            73: }
        !            74: 
        !            75: /*
        !            76:  * finish the process off;
        !            77:  * kill if still running
        !            78:  */
        !            79: 
        !            80: endpcs()
        !            81: {
        !            82:        register BKPT *bk;
        !            83: 
        !            84:        if (pid) {
        !            85:                killpcs();
        !            86:                pid=0;
        !            87:                for (bk=bkpthead; bk; bk = bk->nxtbkpt)
        !            88:                        if (bk->flag != BKPTCLR)
        !            89:                                bk->flag = BKPTSET;
        !            90:        }
        !            91:        bpin = FALSE;
        !            92: }
        !            93: 
        !            94: /*
        !            95:  * start up the program to be debugged in a child
        !            96:  */
        !            97: 
        !            98: setup()
        !            99: {
        !           100: 
        !           101:        startpcs();
        !           102:        if (errflg) {
        !           103:                printf("%s: cannot execute\n", symfil);
        !           104:                endpcs();
        !           105:                error(0);
        !           106:        }
        !           107:        bpin = FALSE;
        !           108: }
        !           109: 
        !           110: /*
        !           111:  * skip over a breakpoint:
        !           112:  * remove breakpoints, then single step
        !           113:  * so we can put it back
        !           114:  */
        !           115: execbkpt(bk, keepsig)
        !           116: BKPT *bk;
        !           117: {
        !           118:        runstep(keepsig);
        !           119:        bk->flag = BKPTSET;
        !           120:        bpwait();
        !           121:        chkerr();
        !           122: }
        !           123: 
        !           124: /*
        !           125:  * find the breakpoint at adr, if any
        !           126:  */
        !           127: 
        !           128: BKPT *
        !           129: scanbkpt(adr)
        !           130: ADDR adr;
        !           131: {
        !           132:        register BKPT *bk;
        !           133: 
        !           134:        for (bk = bkpthead; bk; bk = bk->nxtbkpt)
        !           135:                if (bk->flag != BKPTCLR && bk->loc == adr)
        !           136:                        break;
        !           137:        return(bk);
        !           138: }
        !           139: 
        !           140: /*
        !           141:  * remove all breakpoints from the process' address space
        !           142:  */
        !           143: 
        !           144: delbp()
        !           145: {
        !           146:        register BKPT *bk;
        !           147: 
        !           148:        if (bpin == FALSE || pid == 0)
        !           149:                return;
        !           150:        for (bk = bkpthead; bk; bk = bk->nxtbkpt)
        !           151:                if (bk->flag != BKPTCLR)
        !           152:                        bkput(bk, 0);
        !           153:        bpin = FALSE;
        !           154: }
        !           155: 
        !           156: /*
        !           157:  * install all the breakpoints
        !           158:  */
        !           159: 
        !           160: setbp()
        !           161: {
        !           162:        register BKPT *bk;
        !           163: 
        !           164:        if (bpin == TRUE || pid == 0)
        !           165:                return;
        !           166:        for (bk = bkpthead; bk; bk = bk->nxtbkpt)
        !           167:                if (bk->flag != BKPTCLR)
        !           168:                        bkput(bk, 1);
        !           169:        bpin = TRUE;
        !           170: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.