void colon(char *addr, char *cp) { int argc; char *argv[100]; char tbuf[512]; cp = nextc(cp); switch(*cp) { default: Bprint(bioout, "?\n"); return; case 'b': breakpoint(addr, cp+1); return; case 'd': delbpt(addr); return; /* These fall through to print the stopped address */ case 'r': reset(); argc = buildargv(cp+1, argv, 100); initstk(argc, argv); count = 0; atbpt = 0; run(); break; case 'c': count = 0; atbpt = 0; run(); break; case 's': cp = nextc(cp+1); count = 0; if(*cp) count = strtoul(cp, 0, 0); if(count == 0) count = 1; atbpt = 0; run(); break; } dot = reg.pc; Bprint(bioout, "%s at #%lux ", atbpt ? "breakpoint" : "stopped", dot); symoff(tbuf, sizeof(tbuf), dot, CTEXT); Bprint(bioout, tbuf); if(fmt == 'z') printsource(dot); Bprint(bioout, "\n"); }
static long progwrite(Chan *c, void *va, long n, vlong offset) { Prog *p, *f; Heapqry *hq; char buf[512]; Progctl *ctl; char *b; int i, pc; Cmdbuf *cb; Cmdtab *ct; USED(offset); USED(va); if(c->qid.type & QTDIR) error(Eisdir); acquire(); if(waserror()) { release(); nexterror(); } p = progpid(PID(c->qid)); if(p == nil) error(Ethread); switch(QID(c->qid)){ case Qctl: cb = parsecmd(va, n); if(waserror()){ free(cb); nexterror(); } ct = lookupcmd(cb, progcmd, nelem(progcmd)); switch(ct->index){ case CMkillgrp: killgrp(p, "killed"); break; case CMkill: killprog(p, "killed"); break; case CMrestricted: p->flags |= Prestrict; break; case CMexceptions: if(p->group->id != p->pid) error(Eperm); if(strcmp(cb->f[1], "propagate") == 0) p->flags |= Ppropagate; else if(strcmp(cb->f[1], "notifyleader") == 0) p->flags |= Pnotifyleader; else error(Ebadctl); break; case CMprivate: p->group->flags |= Pprivatemem; break; } poperror(); free(cb); break; case Qdbgctl: cb = parsecmd(va, n); if(waserror()){ free(cb); nexterror(); } if(cb->nf == 1 && strncmp(cb->f[0], "step", 4) == 0) ct = progdbgcmd; else ct = lookupcmd(cb, progdbgcmd, nelem(progdbgcmd)); switch(ct->index){ case CDstep: if(cb->nf == 1) i = strtoul(cb->f[0]+4, nil, 0); else i = strtoul(cb->f[1], nil, 0); dbgstep(c->aux, p, i); break; case CDtoret: f = currun(); i = calldepth(&p->R); while(f->kill == nil) { dbgstep(c->aux, p, 1024); if(i > calldepth(&p->R)) break; } break; case CDcont: f = currun(); while(f->kill == nil) dbgstep(c->aux, p, 1024); break; case CDstart: dbgstart(p); break; case CDstop: ctl = c->aux; ctl->stop = 1; break; case CDunstop: ctl = c->aux; ctl->stop = 0; break; case CDbpt: pc = strtoul(cb->f[3], nil, 10); ctl = c->aux; if(strcmp(cb->f[1], "set") == 0) ctl->bpts = setbpt(ctl->bpts, cb->f[2], pc); else if(strcmp(cb->f[1], "del") == 0) ctl->bpts = delbpt(ctl->bpts, cb->f[2], pc); else error(Ebadctl); break; case CDmaim: p->kill = "maim"; break; } poperror(); free(cb); break; case Qheap: /* * Heap query: * addr.Fn * pc+module.In */ i = n; if(i > sizeof(buf)-1) i = sizeof(buf)-1; memmove(buf, va, i); buf[i] = '\0'; hq = c->aux; hq->addr = strtoul(buf, &b, 0); if(*b == '+') hq->module = strtoul(b, &b, 0); if(*b++ != '.') error(Ebadctl); hq->fmt = *b++; hq->count = strtoul(b, nil, 0); break; default: print("unknown qid in procwrite\n"); error(Egreg); } poperror(); release(); return n; }