2 * functions for running the debugged process
20 if(pid && pid != pcspid){
30 sprint(buf, "/proc/%d/ctl", pid);
31 msgfd = open(buf, OWRITE);
33 error("can't open control file");
34 sprint(buf, "/proc/%d/note", pid);
35 notefd = open(buf, ORDWR);
37 error("can't open note file");
48 if(write(msgfd, msg, strlen(msg)) < 0 && !ending){
49 errstr(err, sizeof err);
50 if(strcmp(err, "interrupted") != 0)
52 errors("can't write control file", err);
57 * empty the note buffer and toss pending breakpoint notes
65 for(; nnote<NNOTE; nnote++){
66 switch(read(notefd, note[nnote], sizeof note[nnote])){
68 errstr(err, sizeof err);
69 if(strcmp(err, "interrupted") != 0)
71 errors("can't read note file", err);
75 note[nnote][ERRMAX-1] = '\0';
76 if(strncmp(note[nnote], "sys: breakpoint", 15) == 0)
82 * reload the note buffer
91 for(i=0; i<nnote; i++){
92 if(write(notefd, note[i], strlen(note[i])) < 0){
93 errstr(err, sizeof err);
94 if(strcmp(err, "interrupted") != 0)
96 errors("can't write note file", err);
110 for(n=0; n<nnote; n++)
111 dprint("%d:\t%s\n", n, note[n]);
146 for (rdc(); lastc != EOR;) {
148 if (lastc == '<' || lastc == '>') {
152 while (lastc != EOR && lastc != SPC && lastc != TB) {
156 if (lastc == SPC || lastc == TB)
159 if (*thisarg == '<') {
161 if (open(&thisarg[1], OREAD) < 0) {
162 print("%s: cannot open\n", &thisarg[1]);
166 else if (*thisarg == '>') {
168 if (create(&thisarg[1], OWRITE, 0666) < 0) {
169 print("%s: cannot create\n", &thisarg[1]);
186 if ((pid = fork()) == 0) {
196 sprint(procname, "/proc/%d/mem", pid);
201 rput(cormap, mach->pc, adrval);
208 runstep(uvlong loc, int keepnote)
215 if(machdata->foll == 0){
216 dprint("stepping unimplemented; assuming not a branch\n");
218 foll[0] = loc+mach->pcquant;
220 nfoll = machdata->foll(cormap, loc, rget, foll);
224 memset(bkpt, 0, sizeof bkpt);
225 for(i=0; i<nfoll; i++){
227 error("can't single step: next instruction is dot");
228 bkpt[i].loc = foll[i];
232 for(i=0; i<nfoll; i++)
252 error("not running: new notes pending");
264 bkput(BKPT *bp, int install)
270 errstr(buf, sizeof buf);
272 loc = (*machdata->bpfix)(bp->loc);
276 ret = get1(cormap, loc, bp->save, machdata->bpsize);
278 ret = put1(cormap, loc, machdata->bpinst, machdata->bpsize);
280 ret = put1(cormap, loc, bp->save, machdata->bpsize);
282 sprint(buf, "can't set breakpoint at %#llux: %r", bp->loc);