@@ -39,7 +39,7 @@ func Caller(skip int) Call {
3939 }
4040
4141 c .pc = pcs [1 ]
42- if runtime .FuncForPC (pcs [0 ]) != sigpanic {
42+ if runtime .FuncForPC (pcs [0 ]). Name () != "runtime. sigpanic" {
4343 c .pc --
4444 }
4545 c .fn = runtime .FuncForPC (c .pc )
@@ -205,33 +205,6 @@ func (cs CallStack) Format(s fmt.State, verb rune) {
205205 s .Write (closeBracketBytes )
206206}
207207
208- // findSigpanic intentionally executes faulting code to generate a stack trace
209- // containing an entry for runtime.sigpanic.
210- func findSigpanic () * runtime.Func {
211- var fn * runtime.Func
212- var p * int
213- func () int {
214- defer func () {
215- if p := recover (); p != nil {
216- var pcs [512 ]uintptr
217- n := runtime .Callers (2 , pcs [:])
218- for _ , pc := range pcs [:n ] {
219- f := runtime .FuncForPC (pc )
220- if f .Name () == "runtime.sigpanic" {
221- fn = f
222- break
223- }
224- }
225- }
226- }()
227- // intentional nil pointer dereference to trigger sigpanic
228- return * p
229- }()
230- return fn
231- }
232-
233- var sigpanic = findSigpanic ()
234-
235208// Trace returns a CallStack for the current goroutine with element 0
236209// identifying the calling function.
237210func Trace () CallStack {
@@ -241,7 +214,7 @@ func Trace() CallStack {
241214
242215 for i , pc := range pcs [:n ] {
243216 pcFix := pc
244- if i > 0 && cs [i - 1 ].fn != sigpanic {
217+ if i > 0 && cs [i - 1 ].fn . Name () != "runtime. sigpanic" {
245218 pcFix --
246219 }
247220 cs [i ] = Call {
0 commit comments