@@ -834,10 +834,23 @@ func printTraces(w io.Writer, rpt *Report) error {
834834
835835 _ , locations := graph .CreateNodes (prof , & graph.Options {})
836836 for _ , sample := range prof .Sample {
837- var stack graph.Nodes
837+ type stk struct {
838+ * graph.NodeInfo
839+ inline bool
840+ }
841+ var stack []stk
838842 for _ , loc := range sample .Location {
839- id := loc .ID
840- stack = append (stack , locations [id ]... )
843+ nodes := locations [loc .ID ]
844+ for i , n := range nodes {
845+ // In this and some other reports the inline flag won't be accurate if
846+ // 'show' or 'hide' filter is used. Those filters may filter out some
847+ // of entries in the line array causing a remaining entry (which is
848+ // physically inlined) to be the rightmost entry in the filtered array,
849+ // and this heuristic will erroneously consider that line entry as not
850+ // inlined. A number of other reports have a similar flaw.
851+ inline := i != len (nodes )- 1
852+ stack = append (stack , stk {& n .Info , inline })
853+ }
841854 }
842855
843856 if len (stack ) == 0 {
@@ -875,10 +888,16 @@ func printTraces(w io.Writer, rpt *Report) error {
875888 if d != 0 {
876889 v = v / d
877890 }
878- fmt .Fprintf (w , "%10s %s\n " ,
879- rpt .formatValue (v ), stack [0 ].Info .PrintableName ())
880- for _ , s := range stack [1 :] {
881- fmt .Fprintf (w , "%10s %s\n " , "" , s .Info .PrintableName ())
891+ for i , s := range stack {
892+ var vs string
893+ if i == 0 {
894+ vs = rpt .formatValue (v )
895+ }
896+ fmt .Fprintf (w , "%10s %s" , vs , s .PrintableName ())
897+ if s .inline {
898+ fmt .Fprint (w , " (inline)" )
899+ }
900+ fmt .Fprintln (w )
882901 }
883902 }
884903 fmt .Fprintln (w , separator )
0 commit comments