mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-27 11:52:03 +00:00
remove threadregs; use %# explicitly; use attachargs
This commit is contained in:
parent
5a2237bb22
commit
7b8a3f12c7
3 changed files with 21 additions and 138 deletions
|
@ -332,12 +332,12 @@ xregister(Node *r, Node *args)
|
||||||
|
|
||||||
na = 0;
|
na = 0;
|
||||||
flatten(av, args);
|
flatten(av, args);
|
||||||
if(na != 1 && na != 2)
|
if(na != 1/* && na != 2 */)
|
||||||
error("register(name[, threadid]): arg count");
|
error("register(name): arg count");
|
||||||
|
|
||||||
expr(av[0], &res);
|
expr(av[0], &res);
|
||||||
if(res.type != TSTRING)
|
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;
|
tid = 0;
|
||||||
if(na == 2){
|
if(na == 2){
|
||||||
expr(av[1], &resid);
|
expr(av[1], &resid);
|
||||||
|
@ -1139,7 +1139,7 @@ patom(char type, Store *res)
|
||||||
switch(type){
|
switch(type){
|
||||||
case TREG:
|
case TREG:
|
||||||
if(res->u.reg.thread)
|
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
|
else
|
||||||
Bprint(bout, "register(\"%s\")", res->u.reg.name);
|
Bprint(bout, "register(\"%s\")", res->u.reg.name);
|
||||||
return;
|
return;
|
||||||
|
@ -1221,16 +1221,16 @@ patom(char type, Store *res)
|
||||||
Bprint(bout, "%s", buf);
|
Bprint(bout, "%s", buf);
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
Bprint(bout, "%.2x", (int)res->u.ival&0xff);
|
Bprint(bout, "%#.2x", (int)res->u.ival&0xff);
|
||||||
break;
|
break;
|
||||||
case 'X':
|
case 'X':
|
||||||
Bprint(bout, "%.8lux", (ulong)res->u.ival);
|
Bprint(bout, "%#.8lux", (ulong)res->u.ival);
|
||||||
break;
|
break;
|
||||||
case 'x':
|
case 'x':
|
||||||
Bprint(bout, "%.4lux", (ulong)res->u.ival&0xffff);
|
Bprint(bout, "%#.4lux", (ulong)res->u.ival&0xffff);
|
||||||
break;
|
break;
|
||||||
case 'W':
|
case 'W':
|
||||||
Bprint(bout, "%.16llux", res->u.ival);
|
Bprint(bout, "%#.16llux", res->u.ival);
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
Bprint(bout, "%d", (int)res->u.ival);
|
Bprint(bout, "%d", (int)res->u.ival);
|
||||||
|
@ -1251,19 +1251,19 @@ patom(char type, Store *res)
|
||||||
Bprint(bout, "%lld", res->u.ival);
|
Bprint(bout, "%lld", res->u.ival);
|
||||||
break;
|
break;
|
||||||
case 'Y':
|
case 'Y':
|
||||||
Bprint(bout, "%.16llux", res->u.ival);
|
Bprint(bout, "%#.16llux", res->u.ival);
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
Bprint(bout, "0%.11uo", (int)res->u.ival&0xffff);
|
Bprint(bout, "%#.11uo", (int)res->u.ival&0xffff);
|
||||||
break;
|
break;
|
||||||
case 'O':
|
case 'O':
|
||||||
Bprint(bout, "0%.6uo", (int)res->u.ival);
|
Bprint(bout, "%#.6uo", (int)res->u.ival);
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
Bprint(bout, "0%.11o", (short)(res->u.ival&0xffff));
|
Bprint(bout, "%#.11o", (short)(res->u.ival&0xffff));
|
||||||
break;
|
break;
|
||||||
case 'Q':
|
case 'Q':
|
||||||
Bprint(bout, "0%.6o", (int)res->u.ival);
|
Bprint(bout, "%#.6o", (int)res->u.ival);
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
case 'F':
|
case 'F':
|
||||||
|
|
|
@ -135,7 +135,7 @@ oindm(Node *n, Node *res)
|
||||||
res->store.comt = l.store.comt;
|
res->store.comt = l.store.comt;
|
||||||
break;
|
break;
|
||||||
case TREG:
|
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;
|
res->store.comt = l.store.comt;
|
||||||
break;
|
break;
|
||||||
case TCON:
|
case TCON:
|
||||||
|
@ -334,7 +334,7 @@ oasgn(Node *n, Node *res)
|
||||||
case OINDM:
|
case OINDM:
|
||||||
expr(lp->left, &aes);
|
expr(lp->left, &aes);
|
||||||
if(aes.type == TREG)
|
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
|
else
|
||||||
windir(cormap, aes, n->right, res);
|
windir(cormap, aes, n->right, res);
|
||||||
break;
|
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);
|
werrstr("*%s: register %s not mapped", name, v->store.u.reg);
|
||||||
return -1;
|
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:
|
case TCON:
|
||||||
n = v->store.u.con;
|
n = v->store.u.con;
|
||||||
if(n->op != OCONST || n->type != TINT){
|
if(n->op != OCONST || n->type != TINT){
|
||||||
|
|
|
@ -93,7 +93,6 @@ main(int argc, char *argv[])
|
||||||
usage();
|
usage();
|
||||||
}ARGEND
|
}ARGEND
|
||||||
|
|
||||||
fmtinstall('x', xfmt);
|
|
||||||
fmtinstall('Z', Zfmt);
|
fmtinstall('Z', Zfmt);
|
||||||
fmtinstall('L', locfmt);
|
fmtinstall('L', locfmt);
|
||||||
Binit(&bioout, 1, OWRITE);
|
Binit(&bioout, 1, OWRITE);
|
||||||
|
@ -191,126 +190,17 @@ setstring(char *var, char *s)
|
||||||
static int
|
static int
|
||||||
attachfiles(int argc, char **argv)
|
attachfiles(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int fd;
|
|
||||||
volatile int pid;
|
volatile int pid;
|
||||||
char *s, *t;
|
|
||||||
int i, omode;
|
|
||||||
Fhdr *hdr;
|
|
||||||
Lsym *l;
|
Lsym *l;
|
||||||
|
|
||||||
pid = 0;
|
pid = 0;
|
||||||
interactive = 0;
|
interactive = 0;
|
||||||
|
|
||||||
if(setjmp(err))
|
if(setjmp(err))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/*
|
attachargs(argc, argv, wtflag?ORDWR:OREAD, 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);
|
|
||||||
|
|
||||||
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("objtype", mach->name);
|
||||||
setstring("textfile", symfil);
|
setstring("textfile", symfil);
|
||||||
setstring("systype", symhdr ? symhdr->aname : "");
|
setstring("systype", symhdr ? symhdr->aname : "");
|
||||||
|
@ -321,8 +211,8 @@ Run:
|
||||||
l->v->type = TLIST;
|
l->v->type = TLIST;
|
||||||
l->v->store.u.l = nil;
|
l->v->store.u.l = nil;
|
||||||
|
|
||||||
if(pid)
|
if(corpid)
|
||||||
sproc(pid);
|
sproc(corpid);
|
||||||
if(corhdr)
|
if(corhdr)
|
||||||
setcore(corhdr);
|
setcore(corhdr);
|
||||||
varreg();
|
varreg();
|
||||||
|
@ -654,7 +544,7 @@ checkqid(int f1, int pid)
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
if(d1->qid.path != d2->qid.path || d1->qid.vers != d2->qid.vers || d1->qid.type != d2->qid.type){
|
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);
|
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);
|
print("warning: image does not match text for pid %d\n", pid);
|
||||||
}
|
}
|
||||||
|
@ -713,10 +603,3 @@ isnumeric(char *s)
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
xfmt(Fmt *f)
|
|
||||||
{
|
|
||||||
f->flags ^= FmtSharp;
|
|
||||||
return __ifmt(f);
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue