瀏覽代碼

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

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

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

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

@@ -272,7 +272,8 @@ func newMapping(prof *profile.Profile, obj plugin.ObjTool, ui plugin.UI, force b
272 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 277
 		if !mappings[m] {
277 278
 			continue
278 279
 		}
@@ -282,9 +283,19 @@ func newMapping(prof *profile.Profile, obj plugin.ObjTool, ui plugin.UI, force b
282 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 296
 		// Skip well-known system mappings
286 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 299
 			continue
289 300
 		}
290 301
 
@@ -301,7 +312,9 @@ func newMapping(prof *profile.Profile, obj plugin.ObjTool, ui plugin.UI, force b
301 312
 
302 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 318
 	return mt, nil
306 319
 }
307 320