130296Ssam /* 238917Skarels * Copyright (c) 1986, 1989 Regents of the University of California. 330296Ssam * All rights reserved. The Berkeley software License Agreement 430296Ssam * specifies the terms and conditions for redistribution. 530296Ssam * 6*41340Ssklower * @(#)kdb_pcs.c 7.4 (Berkeley) 05/03/90 730296Ssam */ 830110Ssam 930110Ssam #include "../kdb/defs.h" 1030110Ssam 11*41340Ssklower char *kdbNOBKPT; 12*41340Ssklower char *kdbSZBKPT; 13*41340Ssklower char *kdbEXBKPT; 14*41340Ssklower char *kdbBADMOD; 1530110Ssam 1630110Ssam /* breakpoints */ 17*41340Ssklower BKPTR kdbbkpthead; 1830110Ssam 19*41340Ssklower char *kdblp; 20*41340Ssklower char kdblastc; 2130296Ssam extern char *kdbmalloc(); 22*41340Ssklower long kdbloopcnt; 2330110Ssam 2430110Ssam /* sub process control */ 2530110Ssam kdbsubpcs(modif)26*41340Ssklowerkdbsubpcs(modif) 2730110Ssam { 2830110Ssam register check, runmode; 2930110Ssam register BKPTR bkptr; 3030110Ssam register char *comptr; 3130110Ssam 32*41340Ssklower kdbloopcnt=kdbcntval; 3330110Ssam switch (modif) { 3430110Ssam 3530110Ssam /* delete breakpoint */ 3630110Ssam case 'd': case 'D': 37*41340Ssklower if (bkptr=kdbscanbkpt((ADDR)kdbdot)) { 3830110Ssam bkptr->flag=0; 3930110Ssam return; 4030110Ssam } 41*41340Ssklower kdberror(kdbNOBKPT); 4230110Ssam 4330110Ssam /* set breakpoint */ 4430110Ssam case 'b': case 'B': 45*41340Ssklower if (bkptr=kdbscanbkpt((ADDR)kdbdot)) 4630110Ssam bkptr->flag=0; 47*41340Ssklower for (bkptr=kdbbkpthead; bkptr; bkptr=bkptr->nxtbkpt) 4830110Ssam if (bkptr->flag == 0) 4930110Ssam break; 5030110Ssam if (bkptr==0) { 5130110Ssam bkptr=(BKPTR)kdbmalloc(sizeof *bkptr); 5230110Ssam if (bkptr == (BKPTR)-1) 53*41340Ssklower kdberror(kdbSZBKPT); 54*41340Ssklower bkptr->nxtbkpt=kdbbkpthead; 55*41340Ssklower kdbbkpthead=bkptr; 5630110Ssam } 57*41340Ssklower bkptr->loc = kdbdot; 58*41340Ssklower bkptr->initcnt = bkptr->count = kdbcntval; 5930110Ssam bkptr->flag = BKPTSET; 60*41340Ssklower check=MAXCOM-1; comptr=bkptr->comm; (void) kdbrdc(); kdblp--; 6130110Ssam do 62*41340Ssklower *comptr++ = kdbreadchar(); 63*41340Ssklower while (check-- && kdblastc!=EOR); 64*41340Ssklower *comptr=0; kdblp--; 6530110Ssam if (check) 6630110Ssam return; 67*41340Ssklower kdberror(kdbEXBKPT); 6830110Ssam 6930110Ssam /* single step */ 7030110Ssam case 's': case 'S': 7130110Ssam runmode=SINGLE; 7230110Ssam break; 7330110Ssam 7430110Ssam /* continue */ 7530110Ssam case 'c': case 'C': 7630110Ssam runmode=CONTIN; 7730110Ssam break; 7830110Ssam 7938917Skarels /* kill */ 8038917Skarels case 'k': case 'K': 8138917Skarels reset(PANIC); 8238917Skarels /* NOTREACHED */ 8338917Skarels 8430110Ssam default: 85*41340Ssklower kdberror(kdbBADMOD); 8630110Ssam } 87*41340Ssklower if (kdbloopcnt>0) 88*41340Ssklower kdbrunpcs(runmode, 0); 8930110Ssam } 90