]> Cypherpunks repositories - gostls13.git/commitdiff
fix 386 log test
authorRuss Cox <rsc@golang.org>
Fri, 5 Jun 2009 17:59:25 +0000 (10:59 -0700)
committerRuss Cox <rsc@golang.org>
Fri, 5 Jun 2009 17:59:25 +0000 (10:59 -0700)
R=r
DELTA=13  (0 added, 1 deleted, 12 changed)
OCL=29928
CL=29943

src/lib/runtime/runtime.go
src/runtime/386/traceback.c

index 07c674847092a03ea9dc20bfbaecce5357244023..6fb5756d677a3ae7c071f385074965c678434505 100644 (file)
@@ -25,4 +25,4 @@ func  Breakpoint()
 // ascend, with 1 identifying the the caller of Caller.  The return values report the
 // program counter, file name, and line number within the file of the corresponding
 // call.  The boolean ok is false if it was not possible to recover the information.
-func   Caller(n int) (pc uint64, file string, line int, ok bool)
+func   Caller(n int) (pc uintptr, file string, line int, ok bool)
index 2d5714e24ff21b87d7915fbbc77efd7b9450c942..05724d9ac91f3eb5a9bd2e61770313bf5f409464 100644 (file)
@@ -80,11 +80,11 @@ traceback(byte *pc0, byte *sp, G *g)
        prints("...\n");
 }
 
-// func caller(n int) (pc uint64, file string, line int, ok bool)
+// func caller(n int) (pc uintptr, file string, line int, ok bool)
 void
-runtime·Caller(int32 n, uint64 retpc, String retfile, int32 retline, bool retbool)
+runtime·Caller(int32 n, uintptr retpc, String retfile, int32 retline, bool retbool)
 {
-       uint64 pc;
+       uintptr pc;
        byte *sp;
        byte *p;
        Stktop *stk;
@@ -92,7 +92,7 @@ runtime·Caller(int32 n, uint64 retpc, String retfile, int32 retline, bool retbo
 
        // our caller's pc, sp.
        sp = (byte*)&n;
-       pc = *(uint64*)(sp-8);
+       pc = *((uintptr*)sp - 1);
        if((f = findfunc(pc)) == nil) {
        error:
                retpc = 0;
@@ -109,27 +109,27 @@ runtime·Caller(int32 n, uint64 retpc, String retfile, int32 retline, bool retbo
        // now unwind n levels
        stk = (Stktop*)g->stackbase;
        while(n-- > 0) {
-               while(pc == (uint64)retfromnewstack) {
+               while(pc == (uintptr)retfromnewstack) {
                        sp = stk->oldsp;
                        stk = (Stktop*)stk->oldbase;
-                       pc = *(uint64*)(sp+8);
-                       sp += 16;
+                       pc = *((uintptr*)sp + 1);
+                       sp += 2*sizeof(uintptr);
                }
 
-               if(f->frame < 8)        // assembly functions lie
-                       sp += 8;
+               if(f->frame < sizeof(uintptr))  // assembly functions lie
+                       sp += sizeof(uintptr);
                else
                        sp += f->frame;
 
        loop:
-               pc = *(uint64*)(sp-8);
+               pc = *((uintptr*)sp - 1);
                if(pc <= 0x1000 || (f = findfunc(pc)) == nil) {
                        // dangerous, but let's try this.
                        // see if it is a closure.
                        p = (byte*)pc;
                        // ADDL $xxx, SP; RET
                        if(p[0] == 0x81 && p[1] == 0xc4 && p[6] == 0xc3) {
-                               sp += *(uint32*)(p+2) + 8;
+                               sp += *(uint32*)(p+2) + sizeof(uintptr);
                                goto loop;
                        }
                        goto error;
@@ -146,4 +146,3 @@ runtime·Caller(int32 n, uint64 retpc, String retfile, int32 retline, bool retbo
        FLUSH(&retbool);
 }
 
-