diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd/acid/builtin.c | 26 | ||||
-rw-r--r-- | src/cmd/acid/expr.c | 6 | ||||
-rw-r--r-- | src/cmd/acid/main.c | 127 |
3 files changed, 21 insertions, 138 deletions
diff --git a/src/cmd/acid/builtin.c b/src/cmd/acid/builtin.c index 8dbc1765..195834d3 100644 --- a/src/cmd/acid/builtin.c +++ b/src/cmd/acid/builtin.c @@ -332,12 +332,12 @@ xregister(Node *r, Node *args) na = 0; flatten(av, args); - if(na != 1 && na != 2) - error("register(name[, threadid]): arg count"); + if(na != 1/* && na != 2 */) + error("register(name): arg count"); expr(av[0], &res); if(res.type != TSTRING) - error("register(name[, threadid]): arg type: name should be string"); + error("register(name): arg type: name should be string"); tid = 0; if(na == 2){ expr(av[1], &resid); @@ -1139,7 +1139,7 @@ patom(char type, Store *res) switch(type){ case TREG: if(res->u.reg.thread) - Bprint(bout, "register(\"%s\", 0x%ux)", res->u.reg.name, res->u.reg.thread); + Bprint(bout, "register(\"%s\", %#ux)", res->u.reg.name, res->u.reg.thread); else Bprint(bout, "register(\"%s\")", res->u.reg.name); return; @@ -1221,16 +1221,16 @@ patom(char type, Store *res) Bprint(bout, "%s", buf); break; case 'b': - Bprint(bout, "%.2x", (int)res->u.ival&0xff); + Bprint(bout, "%#.2x", (int)res->u.ival&0xff); break; case 'X': - Bprint(bout, "%.8lux", (ulong)res->u.ival); + Bprint(bout, "%#.8lux", (ulong)res->u.ival); break; case 'x': - Bprint(bout, "%.4lux", (ulong)res->u.ival&0xffff); + Bprint(bout, "%#.4lux", (ulong)res->u.ival&0xffff); break; case 'W': - Bprint(bout, "%.16llux", res->u.ival); + Bprint(bout, "%#.16llux", res->u.ival); break; case 'D': Bprint(bout, "%d", (int)res->u.ival); @@ -1251,19 +1251,19 @@ patom(char type, Store *res) Bprint(bout, "%lld", res->u.ival); break; case 'Y': - Bprint(bout, "%.16llux", res->u.ival); + Bprint(bout, "%#.16llux", res->u.ival); break; case 'o': - Bprint(bout, "0%.11uo", (int)res->u.ival&0xffff); + Bprint(bout, "%#.11uo", (int)res->u.ival&0xffff); break; case 'O': - Bprint(bout, "0%.6uo", (int)res->u.ival); + Bprint(bout, "%#.6uo", (int)res->u.ival); break; case 'q': - Bprint(bout, "0%.11o", (short)(res->u.ival&0xffff)); + Bprint(bout, "%#.11o", (short)(res->u.ival&0xffff)); break; case 'Q': - Bprint(bout, "0%.6o", (int)res->u.ival); + Bprint(bout, "%#.6o", (int)res->u.ival); break; case 'f': case 'F': diff --git a/src/cmd/acid/expr.c b/src/cmd/acid/expr.c index 822d7bb8..2330c430 100644 --- a/src/cmd/acid/expr.c +++ b/src/cmd/acid/expr.c @@ -135,7 +135,7 @@ oindm(Node *n, Node *res) res->store.comt = l.store.comt; break; case TREG: - indirreg(threadregs(l.store.u.reg.thread), l.store.u.reg.name, l.store.fmt, res); + indirreg(correg, l.store.u.reg.name, l.store.fmt, res); res->store.comt = l.store.comt; break; case TCON: @@ -334,7 +334,7 @@ oasgn(Node *n, Node *res) case OINDM: expr(lp->left, &aes); if(aes.type == TREG) - windirreg(threadregs(aes.store.u.reg.thread), aes.store.u.reg.name, n->right, res); + windirreg(correg, aes.store.u.reg.name, n->right, res); else windir(cormap, aes, n->right, res); break; @@ -1097,7 +1097,7 @@ acidregsrw(Regs *r, char *name, ulong *u, int isr) werrstr("*%s: register %s not mapped", name, v->store.u.reg); return -1; } - return rget(threadregs(v->store.u.reg.thread), v->store.u.reg.name, u); + return rget(correg, v->store.u.reg.name, u); case TCON: n = v->store.u.con; if(n->op != OCONST || n->type != TINT){ diff --git a/src/cmd/acid/main.c b/src/cmd/acid/main.c index e885b01d..9c9c0262 100644 --- a/src/cmd/acid/main.c +++ b/src/cmd/acid/main.c @@ -93,7 +93,6 @@ main(int argc, char *argv[]) usage(); }ARGEND - fmtinstall('x', xfmt); fmtinstall('Z', Zfmt); fmtinstall('L', locfmt); Binit(&bioout, 1, OWRITE); @@ -191,126 +190,17 @@ setstring(char *var, char *s) static int attachfiles(int argc, char **argv) { - int fd; volatile int pid; - char *s, *t; - int i, omode; - Fhdr *hdr; Lsym *l; pid = 0; interactive = 0; + if(setjmp(err)) return -1; - /* - * Unix and Plan 9 differ on what the right order of pid, text, and core is. - * I never remember anyway. Let's just accept them in any order. - */ - omode = wtflag ? ORDWR : OREAD; - for(i=0; i<argc; i++){ - if(isnumeric(argv[i])){ - if(pid){ - fprint(2, "already have pid %d; ignoring pid %d\n", pid, argv[i]); - continue; - } - if(corhdr){ - fprint(2, "already have core %s; ignoring pid %d\n", corfil, pid); - continue; - } - pid = atoi(argv[i]); - continue; - } - if((hdr = crackhdr(argv[i], omode)) == nil){ - fprint(2, "crackhdr %s: %r\n", argv[i]); - if(argc == 1 && (fd = open(argv[i], omode)) > 0){ - fprint(2, "loading %s direct mapped\n", argv[i]); - symmap = dumbmap(fd); - cormap = dumbmap(fd); - symfil = argv[i]; - corfil = argv[i]; - goto Run; - } - continue; - } - fprint(2, "%s: %s %s %s\n", argv[i], hdr->aname, hdr->mname, hdr->fname); - if(hdr->ftype == FCORE){ - if(pid){ - fprint(2, "already have pid %d; ignoring core %s\n", pid, argv[i]); - uncrackhdr(hdr); - continue; - } - if(corhdr){ - fprint(2, "already have core %s; ignoring core %s\n", corfil, argv[i]); - uncrackhdr(hdr); - continue; - } - corhdr = hdr; - corfil = argv[i]; - }else{ - if(symhdr){ - fprint(2, "already have text %s; ignoring text %s\n", symfil, argv[i]); - uncrackhdr(hdr); - continue; - } - symhdr = hdr; - symfil = argv[i]; - } - } - - if(symhdr==nil){ - symfil = "a.out"; - if(pid){ - if((s = proctextfile(pid)) != nil){ - fprint(2, "pid %d: text %s\n", pid, s); - symfil = s; - } - } - if(corhdr){ - /* - * prog gives only the basename of the command, - * so try the command line for a path. - */ - if((s = strdup(corhdr->cmdline)) != nil){ - t = strchr(s, ' '); - if(t) - *t = 0; - if((t = searchpath(s)) != nil){ - fprint(2, "core: text %s\n", t); - symfil = t; - } - free(s); - } - } - - if((symhdr = crackhdr(symfil, omode)) == nil){ - fprint(2, "crackhdr %s: %r\n", symfil); - symfil = nil; - }else - fprint(2, "%s: %s %s %s\n", symfil, symhdr->aname, symhdr->mname, symhdr->fname); - } - - if(symhdr) - symopen(symhdr); + attachargs(argc, argv, wtflag?ORDWR:OREAD, 1); - if(!mach) - mach = machcpu; - - /* - * Set up maps. - */ - symmap = allocmap(); - cormap = allocmap(); - if(symmap == nil || cormap == nil) - sysfatal("allocating maps: %r"); - - if(symhdr){ - if(mapfile(symhdr, 0, symmap, nil) < 0) - fprint(2, "mapping %s: %r\n", symfil); - mapfile(symhdr, 0, cormap, nil); - } - -Run: setstring("objtype", mach->name); setstring("textfile", symfil); setstring("systype", symhdr ? symhdr->aname : ""); @@ -321,8 +211,8 @@ Run: l->v->type = TLIST; l->v->store.u.l = nil; - if(pid) - sproc(pid); + if(corpid) + sproc(corpid); if(corhdr) setcore(corhdr); varreg(); @@ -654,7 +544,7 @@ checkqid(int f1, int pid) close(fd); if(d1->qid.path != d2->qid.path || d1->qid.vers != d2->qid.vers || d1->qid.type != d2->qid.type){ - print("path %llux %llux vers %lud %lud type %d %d\n", + print("path %#llux %#llux vers %lud %lud type %d %d\n", d1->qid.path, d2->qid.path, d1->qid.vers, d2->qid.vers, d1->qid.type, d2->qid.type); print("warning: image does not match text for pid %d\n", pid); } @@ -713,10 +603,3 @@ isnumeric(char *s) } return 1; } - -int -xfmt(Fmt *f) -{ - f->flags ^= FmtSharp; - return __ifmt(f); -} |