diff options
Diffstat (limited to 'libgo/go/runtime/extern.go')
-rw-r--r-- | libgo/go/runtime/extern.go | 54 |
1 files changed, 9 insertions, 45 deletions
diff --git a/libgo/go/runtime/extern.go b/libgo/go/runtime/extern.go index 7c986daee63..25c7470aab1 100644 --- a/libgo/go/runtime/extern.go +++ b/libgo/go/runtime/extern.go @@ -19,8 +19,8 @@ func Gosched() func Goexit() // Caller reports file and line number information about function invocations on -// the calling goroutine's stack. The argument skip is the number of stack frames to -// ascend, with 0 identifying the the caller of Caller. The return values report the +// the calling goroutine's stack. The argument skip is the number of stack frames +// to ascend, with 0 identifying 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(skip int) (pc uintptr, file string, line int, ok bool) @@ -59,54 +59,18 @@ func (f *Func) Entry() uintptr { return f.entry } // The result will not be accurate if pc is not a program // counter within f. func (f *Func) FileLine(pc uintptr) (file string, line int) { - // NOTE(rsc): If you edit this function, also edit - // symtab.c:/^funcline. That function also has the - // comments explaining the logic. - targetpc := pc - - var pcQuant uintptr = 1 - if GOARCH == "arm" { - pcQuant = 4 - } - - p := f.pcln - pc = f.pc0 - line = int(f.ln0) - i := 0 - //print("FileLine start pc=", pc, " targetpc=", targetpc, " line=", line, - // " tab=", p, " ", p[0], " quant=", pcQuant, " GOARCH=", GOARCH, "\n") - for { - for i < len(p) && p[i] > 128 { - pc += pcQuant * uintptr(p[i]-128) - i++ - } - //print("pc<", pc, " targetpc=", targetpc, " line=", line, "\n") - if pc > targetpc || i >= len(p) { - break - } - if p[i] == 0 { - if i+5 > len(p) { - break - } - line += int(p[i+1]<<24) | int(p[i+2]<<16) | int(p[i+3]<<8) | int(p[i+4]) - i += 5 - } else if p[i] <= 64 { - line += int(p[i]) - i++ - } else { - line -= int(p[i] - 64) - i++ - } - //print("pc=", pc, " targetpc=", targetpc, " line=", line, "\n") - pc += pcQuant - } - file = f.src - return + return funcline_go(f, pc) } +// implemented in symtab.c +func funcline_go(*Func, uintptr) (string, int) + // mid returns the current os thread (m) id. func mid() uint32 +// NumCPU returns the number of logical CPUs on the local machine. +func NumCPU() int + // Semacquire waits until *s > 0 and then atomically decrements it. // It is intended as a simple sleep primitive for use by the synchronization // library and should not be used directly. |