瀏覽代碼

Search files under PPROF_BINARY_PATH using both its basename and its full path

This allows pointing PPROF_BINARY_PATH to the root of the filesystem containing
the binaries of interest, similar to perf symfs.

This fixes #96
Raul Silvera 8 年之前
父節點
當前提交
ea9fac9fa3
共有 2 個檔案被更改,包括 8 行新增2 行删除
  1. 7
    2
      internal/driver/fetch.go
  2. 1
    0
      internal/driver/fetch_test.go

+ 7
- 2
internal/driver/fetch.go 查看文件

344
 					fileNames = append(fileNames, matches...)
344
 					fileNames = append(fileNames, matches...)
345
 				}
345
 				}
346
 			}
346
 			}
347
-			if baseName != "" {
348
-				fileNames = append(fileNames, filepath.Join(path, baseName))
347
+			if m.File != "" {
348
+				// Try both the basename and the full path, to support the same directory
349
+				// structure as the perf symfs option.
350
+				if baseName != "" {
351
+					fileNames = append(fileNames, filepath.Join(path, baseName))
352
+				}
353
+				fileNames = append(fileNames, filepath.Join(path, m.File))
349
 			}
354
 			}
350
 			for _, name := range fileNames {
355
 			for _, name := range fileNames {
351
 				if f, err := obj.Open(name, m.Start, m.Limit, m.Offset); err == nil {
356
 				if f, err := obj.Open(name, m.Start, m.Limit, m.Offset); err == nil {

+ 1
- 0
internal/driver/fetch_test.go 查看文件

57
 	}{
57
 	}{
58
 		{"", "/usr/bin/binary", "", "/usr/bin/binary", 0},
58
 		{"", "/usr/bin/binary", "", "/usr/bin/binary", 0},
59
 		{"", "/usr/bin/binary", "fedcb10000", "/usr/bin/binary", 0},
59
 		{"", "/usr/bin/binary", "fedcb10000", "/usr/bin/binary", 0},
60
+		{"/usr", "/bin/binary", "", "/usr/bin/binary", 0},
60
 		{"", "/prod/path/binary", "abcde10001", filepath.Join(tempdir, "pprof/binaries/abcde10001/binary"), 0},
61
 		{"", "/prod/path/binary", "abcde10001", filepath.Join(tempdir, "pprof/binaries/abcde10001/binary"), 0},
61
 		{"/alternate/architecture", "/usr/bin/binary", "", "/alternate/architecture/binary", 0},
62
 		{"/alternate/architecture", "/usr/bin/binary", "", "/alternate/architecture/binary", 0},
62
 		{"/alternate/architecture", "/usr/bin/binary", "abcde10001", "/alternate/architecture/binary", 0},
63
 		{"/alternate/architecture", "/usr/bin/binary", "abcde10001", "/alternate/architecture/binary", 0},