aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2024-04-09 10:29:06 +0200
committerDmitry Vyukov <dvyukov@google.com>2024-04-09 12:15:39 +0000
commitb3198cd94cc221153d34443bc657c799ec47a2ed (patch)
tree32f1a630a8aaafadd345b5c368e6c7ed35f6daef /pkg
parente38e134c4df9e4b637ba5140cff0904ebe5491b1 (diff)
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.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/symbolizer/symbolizer.go28
1 files changed, 1 insertions, 27 deletions
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
}