This repository has been archived on 2023-11-20. You can view files and clone it, but cannot push or open issues or pull requests.
foam-extend4.1-coherent-io/bin/addr2line4Mac.py

31 lines
737 B
Python
Raw Normal View History

#! /usr/bin/python
import sys
filename=sys.argv[1]
address=sys.argv[2]
import re
import subprocess
p = subprocess.Popen("gdb -batch -x /dev/stdin",
shell=True,
bufsize=0,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
close_fds=True)
(child_stdin, child_stdout) = (p.stdin, p.stdout)
child_stdin.write("set sharedlibrary preload-libraries no\n")
child_stdin.write("file "+filename+"\n")
child_stdin.write("info line *"+address+"\n")
result=child_stdout.readline()
answer="??:0"
match=re.compile('Line (.+) of "(.+)" starts at').match(result)
if match:
answer=match.group(2)+":"+match.group(1)
print answer,
sys.exit(255)