Browse Source

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 years ago
parent
commit
ea9fac9fa3
2 changed files with 8 additions and 2 deletions
  1. 7
    2
      internal/driver/fetch.go
  2. 1
    0
      internal/driver/fetch_test.go

+ 7
- 2
internal/driver/fetch.go View File

@@ -344,8 +344,13 @@ mapping:
344 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 355
 			for _, name := range fileNames {
351 356
 				if f, err := obj.Open(name, m.Start, m.Limit, m.Offset); err == nil {

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

@@ -57,6 +57,7 @@ func TestSymbolizationPath(t *testing.T) {
57 57
 	}{
58 58
 		{"", "/usr/bin/binary", "", "/usr/bin/binary", 0},
59 59
 		{"", "/usr/bin/binary", "fedcb10000", "/usr/bin/binary", 0},
60
+		{"/usr", "/bin/binary", "", "/usr/bin/binary", 0},
60 61
 		{"", "/prod/path/binary", "abcde10001", filepath.Join(tempdir, "pprof/binaries/abcde10001/binary"), 0},
61 62
 		{"/alternate/architecture", "/usr/bin/binary", "", "/alternate/architecture/binary", 0},
62 63
 		{"/alternate/architecture", "/usr/bin/binary", "abcde10001", "/alternate/architecture/binary", 0},