浏览代码

Add diagnostics for symbolization without mapping filenames

Raul Silvera 9 年前
父节点
当前提交
cf9a1f462e
共有 3 个文件被更改,包括 18 次插入5 次删除
  1. 1
    1
      internal/graph/graph.go
  2. 1
    1
      internal/report/report.go
  3. 16
    3
      internal/symbolizer/symbolizer.go

+ 1
- 1
internal/graph/graph.go 查看文件

412
 
412
 
413
 func (nm NodeMap) findOrInsertLocation(l *profile.Location, keepBinary bool, kept NodeSet) Nodes {
413
 func (nm NodeMap) findOrInsertLocation(l *profile.Location, keepBinary bool, kept NodeSet) Nodes {
414
 	var objfile string
414
 	var objfile string
415
-	if m := l.Mapping; m != nil {
415
+	if m := l.Mapping; m != nil && m.File != "" {
416
 		objfile = filepath.Base(m.File)
416
 		objfile = filepath.Base(m.File)
417
 	}
417
 	}
418
 
418
 

+ 1
- 1
internal/report/report.go 查看文件

909
 func NewDefault(prof *profile.Profile, options Options) *Report {
909
 func NewDefault(prof *profile.Profile, options Options) *Report {
910
 	index := len(prof.SampleType) - 1
910
 	index := len(prof.SampleType) - 1
911
 	o := &options
911
 	o := &options
912
-	if o.Title == "" && len(prof.Mapping) > 0 {
912
+	if o.Title == "" && len(prof.Mapping) > 0 && prof.Mapping[0].File != "" {
913
 		o.Title = filepath.Base(prof.Mapping[0].File)
913
 		o.Title = filepath.Base(prof.Mapping[0].File)
914
 	}
914
 	}
915
 	o.SampleType = prof.SampleType[index].Type
915
 	o.SampleType = prof.SampleType[index].Type

+ 16
- 3
internal/symbolizer/symbolizer.go 查看文件

272
 		mappings[l.Mapping] = true
272
 		mappings[l.Mapping] = true
273
 	}
273
 	}
274
 
274
 
275
-	for _, m := range prof.Mapping {
275
+	missingBinaries := false
276
+	for mix, m := range prof.Mapping {
276
 		if !mappings[m] {
277
 		if !mappings[m] {
277
 			continue
278
 			continue
278
 		}
279
 		}
282
 			continue
283
 			continue
283
 		}
284
 		}
284
 
285
 
286
+		if m.File == "" {
287
+			if mix == 0 {
288
+				ui.PrintErr("Main binary filename not available.\n" +
289
+					"Try passing the path to the main binary before the profile.")
290
+				continue
291
+			}
292
+			missingBinaries = true
293
+			continue
294
+		}
295
+		
285
 		// Skip well-known system mappings
296
 		// Skip well-known system mappings
286
 		name := filepath.Base(m.File)
297
 		name := filepath.Base(m.File)
287
-		if m.File == "" || name == "[vdso]" || strings.HasPrefix(name, "linux-vdso") {
298
+		if name == "[vdso]" || strings.HasPrefix(name, "linux-vdso") {
288
 			continue
299
 			continue
289
 		}
300
 		}
290
 
301
 
301
 
312
 
302
 		mt.segments[m] = f
313
 		mt.segments[m] = f
303
 	}
314
 	}
304
-
315
+	if missingBinaries {
316
+		ui.PrintErr("Some binary filenames not available. Symbolization may be incomplete.")
317
+	}
305
 	return mt, nil
318
 	return mt, nil
306
 }
319
 }
307
 
320