From b3198cd94cc221153d34443bc657c799ec47a2ed Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 9 Apr 2024 10:29:06 +0200 Subject: pkg/symbolizer: use llvm-addr2line Use llvm-addr2line instead of addr2line if it's available. llvm-addr2line seems to be way faster than llvm-addr2line and consumes less memory on syzbot's vmlinux. Also move the detection logic to sys/targets since that's where we generally do this type of logic. This also allows to reuse addr2line binary in other packages if needed. --- pkg/symbolizer/symbolizer.go | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) (limited to 'pkg') diff --git a/pkg/symbolizer/symbolizer.go b/pkg/symbolizer/symbolizer.go index fb378d09f..ad57f005e 100644 --- a/pkg/symbolizer/symbolizer.go +++ b/pkg/symbolizer/symbolizer.go @@ -7,10 +7,8 @@ package symbolizer import ( "bufio" - "bytes" "fmt" "io" - "os" "os/exec" "strconv" "strings" @@ -65,35 +63,11 @@ func (s *Symbolizer) Close() { } } -func (s *Symbolizer) checkBinSupport(addr2line string) error { - if s.target.OS != targets.Darwin || s.target.Arch != targets.AMD64 { - return nil - } - - cmd := exec.Command(addr2line, "--help") - cmd.Env = append(os.Environ(), "LC_ALL=C") - out, err := cmd.CombinedOutput() - if err != nil { - return fmt.Errorf("addr2line execution failed: %w", err) - } - if !bytes.Contains(out, []byte("supported targets:")) { - return fmt.Errorf("addr2line output didn't contain supported targets") - } - if !bytes.Contains(out, []byte("mach-o-x86-64")) { - return fmt.Errorf("addr2line was built without mach-o-x86-64 support") - } - return nil -} - func (s *Symbolizer) getSubprocess(bin string) (*subprocess, error) { if sub := s.subprocs[bin]; sub != nil { return sub, nil } - addr2line := "addr2line" - if s.target.Triple != "" { - addr2line = s.target.Triple + "-" + addr2line - } - err := s.checkBinSupport(addr2line) + addr2line, err := s.target.Addr2Line() if err != nil { return nil, err } -- cgit mrf-deployment