bring them up-to-speed for current system.

This commit is contained in:
rsc 2004-04-19 18:52:34 +00:00
parent d9c2aa3a33
commit 7284df18a8
3 changed files with 66 additions and 54 deletions

View file

@ -173,7 +173,7 @@ linkdebug()
}
defn
acidmap()
dynamicmap()
{
if systype == "linux" then {
local r, m, n;
@ -192,19 +192,13 @@ acidmap()
}
}
}
}
local syms;
local l;
l = textfile();
if l != {} then {
syms = "acidtypes";
while l != {} do {
syms = syms + " " + ((head l)[0]);
l = tail l;
}
includepipe(syms);
}
defn
acidmap()
{
dynamicmap();
acidtypes();
}
print(acidfile);

View file

@ -33,10 +33,10 @@ notelstk(addr)
_stk({"PC", pc, "SP", sp, linkreg(addr)}, 1);
}
defn labstk(l) // trace from a label
{
_stk({"PC", *(l+4), "SP", *l, linkreg(0)}, 0);
}
// defn labstk(l) // trace from a label
// {
// _stk({"PC", *(l+4), "SP", *l, linkreg(0)}, 0);
// }
defn params(param)
{
@ -64,8 +64,11 @@ defn locals(l)
}
}
defn _stkign(file)
defn _stkign(frame)
{
local file;
file = pcfile(frame[0]);
s = stkignore;
while s do {
if regexp(head s, file) then
@ -85,7 +88,7 @@ defn _stk(regs, dolocals)
stk = strace(regs);
if stkignore then {
while stk && tail stk && _stkign((head tail stk)[1]) do
while stk && tail stk && _stkign(head tail stk) do
stk = tail stk;
}
@ -595,5 +598,21 @@ defn spsrch(len)
}
}
defn acidtypes()
{
local syms;
local l;
l = textfile();
if l != {} then {
syms = "acidtypes";
while l != {} do {
syms = syms + " " + ((head l)[0]);
l = tail l;
}
includepipe(syms);
}
}
progargs="";
print(acidfile);

View file

@ -1,24 +1,29 @@
defn labpc(l)
{
if objtype == "386" then
return longjmp;
return *(l+4);
complex Label l;
return l.pc;
}
defn labsp(l)
defn label(l)
{
return *l;
complex Label l;
if objtype == "386" then
return {"PC", l.pc, "BX", l.bx, "SP", l.sp, "BP", l.bp, "SI", l.si, "DI", l.di};
return {};
}
defn labstk(l)
{
_stk(labpc(l), labsp(l), 0, 0);
_stk(label(l), 0);
}
defn lablstk(l)
{
_stk(labpc(l), labsp(l), 0, 1);
_stk(label(l), 1);
}
defn altfmt(A){
@ -57,8 +62,8 @@ defn alt(A){
}
threadignsrc = {
"^/sys/src/libc",
"^/sys/src/libthread",
"plan9/src/libc",
"plan9/src/libthread",
};
defn fnname(a){
@ -81,32 +86,24 @@ defn stkignore(s){
}
defn threadstkline(T){
local stk, frame, pc, pc0, file, lastpc0, s, sym, i, stop;
local stk, frame, pc, pc0, file, s, sym, i, stop;
if T.state == Running then
stk = strace({});
else
stk = strace(label(T.sched));
if T.state == Running then{
pc = *PC;
stk = strace(*PC, *SP, linkreg(0));
}else{
pc = labpc(T.sched);
stk = strace(labpc(T.sched), labsp(T.sched), 0);
}
lastpc0 = 0;
pc0 = 0;
stop = 0;
while stk && !stop do {
frame = head stk;
stk = tail stk;
pc = frame[2];
pc0 = frame[0];
file = pcfile(pc);
if !regexp("^/sys/src/libc/", file)
&& !regexp("^/sys/src/libthread/", file)
if !regexp("plan9/src/libc/", file)
&& !regexp("plan9/src/libthread/", file)
&& match(file, stkignore)==-1 then
stop = 1;
else{
lastpc0 = pc0;
frame = head stk;
stk = tail stk;
nextframe = head stk;
pc = frame[1];
pc0 = nextframe[0];
}
}
file = pcfile(pc);
s = file+":"+itoa(pcline(pc), "%d");
@ -165,7 +162,7 @@ defn pthreads(P){
while T != 0 do{
print("\t");
thread(T);
T = T.nextt;
T = (Thread)T.nextt;
}
setproc(mainpid);
}
@ -173,6 +170,7 @@ defn pthreads(P){
defn threads(){
local P;
complex Pqueue _threadpq;
P = (Proc)_threadpq.$head;
while P != 0 do{
if P != (Proc)_threadpq.$head then print("\n");
@ -184,6 +182,7 @@ defn threads(){
defn stacks(){
local P, mainpid;
stkprefix = "";
mainpid = pid;
P = (Proc)_threadpq.$head;
while P != 0 do{
@ -195,7 +194,7 @@ defn stacks(){
// }
// print("threadstks(", P\X, ")\n");
threadstks(P);
P = P.next;
P = (Proc)P.next;
print("\n");
}
setproc(mainpid);
@ -219,7 +218,7 @@ defn stacksizes(){
}
sp = *(T.sched);
print(top-sp\D, "\n");
T = T.nextt;
T = (Thread)T.nextt;
}
P = P.next;
}
@ -240,8 +239,8 @@ defn threadstks(P){
stkprefix = pref+"\t\t";
ign = stkignore;
stkignore = {
"^/sys/src/libthread/",
"^/sys/src/libc/(386|arm|alpha|sparc|power|mips)/"
"plan9/src/libthread/",
"plan9/src/libc/(386|arm|alpha|sparc|power|mips)/"
};
setproc(P.pid);
Tq = (Tqueue)P.threads;
@ -252,7 +251,7 @@ defn threadstks(P){
print("\t");
thread(T);
threadstk(T);
T = T.nextt;
T = (Thread)T.nextt;
print("\n");
}
setproc(mainpid);