浏览代码

Add a helper function to check if a mapping is unsymbolizable.

The local symbolization already skips these mappings. Have the helper
which can be used when alternative symbolization flows are used.
Alexey Alexandrov 8 年前
父节点
当前提交
ced695807b
共有 2 个文件被更改,包括 10 次插入2 次删除
  1. 2
    2
      internal/symbolizer/symbolizer.go
  2. 8
    0
      profile/profile.go

+ 2
- 2
internal/symbolizer/symbolizer.go 查看文件

298
 		}
298
 		}
299
 
299
 
300
 		// Skip well-known system mappings
300
 		// Skip well-known system mappings
301
-		name := filepath.Base(m.File)
302
-		if name == "[vdso]" || strings.HasPrefix(name, "linux-vdso") {
301
+		if m.Unsymbolizable() {
303
 			continue
302
 			continue
304
 		}
303
 		}
305
 
304
 
310
 			}
309
 			}
311
 		}
310
 		}
312
 
311
 
312
+		name := filepath.Base(m.File)
313
 		f, err := obj.Open(m.File, m.Start, m.Limit, m.Offset)
313
 		f, err := obj.Open(m.File, m.Start, m.Limit, m.Offset)
314
 		if err != nil {
314
 		if err != nil {
315
 			ui.PrintErr("Local symbolization failed for ", name, ": ", err)
315
 			ui.PrintErr("Local symbolization failed for ", name, ": ", err)

+ 8
- 0
profile/profile.go 查看文件

22
 	"fmt"
22
 	"fmt"
23
 	"io"
23
 	"io"
24
 	"io/ioutil"
24
 	"io/ioutil"
25
+	"path/filepath"
25
 	"regexp"
26
 	"regexp"
26
 	"sort"
27
 	"sort"
27
 	"strings"
28
 	"strings"
583
 	return true
584
 	return true
584
 }
585
 }
585
 
586
 
587
+// Unsymbolizable returns true if a mapping points to a binary for which
588
+// locations can't be symbolized in principle, at least now.
589
+func (m *Mapping) Unsymbolizable() bool {
590
+	name := filepath.Base(m.File)
591
+	return name == "[vdso]" || strings.HasPrefix(name, "linux-vdso")
592
+}
593
+
586
 // Copy makes a fully independent copy of a profile.
594
 // Copy makes a fully independent copy of a profile.
587
 func (p *Profile) Copy() *Profile {
595
 func (p *Profile) Copy() *Profile {
588
 	p.preEncode()
596
 	p.preEncode()