aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/report/linux.go
diff options
context:
space:
mode:
authorSiddharth M <siddharth.muralee@gmail.com>2019-07-17 15:28:23 +0530
committerDmitry Vyukov <dvyukov@google.com>2019-07-17 11:58:23 +0200
commitf613a7c41d0b3ea16eeaad515e44dec003688ffb (patch)
tree5ee7c4e7ce4539636f078c2add6b981df8c01203 /pkg/report/linux.go
parent0d10349cf0b4a9f98490378709bd9a83bd0042d6 (diff)
pkg/cover: fix prefix computation
* pkg/cover: Modify parsing logic 1. Remove prefix computation 2. Add a mgrconfig for kernel build directory * pkg/report: shorten reports with kernelBuildSrc instead of kernelSrc * pkg/report: Fix failing tests * pkg/report: fix formating issues * tools/syz-cover: Fix unintended redefinition * make changes to fix failing ci build * pkg/report: fix issues
Diffstat (limited to 'pkg/report/linux.go')
-rw-r--r--pkg/report/linux.go44
1 files changed, 9 insertions, 35 deletions
diff --git a/pkg/report/linux.go b/pkg/report/linux.go
index fb12b5509..b9145566b 100644
--- a/pkg/report/linux.go
+++ b/pkg/report/linux.go
@@ -21,6 +21,7 @@ import (
type linux struct {
kernelSrc string
+ kernelBuildSrc string
kernelObj string
vmlinux string
symbols map[string][]symbolizer.Symbol
@@ -35,7 +36,7 @@ type linux struct {
eoi []byte
}
-func ctorLinux(target *targets.Target, kernelSrc, kernelObj string, ignores []*regexp.Regexp) (Reporter, []string, error) {
+func ctorLinux(target *targets.Target, kernelSrc, kernelBuildSrc, kernelObj string, ignores []*regexp.Regexp) (Reporter, []string, error) {
var symbols map[string][]symbolizer.Symbol
vmlinux := ""
if kernelObj != "" {
@@ -47,11 +48,12 @@ func ctorLinux(target *targets.Target, kernelSrc, kernelObj string, ignores []*r
}
}
ctx := &linux{
- kernelSrc: kernelSrc,
- kernelObj: kernelObj,
- vmlinux: vmlinux,
- symbols: symbols,
- ignores: ignores,
+ kernelSrc: kernelSrc,
+ kernelBuildSrc: kernelBuildSrc,
+ kernelObj: kernelObj,
+ vmlinux: vmlinux,
+ symbols: symbols,
+ ignores: ignores,
}
ctx.consoleOutputRe = regexp.MustCompile(`^(?:\*\* [0-9]+ printk messages dropped \*\* )?(?:.* login: )?(?:\<[0-9]+\>)?\[ *[0-9]+\.[0-9]+\](\[ *(?:C|T)[0-9]+\])? `)
ctx.questionableRes = []*regexp.Regexp{
@@ -335,14 +337,13 @@ func (ctx *linux) Symbolize(rep *Report) error {
func (ctx *linux) symbolize(rep *Report) error {
symb := symbolizer.NewSymbolizer()
defer symb.Close()
- strip := ctx.stripPrefix(symb)
var symbolized []byte
s := bufio.NewScanner(bytes.NewReader(rep.Report))
prefix := rep.reportPrefixLen
for s.Scan() {
line := append([]byte{}, s.Bytes()...)
line = append(line, '\n')
- newLine := symbolizeLine(symb.Symbolize, ctx.symbols, ctx.vmlinux, strip, line)
+ newLine := symbolizeLine(symb.Symbolize, ctx.symbols, ctx.vmlinux, ctx.kernelBuildSrc, line)
if prefix > len(symbolized) {
prefix += len(newLine) - len(line)
}
@@ -353,33 +354,6 @@ func (ctx *linux) symbolize(rep *Report) error {
return nil
}
-func (ctx *linux) stripPrefix(symb *symbolizer.Symbolizer) string {
- // Vmlinux may have been moved, so check if we can find debug info
- // for some known functions and infer correct strip prefix from it.
- knownSymbols := []struct {
- symbol string
- file string
- }{
- {"__sanitizer_cov_trace_pc", "kernel/kcov.c"},
- {"__asan_load1", "mm/kasan/kasan.c"},
- {"start_kernel", "init/main.c"},
- }
- for _, s := range knownSymbols {
- for _, covSymb := range ctx.symbols[s.symbol] {
- frames, _ := symb.Symbolize(ctx.vmlinux, covSymb.Addr)
- if len(frames) > 0 {
- file := frames[len(frames)-1].File
- if idx := strings.Index(file, s.file); idx != -1 {
- return file[:idx]
- }
- }
- }
- }
- // Strip vmlinux location from all paths.
- strip, _ := filepath.Abs(ctx.vmlinux)
- return filepath.Dir(strip) + string(filepath.Separator)
-}
-
func symbolizeLine(symbFunc func(bin string, pc uint64) ([]symbolizer.Frame, error),
symbols map[string][]symbolizer.Symbol, vmlinux, strip string, line []byte) []byte {
match := linuxSymbolizeRe.FindSubmatchIndex(line)