Просмотр исходного кода

Remove last reference to runtime.FuncForPC (#184)

Signed-off-by: Dave Cheney <dave@cheney.net>
Dave Cheney 7 лет назад
Родитель
Сommit
e19cb699ad
2 измененных файлов с 3 добавлено и 7 удалено
  1. 1 5
      stack.go
  2. 2 2
      stack_test.go

+ 1 - 5
stack.go

@@ -11,10 +11,6 @@ import (
 // Frame represents a program counter inside a stack frame.
 type Frame runtime.Frame
 
-// pc returns the program counter for this frame;
-// multiple frames may have the same PC value.
-func (f Frame) pc() uintptr { return runtime.Frame(f).PC }
-
 // file returns the full path to the file that contains the
 // function for this Frame's pc.
 func (f Frame) file() string {
@@ -61,7 +57,7 @@ func (f Frame) Format(s fmt.State, verb rune) {
 	case 'd':
 		fmt.Fprintf(s, "%d", f.line())
 	case 'n':
-		name := runtime.FuncForPC(f.pc()).Name()
+		name := runtime.Frame(f).Function
 		io.WriteString(s, funcname(name))
 	case 'v':
 		f.Format(s, 's')

+ 2 - 2
stack_test.go

@@ -10,12 +10,12 @@ var initpc = caller()
 
 type X struct{}
 
-//go:noinline
+// val returns a Frame pointing to itself.
 func (x X) val() Frame {
 	return caller()
 }
 
-//go:noinline
+// ptr returns a Frame pointing to itself.
 func (x *X) ptr() Frame {
 	return caller()
 }