Commit 4f30ec7f authored by Russ Cox's avatar Russ Cox

fix 386 log test

R=r
DELTA=13  (0 added, 1 deleted, 12 changed)
OCL=29928
CL=29943
parent 25ac4d07
...@@ -25,4 +25,4 @@ func Breakpoint() ...@@ -25,4 +25,4 @@ func Breakpoint()
// ascend, with 1 identifying the the caller of Caller. The return values report the // 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 // 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. // 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)
...@@ -80,11 +80,11 @@ traceback(byte *pc0, byte *sp, G *g) ...@@ -80,11 +80,11 @@ traceback(byte *pc0, byte *sp, G *g)
prints("...\n"); 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 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 *sp;
byte *p; byte *p;
Stktop *stk; Stktop *stk;
...@@ -92,7 +92,7 @@ runtime·Caller(int32 n, uint64 retpc, String retfile, int32 retline, bool retbo ...@@ -92,7 +92,7 @@ runtime·Caller(int32 n, uint64 retpc, String retfile, int32 retline, bool retbo
// our caller's pc, sp. // our caller's pc, sp.
sp = (byte*)&n; sp = (byte*)&n;
pc = *(uint64*)(sp-8); pc = *((uintptr*)sp - 1);
if((f = findfunc(pc)) == nil) { if((f = findfunc(pc)) == nil) {
error: error:
retpc = 0; retpc = 0;
...@@ -109,27 +109,27 @@ runtime·Caller(int32 n, uint64 retpc, String retfile, int32 retline, bool retbo ...@@ -109,27 +109,27 @@ runtime·Caller(int32 n, uint64 retpc, String retfile, int32 retline, bool retbo
// now unwind n levels // now unwind n levels
stk = (Stktop*)g->stackbase; stk = (Stktop*)g->stackbase;
while(n-- > 0) { while(n-- > 0) {
while(pc == (uint64)retfromnewstack) { while(pc == (uintptr)retfromnewstack) {
sp = stk->oldsp; sp = stk->oldsp;
stk = (Stktop*)stk->oldbase; stk = (Stktop*)stk->oldbase;
pc = *(uint64*)(sp+8); pc = *((uintptr*)sp + 1);
sp += 16; sp += 2*sizeof(uintptr);
} }
if(f->frame < 8) // assembly functions lie if(f->frame < sizeof(uintptr)) // assembly functions lie
sp += 8; sp += sizeof(uintptr);
else else
sp += f->frame; sp += f->frame;
loop: loop:
pc = *(uint64*)(sp-8); pc = *((uintptr*)sp - 1);
if(pc <= 0x1000 || (f = findfunc(pc)) == nil) { if(pc <= 0x1000 || (f = findfunc(pc)) == nil) {
// dangerous, but let's try this. // dangerous, but let's try this.
// see if it is a closure. // see if it is a closure.
p = (byte*)pc; p = (byte*)pc;
// ADDL $xxx, SP; RET // ADDL $xxx, SP; RET
if(p[0] == 0x81 && p[1] == 0xc4 && p[6] == 0xc3) { if(p[0] == 0x81 && p[1] == 0xc4 && p[6] == 0xc3) {
sp += *(uint32*)(p+2) + 8; sp += *(uint32*)(p+2) + sizeof(uintptr);
goto loop; goto loop;
} }
goto error; goto error;
...@@ -146,4 +146,3 @@ runtime·Caller(int32 n, uint64 retpc, String retfile, int32 retline, bool retbo ...@@ -146,4 +146,3 @@ runtime·Caller(int32 n, uint64 retpc, String retfile, int32 retline, bool retbo
FLUSH(&retbool); FLUSH(&retbool);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment