Skip to content
Snippets Groups Projects
addr2line4Mac.py 1.3 KiB
Newer Older
  • Learn to ignore specific revisions
  • #! /usr/bin/python
    
    import sys
    filename=sys.argv[1]
    address=sys.argv[2]
    import re
    
    fullFile=None
    if path.exists(filename):
        fullFile=filename
    
        if not v in environ:
            continue
    
        if not fullFile:
            for d in environ[v].split(':'):
                if path.exists(path.join(d,filename)):
                    fullFile=path.join(d,filename)
                    break
    
    if path.exists(fullFile):
        import subprocess
    
        result=subprocess.Popen(["xcrun", "atos",
                                 "-o",fullFile,
                                 address],
                                stdout=subprocess.PIPE
                            ).communicate()[0]
        match=re.compile('.+ \((.+)\) \((.+)\)').match(result)
        if match:
            answer=match.group(2)+" "+match.group(1)
        else:
            import os
            result=subprocess.Popen(["xcrun", "atos",
                                     "-p",str(os.getppid()),
                                     address],
                                    stdout=subprocess.PIPE
                                ).communicate()[0]
            match=re.compile('.+ \((.+)\) \((.+)\)').match(result)
            if match:
                answer=match.group(2)+" "+match.group(1)