@@ -834,10 +834,19 @@ 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+ // The inline flag may be inaccurate if 'show' or 'hide' filter is
846+ // used. See https://github.com/google/pprof/issues/511.
847+ inline := i != len (nodes )- 1
848+ stack = append (stack , stk {& n .Info , inline })
849+ }
841850 }
842851
843852 if len (stack ) == 0 {
@@ -875,10 +884,15 @@ func printTraces(w io.Writer, rpt *Report) error {
875884 if d != 0 {
876885 v = v / d
877886 }
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 ())
887+ for i , s := range stack {
888+ var vs , inline string
889+ if i == 0 {
890+ vs = rpt .formatValue (v )
891+ }
892+ if s .inline {
893+ inline = " (inline)"
894+ }
895+ fmt .Fprintf (w , "%10s %s%s\n " , vs , s .PrintableName (), inline )
882896 }
883897 }
884898 fmt .Fprintln (w , separator )
0 commit comments