]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: delete duplicate implementation of pcln walker
authorRuss Cox <rsc@golang.org>
Thu, 12 Jan 2012 02:45:32 +0000 (18:45 -0800)
committerRuss Cox <rsc@golang.org>
Thu, 12 Jan 2012 02:45:32 +0000 (18:45 -0800)
It's hard enough to get right once.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5533073

src/pkg/runtime/extern.go
src/pkg/runtime/symtab.c

index e86da01732422f98665090295beaf153ec4a3afe..1860c5b896b438d097d0b01e8e62a5ab2b41f1c2 100644 (file)
@@ -59,51 +59,12 @@ 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
 
index 6cd59136f426fcf94f44cd6f373edc10221c19e6..0346a420b5499789d8fc59e40476f7f5126a6a05 100644 (file)
@@ -381,6 +381,15 @@ runtime·funcline(Func *f, uintptr targetpc)
        return line;
 }
 
+void
+runtime·funcline_go(Func *f, uintptr targetpc, String retfile, int32 retline)
+{
+       retfile = f->src;
+       retline = runtime·funcline(f, targetpc);
+       FLUSH(&retfile);
+       FLUSH(&retline);
+}
+
 static void
 buildfuncs(void)
 {