Browse Source

Clean up paths using filepath package

When reconciling samples, cleanup file paths to allow functions to be
combined if their source filenames match after cleanup (eg "src.cpp" and
"./src.cpp").

Also clean up existing uses of filepath to avoid passing empty strings
to it: filepath.Base("") returns "."
Raul Silvera 9 years ago
parent
commit
1c9cb2e8d3

+ 1
- 1
internal/driver/driver.go View File

235
 		OutputUnit: vars["unit"].value,
235
 		OutputUnit: vars["unit"].value,
236
 	}
236
 	}
237
 
237
 
238
-	if len(p.Mapping) > 0 {
238
+	if len(p.Mapping) > 0 && p.Mapping[0].File != "" {
239
 		ropt.Title = filepath.Base(p.Mapping[0].File)
239
 		ropt.Title = filepath.Base(p.Mapping[0].File)
240
 	}
240
 	}
241
 
241
 

+ 1
- 1
internal/driver/testdata/pprof.contention.cum.files.dot View File

1
-digraph "." {
1
+digraph "unnamed" {
2
 node [style=filled fillcolor="#f8f8f8"]
2
 node [style=filled fillcolor="#f8f8f8"]
3
 subgraph cluster_L { "Build ID: buildid-contention" [shape=box fontsize=16 label="Build ID: buildid-contention\lComment #1\lComment #2\lType: delay\lShowing nodes accounting for 149.50ms, 100% of 149.50ms total\l"] }
3
 subgraph cluster_L { "Build ID: buildid-contention" [shape=box fontsize=16 label="Build ID: buildid-contention\lComment #1\lComment #2\lType: delay\lShowing nodes accounting for 149.50ms, 100% of 149.50ms total\l"] }
4
 N1 [label="file3000.src\n32.77ms (21.92%)\nof 149.50ms (100%)" fontsize=20 shape=box tooltip="testdata/file3000.src (149.50ms)" color="#b20000" fillcolor="#edd5d5"]
4
 N1 [label="file3000.src\n32.77ms (21.92%)\nof 149.50ms (100%)" fontsize=20 shape=box tooltip="testdata/file3000.src (149.50ms)" color="#b20000" fillcolor="#edd5d5"]

+ 1
- 1
internal/driver/testdata/pprof.contention.flat.addresses.dot.focus.ignore View File

1
-digraph "." {
1
+digraph "unnamed" {
2
 node [style=filled fillcolor="#f8f8f8"]
2
 node [style=filled fillcolor="#f8f8f8"]
3
 subgraph cluster_L { "Build ID: buildid-contention" [shape=box fontsize=16 label="Build ID: buildid-contention\lComment #1\lComment #2\lType: delay\lShowing nodes accounting for 40.96ms, 27.40% of 149.50ms total\l"] }
3
 subgraph cluster_L { "Build ID: buildid-contention" [shape=box fontsize=16 label="Build ID: buildid-contention\lComment #1\lComment #2\lType: delay\lShowing nodes accounting for 40.96ms, 27.40% of 149.50ms total\l"] }
4
 N1 [label="0000000000001000\nline1000\nfile1000.src:1\n40.96ms (27.40%)" fontsize=24 shape=box tooltip="0000000000001000 line1000 testdata/file1000.src:1 (40.96ms)" color="#b23900" fillcolor="#edddd5"]
4
 N1 [label="0000000000001000\nline1000\nfile1000.src:1\n40.96ms (27.40%)" fontsize=24 shape=box tooltip="0000000000001000 line1000 testdata/file1000.src:1 (40.96ms)" color="#b23900" fillcolor="#edddd5"]

+ 1
- 1
internal/driver/testdata/pprof.heap.flat.inuse_space.dot.focus View File

1
-digraph "." {
1
+digraph "unnamed" {
2
 node [style=filled fillcolor="#f8f8f8"]
2
 node [style=filled fillcolor="#f8f8f8"]
3
 subgraph cluster_L { "Build ID: buildid" [shape=box fontsize=16 label="Build ID: buildid\lType: inuse_space\lShowing nodes accounting for 62.50MB, 63.37% of 98.63MB total\l"] }
3
 subgraph cluster_L { "Build ID: buildid" [shape=box fontsize=16 label="Build ID: buildid\lType: inuse_space\lShowing nodes accounting for 62.50MB, 63.37% of 98.63MB total\l"] }
4
 N1 [label="line2001\nfile2000.src\n62.50MB (63.37%)" fontsize=24 shape=box tooltip="line2001 testdata/file2000.src (62.50MB)" color="#b21600" fillcolor="#edd8d5"]
4
 N1 [label="line2001\nfile2000.src\n62.50MB (63.37%)" fontsize=24 shape=box tooltip="line2001 testdata/file2000.src (62.50MB)" color="#b21600" fillcolor="#edd8d5"]

+ 1
- 1
internal/driver/testdata/pprof.heap.flat.inuse_space.dot.focus.ignore View File

1
-digraph "." {
1
+digraph "unnamed" {
2
 node [style=filled fillcolor="#f8f8f8"]
2
 node [style=filled fillcolor="#f8f8f8"]
3
 subgraph cluster_L { "Build ID: buildid" [shape=box fontsize=16 label="Build ID: buildid\lType: inuse_space\lShowing nodes accounting for 36.13MB, 36.63% of 98.63MB total\lDropped 2 nodes (cum <= 4.93MB)\l"] }
3
 subgraph cluster_L { "Build ID: buildid" [shape=box fontsize=16 label="Build ID: buildid\lType: inuse_space\lShowing nodes accounting for 36.13MB, 36.63% of 98.63MB total\lDropped 2 nodes (cum <= 4.93MB)\l"] }
4
 N1 [label="line3002\nfile3000.src\n31.25MB (31.68%)\nof 32.23MB (32.67%)" fontsize=24 shape=box tooltip="line3002 testdata/file3000.src (32.23MB)" color="#b23200" fillcolor="#eddcd5"]
4
 N1 [label="line3002\nfile3000.src\n31.25MB (31.68%)\nof 32.23MB (32.67%)" fontsize=24 shape=box tooltip="line3002 testdata/file3000.src (32.23MB)" color="#b23200" fillcolor="#eddcd5"]

+ 1
- 1
internal/driver/testdata/pprof.heap.flat.lines.dot.focus View File

1
-digraph "." {
1
+digraph "unnamed" {
2
 node [style=filled fillcolor="#f8f8f8"]
2
 node [style=filled fillcolor="#f8f8f8"]
3
 subgraph cluster_L { "Build ID: buildid" [shape=box fontsize=16 label="Build ID: buildid\lType: inuse_space\lShowing nodes accounting for 67.38MB, 68.32% of 98.63MB total\l"] }
3
 subgraph cluster_L { "Build ID: buildid" [shape=box fontsize=16 label="Build ID: buildid\lType: inuse_space\lShowing nodes accounting for 67.38MB, 68.32% of 98.63MB total\l"] }
4
 N1 [label="line3000\nfile3000.src:4\n0 of 67.38MB (68.32%)" fontsize=8 shape=box tooltip="line3000 testdata/file3000.src:4 (67.38MB)" color="#b21300" fillcolor="#edd7d5"]
4
 N1 [label="line3000\nfile3000.src:4\n0 of 67.38MB (68.32%)" fontsize=8 shape=box tooltip="line3000 testdata/file3000.src:4 (67.38MB)" color="#b21300" fillcolor="#edd7d5"]

+ 1
- 1
internal/driver/testdata/pprof.heap_alloc.flat.alloc_space.dot.focus View File

1
-digraph "." {
1
+digraph "unnamed" {
2
 node [style=filled fillcolor="#f8f8f8"]
2
 node [style=filled fillcolor="#f8f8f8"]
3
 subgraph cluster_L { "Build ID: buildid" [shape=box fontsize=16 label="Build ID: buildid\lType: alloc_space\lShowing nodes accounting for 93.75MB, 95.05% of 98.63MB total\lDropped 1 node (cum <= 4.93MB)\l"] }
3
 subgraph cluster_L { "Build ID: buildid" [shape=box fontsize=16 label="Build ID: buildid\lType: alloc_space\lShowing nodes accounting for 93.75MB, 95.05% of 98.63MB total\lDropped 1 node (cum <= 4.93MB)\l"] }
4
 N1 [label="line3002\nfile3000.src\n31.25MB (31.68%)\nof 94.73MB (96.04%)" fontsize=20 shape=box tooltip="line3002 testdata/file3000.src (94.73MB)" color="#b20200" fillcolor="#edd5d5"]
4
 N1 [label="line3002\nfile3000.src\n31.25MB (31.68%)\nof 94.73MB (96.04%)" fontsize=20 shape=box tooltip="line3002 testdata/file3000.src (94.73MB)" color="#b20200" fillcolor="#edd5d5"]

+ 1
- 1
internal/driver/testdata/pprof.heap_alloc.flat.alloc_space.dot.hide View File

1
-digraph "." {
1
+digraph "unnamed" {
2
 node [style=filled fillcolor="#f8f8f8"]
2
 node [style=filled fillcolor="#f8f8f8"]
3
 subgraph cluster_L { "Build ID: buildid" [shape=box fontsize=16 label="Build ID: buildid\lType: alloc_space\lShowing nodes accounting for 93.75MB, 95.05% of 98.63MB total\lDropped 1 node (cum <= 4.93MB)\l"] }
3
 subgraph cluster_L { "Build ID: buildid" [shape=box fontsize=16 label="Build ID: buildid\lType: alloc_space\lShowing nodes accounting for 93.75MB, 95.05% of 98.63MB total\lDropped 1 node (cum <= 4.93MB)\l"] }
4
 N1 [label="line3000\nfile3000.src\n62.50MB (63.37%)\nof 98.63MB (100%)" fontsize=24 shape=box tooltip="line3000 testdata/file3000.src (98.63MB)" color="#b20000" fillcolor="#edd5d5"]
4
 N1 [label="line3000\nfile3000.src\n62.50MB (63.37%)\nof 98.63MB (100%)" fontsize=24 shape=box tooltip="line3000 testdata/file3000.src (98.63MB)" color="#b20000" fillcolor="#edd5d5"]

+ 6
- 2
internal/graph/graph.go View File

331
 			if line.Function != nil {
331
 			if line.Function != nil {
332
 				ni.Name = line.Function.Name
332
 				ni.Name = line.Function.Name
333
 				ni.OrigName = line.Function.SystemName
333
 				ni.OrigName = line.Function.SystemName
334
-				ni.File = line.Function.Filename
335
-				ni.StartLine = int(line.Function.StartLine)
334
+				if fname := line.Function.Filename; fname != "" {
335
+					ni.File = filepath.Clean(fname)
336
+				}
337
+				if keepBinary {
338
+					ni.StartLine = int(line.Function.StartLine)
339
+				}
336
 			}
340
 			}
337
 			if keepBinary || line.Function == nil {
341
 			if keepBinary || line.Function == nil {
338
 				ni.Objfile = objfile
342
 				ni.Objfile = objfile

+ 0
- 3
internal/report/report_test.go View File

17
 import (
17
 import (
18
 	"bytes"
18
 	"bytes"
19
 	"io/ioutil"
19
 	"io/ioutil"
20
-	"path/filepath"
21
 	"regexp"
20
 	"regexp"
22
 	"testing"
21
 	"testing"
23
 
22
 
45
 				&Options{
44
 				&Options{
46
 					OutputFormat: List,
45
 					OutputFormat: List,
47
 					Symbol:       regexp.MustCompile(`.`),
46
 					Symbol:       regexp.MustCompile(`.`),
48
-					Title:        filepath.Base(testProfile.Mapping[0].File),
49
 
47
 
50
 					SampleValue: sampleValue1,
48
 					SampleValue: sampleValue1,
51
 					SampleUnit:  testProfile.SampleType[1].Unit,
49
 					SampleUnit:  testProfile.SampleType[1].Unit,
60
 					OutputFormat: Dot,
58
 					OutputFormat: Dot,
61
 					CallTree:     true,
59
 					CallTree:     true,
62
 					Symbol:       regexp.MustCompile(`.`),
60
 					Symbol:       regexp.MustCompile(`.`),
63
-					Title:        filepath.Base(testProfile.Mapping[0].File),
64
 
61
 
65
 					SampleValue: sampleValue1,
62
 					SampleValue: sampleValue1,
66
 					SampleUnit:  testProfile.SampleType[1].Unit,
63
 					SampleUnit:  testProfile.SampleType[1].Unit,

+ 1
- 1
internal/report/testdata/source.dot View File

1
-digraph "." {
1
+digraph "unnamed" {
2
 node [style=filled fillcolor="#f8f8f8"]
2
 node [style=filled fillcolor="#f8f8f8"]
3
 subgraph cluster_L { "Duration: 10s, Total samples = 11111 " [shape=box fontsize=16 label="Duration: 10s, Total samples = 11111 \lShowing nodes accounting for 11111, 100% of 11111 total\l"] }
3
 subgraph cluster_L { "Duration: 10s, Total samples = 11111 " [shape=box fontsize=16 label="Duration: 10s, Total samples = 11111 \lShowing nodes accounting for 11111, 100% of 11111 total\l"] }
4
 N1 [label="tee\nsource2:8\n10000 (90.00%)" fontsize=24 shape=box tooltip="tee testdata/source2:8 (10000)" color="#b20500" fillcolor="#edd6d5"]
4
 N1 [label="tee\nsource2:8\n10000 (90.00%)" fontsize=24 shape=box tooltip="tee testdata/source2:8 (10000)" color="#b20500" fillcolor="#edd6d5"]

+ 1
- 1
internal/symbolizer/symbolizer.go View File

284
 
284
 
285
 		// Skip well-known system mappings
285
 		// Skip well-known system mappings
286
 		name := filepath.Base(m.File)
286
 		name := filepath.Base(m.File)
287
-		if name == "" || name == "[vdso]" || strings.HasPrefix(name, "linux-vdso") {
287
+		if m.File == "" || name == "[vdso]" || strings.HasPrefix(name, "linux-vdso") {
288
 			continue
288
 			continue
289
 		}
289
 		}
290
 
290
 

+ 1
- 0
internal/symbolizer/symbolizer_test.go View File

29
 		ID:    1,
29
 		ID:    1,
30
 		Start: 0x1000,
30
 		Start: 0x1000,
31
 		Limit: 0x5000,
31
 		Limit: 0x5000,
32
+		File:  "mapping",
32
 	},
33
 	},
33
 }
34
 }
34
 
35