Spin Control
September 9th, 2009
This little script takes Spin Control output from a running process and tries to demangle the symbols to get sample stacks. It was just a quick hack. Someone make it better!
I used the script to file bug 515447. You can use it by turning on Spin Control and running it on the text file output. I don’t know why Spin Control can’t find the symbols itself. There are also some other options for running atos that probably don’t need a running process. You’ll need a build that has symbols, like the Shark-enabled nightlies do.
from __future__ import with_statement
from subprocess import Popen, PIPE
firefox_pid = 85034
spin_file_path = "/Users/sayrer/Desktop/spinout.txt"
class memoize:
def __init__(self, function):
self.function = function
self.memoized = {}
def __call__(self, *args):
try:
return self.memoized[args]
except KeyError:
self.memoized[args] = self.function(*args)
return self.memoized[args]
@memoize
def findSymbol(word):
# run atos
cmd = ["atos", "-p", str(firefox_pid), word]
proc = Popen(cmd, stdout=PIPE)
stdout, stderr = proc.communicate()
return stdout[0:-1]
def demangle(words):
output = ""
for word in words:
if word.startswith("0x"):
word = findSymbol(word)
output += " " + word
return output
with open(spin_file_path) as a_file:
for line in a_file.readlines():
indent = len(line) - len(line.lstrip())
words = line.split()
print line[0:indent], demangle(words)
Feel free to improve.
September 9th, 2009 at 12:34 pm
Can we just get this checked into tools/ in m-c?
September 9th, 2009 at 10:17 pm
ALL GLORY TO THE HYPNOWHEEL