acid: update acid libraries for amd64
This commit is contained in:
parent
16acf605e2
commit
de356dd855
6 changed files with 113 additions and 84 deletions
|
@ -34,12 +34,12 @@ defn imagecacheline(h) {
|
|||
while h != 0 do {
|
||||
complex Image h;
|
||||
|
||||
d=(Dev)(*(devtab+4*h.type));
|
||||
d=(Dev)devtab[h.type];
|
||||
p = "*closed*";
|
||||
if h.c != 0 then
|
||||
p = path(h.c.path);
|
||||
q = h.qid;
|
||||
print (h\X, " ref=", h.ref, " pgref=", h.pgref, "\t#", d.dc\r, h.dev\D, " (",
|
||||
print (h\A, " ref=", h.ref, " pgref=", h.pgref, "\t#", d.dc\r, h.dev\D, " (",
|
||||
q.path, " ", q.vers\D, " ", q.type\X, ") ", p, "\n");
|
||||
h = h.hash;
|
||||
}
|
||||
|
@ -59,12 +59,12 @@ defn chan(c) {
|
|||
local d, q;
|
||||
|
||||
c = (Chan)c;
|
||||
d=(Dev)(*(devtab+4*c.type));
|
||||
d= (Dev)devtab[c.type];
|
||||
q=c.qid;
|
||||
print("chan(", c\X, "): ref=", c.ref\D, " #", d.dc\r, c.dev\D, " (", q.path, " ", q.vers\D, " ", q.type\X, ")");
|
||||
print("chan(", c\A, "): ref=", c.ref\D, " #", d.dc\r, c.dev\D, " (", q.path, " ", q.vers\D, " ", q.type\X, ")");
|
||||
print(" fid=", c.fid\D, " iounit=", c.iounit\D);
|
||||
if c.ref != 0 then {
|
||||
print(" ", path(c.path), " mchan=", c.mchan\X);
|
||||
print(" ", path(c.path), " mchan=", c.mchan\A);
|
||||
if c.mchan != 0 then {
|
||||
print(" ", path(c.mchan.path));
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ defn badchans() {
|
|||
}
|
||||
}
|
||||
if bad != "" then
|
||||
print("chan(", c\X, "):", bad, "\n");
|
||||
print("chan(", c\A, "):", bad, "\n");
|
||||
}
|
||||
c = (Chan)c.link;
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ defn mntcache() {
|
|||
m = cache.hash[i];
|
||||
while m != 0 do {
|
||||
complex Mntcache m;
|
||||
print(m\X, " dev ", m.dev\D, " type ", m.type, " qid (",
|
||||
print(m\A, " dev ", m.dev\D, " type ", m.type, " qid (",
|
||||
m.qid.path, " ", m.qid.vers\D, ")\n");
|
||||
c = findchan(m.dev, m.type, m.qid.path);
|
||||
if c != 0 then {
|
||||
|
@ -219,7 +219,7 @@ defn proc(p) {
|
|||
} else {
|
||||
s = *(s\s);
|
||||
}
|
||||
print(p\X, " ", p.pid, ": ", *(p.text\s), " ", *(p.user\s), " pc ", p.pc\X, " ", s, " (", *(statename[p.state]\s), ") ut ", p.time[0]\D, " st ", p.time[1]\D, " qpc ", p.qpc\X, "\n");
|
||||
print(p\A, " ", p.pid, ": ", *(p.text\s), " ", *(p.user\s), " pc ", p.pc, " ", s, " (", *(statename[p.state]\s), ") ut ", p.time[0]\D, " st ", p.time[1]\D, " qpc ", p.qpc, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -240,6 +240,9 @@ defn procenv(p) {
|
|||
}
|
||||
|
||||
KSTACK=4096;
|
||||
if objtype=="amd64" then {
|
||||
KSTACK=16*1024;
|
||||
}
|
||||
|
||||
defn procstksize(p) {
|
||||
complex Proc p;
|
||||
|
@ -258,7 +261,7 @@ defn procstk(p) {
|
|||
|
||||
if p.state != 0 then { // 0 is Dead
|
||||
l = p.sched;
|
||||
if objtype=="386" then
|
||||
if objtype=="386" || objtype=="amd64" then
|
||||
_stk(gotolabel, *l, linkreg(0), 0);
|
||||
else
|
||||
_stk(*(l+4), *l, linkreg(0), 0);
|
||||
|
@ -313,7 +316,7 @@ defn psegment(s) {
|
|||
complex Segment s;
|
||||
|
||||
if s != 0 then {
|
||||
print(s\X, " ", segtypes[s.type&SG_TYPE], " ", s.base\X, "-", s.top\X, " image ", s.image\X, "\n");
|
||||
print(s\A, " ", segtypes[s.type&SG_TYPE], " ", s.base, "-", s.top, " image ", s.image, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -362,24 +365,34 @@ defn segaddr(s, a) {
|
|||
}
|
||||
|
||||
complex Page pg;
|
||||
return (KZERO|(pg.pa+(a%BY2PG)))\X;
|
||||
return (KZERO|(pg.pa+(a%BY2PG)))\A;
|
||||
}
|
||||
|
||||
defn kzero() {
|
||||
return main - (main & 0x0FFFFFFF);
|
||||
}
|
||||
|
||||
// PC only
|
||||
PTEMAPMEM = (1024*1024);
|
||||
BY2PG = 4096;
|
||||
PTEPERTAB = (PTEMAPMEM/BY2PG);
|
||||
defn up() {
|
||||
local mach;
|
||||
if objtype == "386" then {
|
||||
local mach;
|
||||
|
||||
MACHADDR = KZERO+0x15000;
|
||||
mach = MACHADDR;
|
||||
complex Mach mach;
|
||||
return mach.externup;
|
||||
MACHADDR = KZERO+0x15000;
|
||||
mach = MACHADDR;
|
||||
complex Mach mach;
|
||||
return mach.externup;
|
||||
}
|
||||
if objtype == "amd64" then {
|
||||
local proc;
|
||||
|
||||
proc = *R14;
|
||||
complex Proc proc;
|
||||
return proc;
|
||||
}
|
||||
print("up() not implemented for", objtype, "\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
defn intrcount() {
|
||||
|
@ -397,8 +410,6 @@ defn intrcount() {
|
|||
}
|
||||
}
|
||||
|
||||
print("/sys/lib/acid/kernel");
|
||||
|
||||
defn needacid(s){
|
||||
print("\trc(\"cd /sys/src/9/", kdir, "; mk ", s, ".acid\")\n");
|
||||
print("\tinclude(\"/sys/src/9/", kdir, "/", s, ".acid\")\n");
|
||||
|
@ -413,6 +424,10 @@ if (map()[2]) != {} then { // map has more than two elements -> active proc
|
|||
map({"*data", KZERO, 0xffffffff, KZERO});
|
||||
kdir="pc";
|
||||
}
|
||||
if objtype == "amd64" then {
|
||||
map({"*data", KZERO, 0xffffffffffffffff, KZERO});
|
||||
kdir="pc64";
|
||||
}
|
||||
if (objtype == "mips" || objtype == "mips2") then {
|
||||
kdir = "ch";
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
// usage: acid -l pool -l leak
|
||||
//
|
||||
include("/sys/src/libc/port/pool.acid");
|
||||
include("/sys/src/libc/port/pool." + objchar + ".acid");
|
||||
|
||||
defn
|
||||
dumppool(p, sum)
|
||||
|
@ -9,7 +9,7 @@ dumppool(p, sum)
|
|||
complex Pool p;
|
||||
a = p.arenalist;
|
||||
|
||||
print("A: ", p.arenalist\X, "\n");
|
||||
print("A: ", p.arenalist\A, "\n");
|
||||
while a != 0 do {
|
||||
complex Arena a;
|
||||
dumparena(a, sum);
|
||||
|
@ -25,25 +25,25 @@ dumparena(arena, sum)
|
|||
atail = A2TB(arena);
|
||||
complex Bhdr arena;
|
||||
b = a;
|
||||
print("B: ", b\X, " ", atail\X, "\n");
|
||||
print("B: ", b\A, " ", atail\A, "\n");
|
||||
while b < atail && b.magic != ARENATAIL_MAGIC do {
|
||||
dumpblock(b, sum);
|
||||
nb = B2NB(b);
|
||||
if nb == b then {
|
||||
print("B2NB(", b\X, ") = b\n");
|
||||
print("B2NB(", b\A, ") = b\n");
|
||||
b = atail; // end loop
|
||||
}
|
||||
if nb > atail then {
|
||||
b = (Bhdr)(b+4);
|
||||
print("lost at block ", (b-4)\X, ", scanning forward\n");
|
||||
print("lost at block ", (b-4)\A, ", scanning forward\n");
|
||||
while b < atail && b.magic != ALLOC_MAGIC && b.magic != FREE_MAGIC do
|
||||
b = (Bhdr)(b+4);
|
||||
print("stopped at ", b\X, " ", *b\X, "\n");
|
||||
print("stopped at ", b\A, " ", *b\A, "\n");
|
||||
}else
|
||||
b = nb;
|
||||
}
|
||||
if b != atail then
|
||||
print("found wrong tail to arena ", arena\X, " wanted ", atail\X, "\n");
|
||||
print("found wrong tail to arena ", arena\A, " wanted ", atail\A, "\n");
|
||||
}
|
||||
|
||||
defn
|
||||
|
@ -69,28 +69,39 @@ emitsum()
|
|||
lastsize = 0;
|
||||
}
|
||||
|
||||
defn
|
||||
sxpc(addr)
|
||||
{
|
||||
if objtype == "amd64" && addr & 0x80000000 then {
|
||||
return addr | 0xffffffff00000000;
|
||||
}
|
||||
return addr;
|
||||
}
|
||||
|
||||
defn
|
||||
dumpblock(addr, sum)
|
||||
{
|
||||
complex Bhdr addr;
|
||||
|
||||
if addr.magic == ALLOC_MAGIC || (!sum && addr.magic == FREE_MAGIC) then {
|
||||
local a, x, s;
|
||||
local a, x, s, allocpc, reallocpc;
|
||||
|
||||
a = addr;
|
||||
complex Alloc a;
|
||||
|
||||
x = addr+sizeofBhdr;
|
||||
x = fmt(addr+sizeofBhdr, 'X');
|
||||
if addr.magic == ALLOC_MAGIC then {
|
||||
// for mallocalign()
|
||||
while *x == ALIGN_MAGIC do {
|
||||
x = x + 4;
|
||||
}
|
||||
}
|
||||
allocpc=sxpc(x[0]);
|
||||
reallocpc=sxpc(x[1]);
|
||||
if sum then {
|
||||
if *x != lastalloc then {
|
||||
if allocpc != lastalloc then {
|
||||
emitsum();
|
||||
lastalloc = *x;
|
||||
lastalloc = allocpc;
|
||||
}
|
||||
lastcount = lastcount+1;
|
||||
lastsize = lastsize+a.size;
|
||||
|
@ -99,8 +110,8 @@ dumpblock(addr, sum)
|
|||
s = "block";
|
||||
} else
|
||||
s = "free";
|
||||
print(s, " ", addr\X, " ", a.size\X, " ");
|
||||
print(*x\X, " ", *(x+4)\X, " ", *x\a, " ", *(x+4)\a, "\n");
|
||||
print(s, " ", addr\A, " ", a.size\X, " ");
|
||||
print(x[0]\X, " ", x[1]\X, " ", allocpc\a, " ", reallocpc\a, "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -191,3 +202,5 @@ blocksummary()
|
|||
emitsum();
|
||||
print("==BLOCK END==\n");
|
||||
}
|
||||
|
||||
print("/sys/lib/acid/leak");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
include("/sys/src/libc/port/pool.acid");
|
||||
include("/sys/src/libc/port/pool." + objchar + ".acid");
|
||||
|
||||
aggr Byte {
|
||||
'b' 0 byte;
|
||||
|
@ -308,3 +308,4 @@ blockhdr(addr)
|
|||
return addr;
|
||||
}
|
||||
|
||||
print("/sys/lib/acid/pool");
|
||||
|
|
|
@ -80,53 +80,53 @@ defn code(*e) { return e; }
|
|||
|
||||
syscalls = {
|
||||
{ 0, {"sysr1", "s", code(0)}},
|
||||
{ 1, {"_errstr", "s", code(*sys_errstr:arg)}},
|
||||
{ 2, {"bind", "ssX", code(*sysbind:arg)}},
|
||||
{ 3, {"chdir", "s", code(*sysbind:arg)}},
|
||||
{ 4, {"close", "D", code(*sysclose:arg)}},
|
||||
{ 5, {"dup", "DD", code(*sysdup:arg)}},
|
||||
{ 6, {"alarm", "D", code(*sysalarm:arg)}},
|
||||
{ 7, {"exec", "sS", code(*sysexec:arg)}},
|
||||
{ 8, {"exits", "s", code(*sysexits:arg)}},
|
||||
{ 9, {"_fsession", "DX", code(*sys_fsession:arg)}},
|
||||
{10, {"fauth", "DX", code(*sysfauth:arg)}},
|
||||
{11, {"_fstat", "DX", code(*sys_fstat:arg)}},
|
||||
{12, {"segbrk", "XX", code(*syssegbrk:arg)}},
|
||||
{13, {"_mount", "DsXs", code(*sys_mount:arg)}},
|
||||
{14, {"open", "sD", code(*sysopen:arg)}},
|
||||
{15, {"_read", "DXD", code(*sys_read:arg)}},
|
||||
{16, {"oseek", "DDD", code(*sysoseek:arg)}},
|
||||
{17, {"sleep", "D", code(*syssleep:arg)}},
|
||||
{18, {"_stat", "sX", code(*sys_stat:arg)}},
|
||||
{19, {"rfork", "X", code(*sysstat:arg)}},
|
||||
{20, {"_write", "DXD", code(*sys_write:arg)}},
|
||||
{21, {"pipe", "X", code(*syspipe:arg)}},
|
||||
{22, {"create", "sDO", code(*syscreate:arg)}},
|
||||
{23, {"fd2path", "DXD", code(*sysfd2path:arg)}},
|
||||
{24, {"brk_", "X", code(*sysbrk_:arg)}},
|
||||
{25, {"remove", "s", code(*sysremove:arg)}},
|
||||
{26, {"_wstat", "sX", code(*sys_wstat:arg)}},
|
||||
{27, {"_fwstat", "DX", code(*sys_fwstat:arg)}},
|
||||
{28, {"notify", "X", code(*sysnotify:arg)}},
|
||||
{29, {"noted", "D", code(*sysnoted:arg)}},
|
||||
{30, {"segattach", "DsXD", code(*syssegattach:arg)}},
|
||||
{31, {"segdetach", "X", code(*syssegdetach:arg)}},
|
||||
{32, {"segfree", "XD", code(*syssegfree:arg)}},
|
||||
{33, {"segflush", "XD", code(*syssegflush:arg)}},
|
||||
{34, {"rendezvous", "XX", code(*sysrendezvous:arg)}},
|
||||
{35, {"unmount", "ss", code(*sysunmount:arg)}},
|
||||
{36, {"_wait", "X", code(*sys_wait:arg)}},
|
||||
{39, {"seek", "XDVD", code(*sysseek:arg)}},
|
||||
{40, {"fversion", "DDsD", code(*sysfversion:arg)}},
|
||||
{41, {"errstr", "TD", code(*syserrstr:arg)}},
|
||||
{42, {"stat", "sXD", code(*sysstat:arg)}},
|
||||
{43, {"fstat", "DXD", code(*sysfstat:arg)}},
|
||||
{44, {"wstat", "sXD", code(*syswstat:arg)}},
|
||||
{45, {"fwstat", "DXD", code(*sysfwstat:arg)}},
|
||||
{46, {"mount", "DDsXs", code(*sysmount:arg)}},
|
||||
{47, {"await", "TD", code(*sysawait:arg)}},
|
||||
{50, {"pread", "DXDZ", code(*syspread:arg)}},
|
||||
{51, {"pwrite", "DTDZ", code(*syspwrite:arg)}},
|
||||
{ 1, {"_errstr", "s", code(*sys_errstr:list)}},
|
||||
{ 2, {"bind", "ssX", code(*sysbind:list)}},
|
||||
{ 3, {"chdir", "s", code(*sysbind:list)}},
|
||||
{ 4, {"close", "D", code(*sysclose:list)}},
|
||||
{ 5, {"dup", "DD", code(*sysdup:list)}},
|
||||
{ 6, {"alarm", "D", code(*sysalarm:list)}},
|
||||
{ 7, {"exec", "sS", code(*sysexec:list)}},
|
||||
{ 8, {"exits", "s", code(*sysexits:list)}},
|
||||
{ 9, {"_fsession", "DX", code(*sys_fsession:list)}},
|
||||
{10, {"fauth", "DX", code(*sysfauth:list)}},
|
||||
{11, {"_fstat", "DX", code(*sys_fstat:list)}},
|
||||
{12, {"segbrk", "XX", code(*syssegbrk:list)}},
|
||||
{13, {"_mount", "DsXs", code(*sys_mount:list)}},
|
||||
{14, {"open", "sD", code(*sysopen:list)}},
|
||||
{15, {"_read", "DXD", code(*sys_read:list)}},
|
||||
{16, {"oseek", "DDD", code(*sysoseek:list)}},
|
||||
{17, {"sleep", "D", code(*syssleep:list)}},
|
||||
{18, {"_stat", "sX", code(*sys_stat:list)}},
|
||||
{19, {"rfork", "X", code(*sysstat:list)}},
|
||||
{20, {"_write", "DXD", code(*sys_write:list)}},
|
||||
{21, {"pipe", "X", code(*syspipe:list)}},
|
||||
{22, {"create", "sDO", code(*syscreate:list)}},
|
||||
{23, {"fd2path", "DXD", code(*sysfd2path:list)}},
|
||||
{24, {"brk_", "X", code(*sysbrk_:list)}},
|
||||
{25, {"remove", "s", code(*sysremove:list)}},
|
||||
{26, {"_wstat", "sX", code(*sys_wstat:list)}},
|
||||
{27, {"_fwstat", "DX", code(*sys_fwstat:list)}},
|
||||
{28, {"notify", "X", code(*sysnotify:list)}},
|
||||
{29, {"noted", "D", code(*sysnoted:list)}},
|
||||
{30, {"segattach", "DsXD", code(*syssegattach:list)}},
|
||||
{31, {"segdetach", "X", code(*syssegdetach:list)}},
|
||||
{32, {"segfree", "XD", code(*syssegfree:list)}},
|
||||
{33, {"segflush", "XD", code(*syssegflush:list)}},
|
||||
{34, {"rendezvous", "XX", code(*sysrendezvous:list)}},
|
||||
{35, {"unmount", "ss", code(*sysunmount:list)}},
|
||||
{36, {"_wait", "X", code(*sys_wait:list)}},
|
||||
{39, {"seek", "XDVD", code(*sysseek:list)}},
|
||||
{40, {"fversion", "DDsD", code(*sysfversion:list)}},
|
||||
{41, {"errstr", "TD", code(*syserrstr:list)}},
|
||||
{42, {"stat", "sXD", code(*sysstat:list)}},
|
||||
{43, {"fstat", "DXD", code(*sysfstat:list)}},
|
||||
{44, {"wstat", "sXD", code(*syswstat:list)}},
|
||||
{45, {"fwstat", "DXD", code(*sysfwstat:list)}},
|
||||
{46, {"mount", "DDsXs", code(*sysmount:list)}},
|
||||
{47, {"await", "TD", code(*sysawait:list)}},
|
||||
{50, {"pread", "DXDZ", code(*syspread:list)}},
|
||||
{51, {"pwrite", "DTDZ", code(*syspwrite:list)}},
|
||||
};
|
||||
|
||||
defn syscall() {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
include("/sys/src/libthread/sched.acid");
|
||||
include("/sys/src/libthread/sched." + objchar + ".acid");
|
||||
|
||||
defn labpc(l)
|
||||
{
|
||||
if objtype == "386" then
|
||||
if objtype == "386" || objtype == "amd64" then
|
||||
return longjmp;
|
||||
return *(l+4);
|
||||
}
|
||||
|
|
|
@ -36,8 +36,8 @@ clean:V:
|
|||
nuke:V:
|
||||
rm -f *.[$OS] [$OS].out $CLEANFILES $LIB
|
||||
|
||||
%.acid: %.$O $HFILES
|
||||
$CC $CFLAGS -a $stem.c >$target
|
||||
%.acid:V:
|
||||
$CC $CFLAGS -a `{basename $stem .$O}^.c >$target
|
||||
|
||||
update:V:
|
||||
update $UPDATEFLAGS $UPDATE
|
||||
|
|
Loading…
Reference in a new issue