@@ -376,22 +376,16 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in
376
376
// If there is inlining info, print the inner frames.
377
377
if inldata := funcdata (f , _FUNCDATA_InlTree ); inldata != nil {
378
378
inltree := (* [1 << 20 ]inlinedCall )(inldata )
379
- var inlFunc _func
380
- inlFuncInfo := funcInfo {& inlFunc , f .datap }
381
379
for {
382
380
ix := pcdatavalue (f , _PCDATA_InlTreeIndex , tracepc , nil )
383
381
if ix < 0 {
384
382
break
385
383
}
386
384
387
- // Create a fake _func for the
388
- // inlined function.
389
- inlFunc .nameOff = inltree [ix ].nameOff
390
- inlFunc .funcID = inltree [ix ].funcID
391
- inlFunc .startLine = inltree [ix ].startLine
385
+ sf := srcFunc {f .datap , inltree [ix ].nameOff , inltree [ix ].startLine , inltree [ix ].funcID }
392
386
393
- if (flags & _TraceRuntimeFrames ) != 0 || showframe (inlFuncInfo , gp , nprint == 0 , inlFuncInfo . funcID , calleeFuncID ) {
394
- name := funcname ( inlFuncInfo )
387
+ if (flags & _TraceRuntimeFrames ) != 0 || showframe (sf , gp , nprint == 0 , calleeFuncID ) {
388
+ name := sf . name ( )
395
389
file , line := funcline (f , tracepc )
396
390
print (name , "(...)\n " )
397
391
print ("\t " , file , ":" , line , "\n " )
@@ -402,7 +396,7 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in
402
396
tracepc = frame .fn .entry () + uintptr (inltree [ix ].parentPc )
403
397
}
404
398
}
405
- if (flags & _TraceRuntimeFrames ) != 0 || showframe (f , gp , nprint == 0 , f . funcID , calleeFuncID ) {
399
+ if (flags & _TraceRuntimeFrames ) != 0 || showframe (f . srcFunc () , gp , nprint == 0 , calleeFuncID ) {
406
400
// Print during crash.
407
401
// main(0x1, 0x2, 0x3)
408
402
// /home/rsc/go/src/runtime/x.go:23 +0xf
@@ -692,7 +686,7 @@ func printcreatedby(gp *g) {
692
686
// Show what created goroutine, except main goroutine (goid 1).
693
687
pc := gp .gopc
694
688
f := findfunc (pc )
695
- if f .valid () && showframe (f , gp , false , funcID_normal , funcID_normal ) && gp .goid != 1 {
689
+ if f .valid () && showframe (f . srcFunc () , gp , false , funcID_normal ) && gp .goid != 1 {
696
690
printcreatedby1 (f , pc , gp .parentGoid )
697
691
}
698
692
}
@@ -792,7 +786,7 @@ func printAncestorTraceback(ancestor ancestorInfo) {
792
786
print ("[originating from goroutine " , ancestor .goid , "]:\n " )
793
787
for fidx , pc := range ancestor .pcs {
794
788
f := findfunc (pc ) // f previously validated
795
- if showfuncinfo (f , fidx == 0 , funcID_normal , funcID_normal ) {
789
+ if showfuncinfo (f . srcFunc () , fidx == 0 , funcID_normal ) {
796
790
printAncestorTracebackFuncInfo (f , pc )
797
791
}
798
792
}
@@ -801,7 +795,7 @@ func printAncestorTraceback(ancestor ancestorInfo) {
801
795
}
802
796
// Show what created goroutine, except main goroutine (goid 1).
803
797
f := findfunc (ancestor .gopc )
804
- if f .valid () && showfuncinfo (f , false , funcID_normal , funcID_normal ) && ancestor .goid != 1 {
798
+ if f .valid () && showfuncinfo (f . srcFunc () , false , funcID_normal ) && ancestor .goid != 1 {
805
799
// In ancestor mode, we'll already print the goroutine ancestor.
806
800
// Pass 0 for the goid parameter so we don't print it again.
807
801
printcreatedby1 (f , ancestor .gopc , 0 )
@@ -850,35 +844,28 @@ func gcallers(gp *g, skip int, pcbuf []uintptr) int {
850
844
851
845
// showframe reports whether the frame with the given characteristics should
852
846
// be printed during a traceback.
853
- func showframe (f funcInfo , gp * g , firstFrame bool , funcID , childID funcID ) bool {
847
+ func showframe (sf srcFunc , gp * g , firstFrame bool , calleeID funcID ) bool {
854
848
mp := getg ().m
855
849
if mp .throwing >= throwTypeRuntime && gp != nil && (gp == mp .curg || gp == mp .caughtsig .ptr ()) {
856
850
return true
857
851
}
858
- return showfuncinfo (f , firstFrame , funcID , childID )
852
+ return showfuncinfo (sf , firstFrame , calleeID )
859
853
}
860
854
861
855
// showfuncinfo reports whether a function with the given characteristics should
862
856
// be printed during a traceback.
863
- func showfuncinfo (f funcInfo , firstFrame bool , funcID , childID funcID ) bool {
864
- // Note that f may be a synthesized funcInfo for an inlined
865
- // function, in which case only nameOff and funcID are set.
866
-
857
+ func showfuncinfo (sf srcFunc , firstFrame bool , calleeID funcID ) bool {
867
858
level , _ , _ := gotraceback ()
868
859
if level > 1 {
869
860
// Show all frames.
870
861
return true
871
862
}
872
863
873
- if ! f .valid () {
874
- return false
875
- }
876
-
877
- if funcID == funcID_wrapper && elideWrapperCalling (childID ) {
864
+ if sf .funcID == funcID_wrapper && elideWrapperCalling (calleeID ) {
878
865
return false
879
866
}
880
867
881
- name := funcname ( f )
868
+ name := sf . name ( )
882
869
883
870
// Special case: always show runtime.gopanic frame
884
871
// in the middle of a stack trace, so that we can
0 commit comments