URI: 
       tbring them up-to-speed for current system. - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 7284df18a883c64721720276dac4f4540440e74c
   DIR parent d9c2aa3a3366b60d5054c575801692579162a47f
  HTML Author: rsc <devnull@localhost>
       Date:   Mon, 19 Apr 2004 18:52:34 +0000
       
       bring them up-to-speed for current system.
       
       Diffstat:
         M acid/386                            |      20 +++++++-------------
         M acid/port                           |      31 +++++++++++++++++++++++++------
         M acid/thread                         |      69 +++++++++++++++----------------
       
       3 files changed, 66 insertions(+), 54 deletions(-)
       ---
   DIR diff --git a/acid/386 b/acid/386
       t@@ -173,7 +173,7 @@ linkdebug()
        }
        
        defn
       -acidmap()
       +dynamicmap()
        {
                if systype == "linux" then {
                        local r, m, n;
       t@@ -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);
   DIR diff --git a/acid/port b/acid/port
       t@@ -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)
        {
       t@@ -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
       t@@ -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;
                }
        
       t@@ -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);
   DIR diff --git a/acid/thread b/acid/thread
       t@@ -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){
       t@@ -57,8 +62,8 @@ defn alt(A){
        }
        
        threadignsrc = {
       -        "^/sys/src/libc",
       -        "^/sys/src/libthread",
       +        "plan9/src/libc",
       +        "plan9/src/libthread",
        };
        
        defn fnname(a){
       t@@ -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");
       t@@ -165,7 +162,7 @@ defn pthreads(P){
                while T != 0 do{
                        print("\t");
                        thread(T);
       -                T = T.nextt;
       +                T = (Thread)T.nextt;
                }
                setproc(mainpid);
        }
       t@@ -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");
       t@@ -184,6 +182,7 @@ defn threads(){
        defn stacks(){
                local P, mainpid;
        
       +        stkprefix = "";
                mainpid = pid;
                P = (Proc)_threadpq.$head;
                while P != 0 do{
       t@@ -195,7 +194,7 @@ defn stacks(){
                //        }
                //        print("threadstks(", P\X, ")\n");
                        threadstks(P);
       -                P = P.next;
       +                P = (Proc)P.next;
                        print("\n");
                }
                setproc(mainpid);
       t@@ -219,7 +218,7 @@ defn stacksizes(){
                                }
                                sp = *(T.sched);
                                print(top-sp\D, "\n");
       -                        T = T.nextt;
       +                        T = (Thread)T.nextt;
                        }
                        P = P.next;
                }
       t@@ -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;
       t@@ -252,7 +251,7 @@ defn threadstks(P){
                        print("\t");
                        thread(T);
                        threadstk(T);
       -                T = T.nextt;
       +                T = (Thread)T.nextt;
                        print("\n");
                }
                setproc(mainpid);