|
@@ -339,7 +339,8 @@ func printPageClosing(w io.Writer) {
|
339
|
339
|
// file and annotates it with the samples in fns. Returns the sources
|
340
|
340
|
// as nodes, using the info.name field to hold the source code.
|
341
|
341
|
func getSourceFromFile(file, sourcePath string, fns graph.Nodes, start, end int) (graph.Nodes, string, error) {
|
342
|
|
- f, file, err := openSourceFile(file, sourcePath)
|
|
342
|
+ file = trimPath(file)
|
|
343
|
+ f, err := openSourceFile(file, sourcePath)
|
343
|
344
|
if err != nil {
|
344
|
345
|
return nil, file, err
|
345
|
346
|
}
|
|
@@ -434,12 +435,10 @@ func getMissingFunctionSource(filename string, asm map[int]graph.Nodes, start, e
|
434
|
435
|
// profile. File names in a profile after often relative paths, so
|
435
|
436
|
// search them in each of the paths in searchPath (or CWD by default),
|
436
|
437
|
// and their parents.
|
437
|
|
-func openSourceFile(path, searchPath string) (*os.File, string, error) {
|
438
|
|
- path = trimPath(path)
|
439
|
|
-
|
|
438
|
+func openSourceFile(path, searchPath string) (*os.File, error) {
|
440
|
439
|
if filepath.IsAbs(path) {
|
441
|
440
|
f, err := os.Open(path)
|
442
|
|
- return f, path, err
|
|
441
|
+ return f, err
|
443
|
442
|
}
|
444
|
443
|
|
445
|
444
|
// Scan each component of the path
|
|
@@ -448,7 +447,7 @@ func openSourceFile(path, searchPath string) (*os.File, string, error) {
|
448
|
447
|
for {
|
449
|
448
|
filename := filepath.Join(dir, path)
|
450
|
449
|
if f, err := os.Open(filename); err == nil {
|
451
|
|
- return f, filename, nil
|
|
450
|
+ return f, nil
|
452
|
451
|
}
|
453
|
452
|
parent := filepath.Dir(dir)
|
454
|
453
|
if parent == dir {
|
|
@@ -458,7 +457,7 @@ func openSourceFile(path, searchPath string) (*os.File, string, error) {
|
458
|
457
|
}
|
459
|
458
|
}
|
460
|
459
|
|
461
|
|
- return nil, "", fmt.Errorf("Could not find file %s on path %s", path, searchPath)
|
|
460
|
+ return nil, fmt.Errorf("Could not find file %s on path %s", path, searchPath)
|
462
|
461
|
}
|
463
|
462
|
|
464
|
463
|
// trimPath cleans up a path by removing prefixes that are commonly
|