aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/report/linux.go
diff options
context:
space:
mode:
authorJoey Jiao <quic_jiangenj@quicinc.com>2024-07-04 11:18:06 +0800
committerAlexander Potapenko <glider@google.com>2024-07-23 12:07:55 +0000
commit063d1761a6208b44ddd25c19e8d6a90acb886731 (patch)
tree0d74e17a7d556a7897460a5ffc58e544c6e11bd5 /pkg/report/linux.go
parent44cd723acfeeb472c42cc2fa6d1279ec4406d07d (diff)
pkg/report: support to symbolize line with module+offset
Diffstat (limited to 'pkg/report/linux.go')
-rw-r--r--pkg/report/linux.go39
1 files changed, 31 insertions, 8 deletions
diff --git a/pkg/report/linux.go b/pkg/report/linux.go
index 596c834ce..816c40fa7 100644
--- a/pkg/report/linux.go
+++ b/pkg/report/linux.go
@@ -16,13 +16,14 @@ import (
"github.com/google/syzkaller/pkg/report/crash"
"github.com/google/syzkaller/pkg/symbolizer"
"github.com/google/syzkaller/pkg/vcs"
+ "github.com/google/syzkaller/pkg/vminfo"
"github.com/google/syzkaller/sys/targets"
)
type linux struct {
*config
vmlinux string
- symbols map[string][]symbolizer.Symbol
+ symbols map[string]map[string][]symbolizer.Symbol
consoleOutputRe *regexp.Regexp
taskContext *regexp.Regexp
cpuContext *regexp.Regexp
@@ -36,16 +37,26 @@ type linux struct {
}
func ctorLinux(cfg *config) (reporterImpl, []string, error) {
- var symbols map[string][]symbolizer.Symbol
+ symbols := make(map[string]map[string][]symbolizer.Symbol)
vmlinux := ""
if cfg.kernelObj != "" {
vmlinux = filepath.Join(cfg.kernelObj, cfg.target.KernelObject)
var err error
symb := symbolizer.NewSymbolizer(cfg.target)
- symbols, err = symb.ReadTextSymbols(vmlinux)
+ symbols[""], err = symb.ReadTextSymbols(vmlinux)
if err != nil {
return nil, nil, err
}
+ for _, mod := range cfg.kernelModules {
+ if mod.Name == "" {
+ continue
+ }
+ ss, err := symb.ReadTextSymbols(mod.Path)
+ if err != nil {
+ continue
+ }
+ symbols[mod.Name] = ss
+ }
}
ctx := &linux{
config: cfg,
@@ -405,7 +416,7 @@ func (ctx *linux) symbolize(rep *Report) error {
prefix := rep.reportPrefixLen
for _, line := range bytes.SplitAfter(rep.Report, []byte("\n")) {
line := bytes.Clone(line)
- newLine := symbolizeLine(symbFunc, ctx.symbols, ctx.vmlinux, ctx.kernelBuildSrc, line)
+ newLine := symbolizeLine(symbFunc, ctx.symbols, ctx.config.kernelModules, ctx.kernelBuildSrc, ctx, line)
if prefix > len(symbolized) {
prefix += len(newLine) - len(line)
}
@@ -426,7 +437,8 @@ func (ctx *linux) symbolize(rep *Report) error {
}
func symbolizeLine(symbFunc func(bin string, pc uint64) ([]symbolizer.Frame, error),
- symbols map[string][]symbolizer.Symbol, vmlinux, strip string, line []byte) []byte {
+ symbols map[string]map[string][]symbolizer.Symbol, modules []*vminfo.KernelModule, strip string,
+ ctx *linux, line []byte) []byte {
match := linuxSymbolizeRe.FindSubmatchIndex(line)
if match == nil {
return line
@@ -440,7 +452,11 @@ func symbolizeLine(symbFunc func(bin string, pc uint64) ([]symbolizer.Frame, err
if err != nil {
return line
}
- symb := symbols[string(fn)]
+ modName := ""
+ if match[10] != -1 && match[11] != -1 {
+ modName = string(line[match[10]:match[11]])
+ }
+ symb := symbols[modName][string(fn)]
if len(symb) == 0 {
return line
}
@@ -456,7 +472,14 @@ func symbolizeLine(symbFunc func(bin string, pc uint64) ([]symbolizer.Frame, err
// But RIP lines contain the exact faulting PC.
pc--
}
- frames, err := symbFunc(vmlinux, pc)
+ var bin string
+ for _, mod := range modules {
+ if mod.Name == modName {
+ bin = mod.Path
+ break
+ }
+ }
+ frames, err := symbFunc(bin, pc)
if err != nil || len(frames) == 0 {
return line
}
@@ -1023,7 +1046,7 @@ var linuxStallAnchorFrames = []*regexp.Regexp{
// nolint: lll
var (
- linuxSymbolizeRe = regexp.MustCompile(`(?:\[\<(?:(?:0x)?[0-9a-f]+)\>\])?[ \t]+\(?(?:[0-9]+:)?([a-zA-Z0-9_.]+)\+0x([0-9a-f]+)/0x([0-9a-f]+)\)?`)
+ linuxSymbolizeRe = regexp.MustCompile(`(?:\[\<(?:(?:0x)?[0-9a-f]+)\>\])?[ \t]+\(?(?:[0-9]+:)?([a-zA-Z0-9_.]+)\+0x([0-9a-f]+)/0x([0-9a-f]+)( ?\[([a-zA-Z0-9_.]+)\])?\)?`)
linuxRipFrame = compile(`(?:IP|NIP|pc |PC is at):? (?:(?:[0-9]+:)?(?:{{PC}} +){0,2}{{FUNC}}|(?:[0-9]+:)?0x[0-9a-f]+|(?:[0-9]+:)?{{PC}} +\[< *\(null\)>\] +\(null\)|[0-9]+: +\(null\))`)
linuxCallTrace = compile(`(?:Call (?:T|t)race:)|(?:Backtrace:)`)
linuxCodeRe = regexp.MustCompile(`(?m)^\s*Code\:\s+((?:[A-Fa-f0-9\(\)\<\>]{2,8}\s*)*)\s*$`)