Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func TestParse(t *testing.T) {
{"tags", "heap"},
{"tags,unit=bytes", "heap"},
{"traces", "cpu"},
{"traces,addresses", "cpu"},
{"traces", "heap_tags"},
{"dot,alloc_space,flat,focus=[234]00", "heap_alloc"},
{"dot,alloc_space,flat,tagshow=[2]00", "heap_alloc"},
Expand Down
32 changes: 32 additions & 0 deletions internal/driver/testdata/pprof.cpu.addresses.traces
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
File: testbinary
Type: cpu
Duration: 10s, Total samples = 1.12s (11.20%)
-----------+-------------------------------------------------------
key1: tag1
key2: tag1
1s 0000000000001000 line1000 testdata/file1000.src:1
0000000000002000 line2001 testdata/file2000.src:9 (inline)
0000000000002000 line2000 testdata/file2000.src:4
0000000000003000 line3002 testdata/file3000.src:2 (inline)
0000000000003000 line3001 testdata/file3000.src:5 (inline)
0000000000003000 line3000 testdata/file3000.src:6
-----------+-------------------------------------------------------
key1: tag2
key3: tag2
100ms 0000000000001000 line1000 testdata/file1000.src:1
0000000000003001 line3001 testdata/file3000.src:8 (inline)
0000000000003001 line3000 testdata/file3000.src:9
-----------+-------------------------------------------------------
key1: tag3
key2: tag2
10ms 0000000000002000 line2001 testdata/file2000.src:9 (inline)
0000000000002000 line2000 testdata/file2000.src:4
0000000000003002 line3002 testdata/file3000.src:5 (inline)
0000000000003002 line3000 testdata/file3000.src:9
-----------+-------------------------------------------------------
key1: tag4
key2: tag1
10ms 0000000000003000 line3002 testdata/file3000.src:2 (inline)
0000000000003000 line3001 testdata/file3000.src:5 (inline)
0000000000003000 line3000 testdata/file3000.src:6
-----------+-------------------------------------------------------
16 changes: 8 additions & 8 deletions internal/driver/testdata/pprof.cpu.traces
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@ Duration: 10s, Total samples = 1.12s (11.20%)
key1: tag1
key2: tag1
1s line1000
line2001
line2001 (inline)
line2000
line3002
line3001
line3002 (inline)
line3001 (inline)
line3000
-----------+-------------------------------------------------------
key1: tag2
key3: tag2
100ms line1000
line3001
line3001 (inline)
line3000
-----------+-------------------------------------------------------
key1: tag3
key2: tag2
10ms line2001
10ms line2001 (inline)
line2000
line3002
line3002 (inline)
line3000
-----------+-------------------------------------------------------
key1: tag4
key2: tag1
10ms line3002
line3001
10ms line3002 (inline)
line3001 (inline)
line3000
-----------+-------------------------------------------------------
16 changes: 8 additions & 8 deletions internal/driver/testdata/pprof.heap_tags.traces
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ Type: inuse_space
bytes: 100kB
request: 100kB
1000kB line1000
line2001
line2001 (inline)
line2000
line3002
line3001
line3002 (inline)
line3001 (inline)
line3000
-----------+-------------------------------------------------------
bytes: 200kB
3.91MB line1000
line3001
line3001 (inline)
line3000
-----------+-------------------------------------------------------
key1: tag
bytes: 1.56MB
request: 1.56MB
62.50MB line2001
62.50MB line2001 (inline)
line2000
line3002
line3002 (inline)
line3000
-----------+-------------------------------------------------------
bytes: 400kB
31.25MB line3002
line3001
31.25MB line3002 (inline)
line3001 (inline)
line3000
-----------+-------------------------------------------------------
28 changes: 21 additions & 7 deletions internal/report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -834,10 +834,19 @@ func printTraces(w io.Writer, rpt *Report) error {

_, locations := graph.CreateNodes(prof, &graph.Options{})
for _, sample := range prof.Sample {
var stack graph.Nodes
type stk struct {
*graph.NodeInfo
inline bool
}
var stack []stk
for _, loc := range sample.Location {
id := loc.ID
stack = append(stack, locations[id]...)
nodes := locations[loc.ID]
for i, n := range nodes {
// The inline flag may be inaccurate if 'show' or 'hide' filter is
// used. See https://github.com/google/pprof/issues/511.
inline := i != len(nodes)-1
stack = append(stack, stk{&n.Info, inline})
}
}

if len(stack) == 0 {
Expand Down Expand Up @@ -875,10 +884,15 @@ func printTraces(w io.Writer, rpt *Report) error {
if d != 0 {
v = v / d
}
fmt.Fprintf(w, "%10s %s\n",
rpt.formatValue(v), stack[0].Info.PrintableName())
for _, s := range stack[1:] {
fmt.Fprintf(w, "%10s %s\n", "", s.Info.PrintableName())
for i, s := range stack {
var vs, inline string
if i == 0 {
vs = rpt.formatValue(v)
}
if s.inline {
inline = " (inline)"
}
fmt.Fprintf(w, "%10s %s%s\n", vs, s.PrintableName(), inline)
}
}
fmt.Fprintln(w, separator)
Expand Down