aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/symbolizer/symbolizer.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/pkg/symbolizer/symbolizer.go b/pkg/symbolizer/symbolizer.go
index 96b62fb95..158cb9dd1 100644
--- a/pkg/symbolizer/symbolizer.go
+++ b/pkg/symbolizer/symbolizer.go
@@ -7,6 +7,7 @@ package symbolizer
import (
"bufio"
+ "bytes"
"fmt"
"io"
"os/exec"
@@ -63,6 +64,22 @@ func (s *Symbolizer) Close() {
}
}
+func (s *Symbolizer) checkBinSupport(addr2line string) error {
+ cmd := exec.Command(addr2line, "--help")
+ out, err := cmd.CombinedOutput()
+ if err != nil {
+ return fmt.Errorf("addr2line execution failed: %s", err)
+ }
+ if !bytes.Contains(out, []byte("supported targets:")) {
+ return fmt.Errorf("addr2line output didn't contain supported targets")
+ }
+ if s.target.OS == targets.Darwin && s.target.Arch == targets.AMD64 &&
+ !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
@@ -71,6 +88,10 @@ func (s *Symbolizer) getSubprocess(bin string) (*subprocess, error) {
if s.target.Triple != "" {
addr2line = s.target.Triple + "-" + addr2line
}
+ err := s.checkBinSupport(addr2line)
+ if err != nil {
+ return nil, err
+ }
cmd := osutil.Command(addr2line, "-afi", "-e", bin)
stdin, err := cmd.StdinPipe()
if err != nil {