Parcourir la 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 il y a 9 ans
Parent
révision
1c9cb2e8d3

+ 1
- 1
internal/driver/driver.go Voir le fichier

@@ -235,7 +235,7 @@ func reportOptions(p *profile.Profile, vars variables) (*report.Options, error)
235 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 239
 		ropt.Title = filepath.Base(p.Mapping[0].File)
240 240
 	}
241 241
 

+ 1
- 1
internal/driver/testdata/pprof.contention.cum.files.dot Voir le fichier

@@ -1,4 +1,4 @@
1
-digraph "." {
1
+digraph "unnamed" {
2 2
 node [style=filled fillcolor="#f8f8f8"]
3 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 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 Voir le fichier

@@ -1,4 +1,4 @@
1
-digraph "." {
1
+digraph "unnamed" {
2 2
 node [style=filled fillcolor="#f8f8f8"]
3 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 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 Voir le fichier

@@ -1,4 +1,4 @@
1
-digraph "." {
1
+digraph "unnamed" {
2 2
 node [style=filled fillcolor="#f8f8f8"]
3 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 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 Voir le fichier

@@ -1,4 +1,4 @@
1
-digraph "." {
1
+digraph "unnamed" {
2 2
 node [style=filled fillcolor="#f8f8f8"]
3 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 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 Voir le fichier

@@ -1,4 +1,4 @@
1
-digraph "." {
1
+digraph "unnamed" {
2 2
 node [style=filled fillcolor="#f8f8f8"]
3 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 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 Voir le fichier

@@ -1,4 +1,4 @@
1
-digraph "." {
1
+digraph "unnamed" {
2 2
 node [style=filled fillcolor="#f8f8f8"]
3 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 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 Voir le fichier

@@ -1,4 +1,4 @@
1
-digraph "." {
1
+digraph "unnamed" {
2 2
 node [style=filled fillcolor="#f8f8f8"]
3 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 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 Voir le fichier

@@ -331,8 +331,12 @@ func NewLocInfo(prof *profile.Profile, keepBinary bool) map[uint64][]NodeInfo {
331 331
 			if line.Function != nil {
332 332
 				ni.Name = line.Function.Name
333 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 341
 			if keepBinary || line.Function == nil {
338 342
 				ni.Objfile = objfile

+ 0
- 3
internal/report/report_test.go Voir le fichier

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

+ 1
- 1
internal/report/testdata/source.dot Voir le fichier

@@ -1,4 +1,4 @@
1
-digraph "." {
1
+digraph "unnamed" {
2 2
 node [style=filled fillcolor="#f8f8f8"]
3 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 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 Voir le fichier

@@ -284,7 +284,7 @@ func newMapping(prof *profile.Profile, obj plugin.ObjTool, ui plugin.UI, force b
284 284
 
285 285
 		// Skip well-known system mappings
286 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 288
 			continue
289 289
 		}
290 290
 

+ 1
- 0
internal/symbolizer/symbolizer_test.go Voir le fichier

@@ -29,6 +29,7 @@ var testM = []*profile.Mapping{
29 29
 		ID:    1,
30 30
 		Start: 0x1000,
31 31
 		Limit: 0x5000,
32
+		File:  "mapping",
32 33
 	},
33 34
 }
34 35