Skip to content

Instantly share code, notes, and snippets.

@luser

luser/stack.py

Created Sep 6, 2017
Embed
What would you like to do?
import fileinput
import re
r = re.compile('^\s*\d+\s*([^\s]+)')
rsp_r = re.compile('rsp\s=\s(0x[a-f0-9]+)')
prev_fn = None
this_fn = None
prev_rsp = None
for line in fileinput.input():
m = r.match(line)
if m:
prev_fn = this_fn
this_fn = m.group(1)
else:
m = rsp_r.search(line)
if m:
rsp = int(m.group(1), 16)
if prev_rsp is not None:
size = rsp - prev_rsp
print '%d %s' % (size, prev_fn)
prev_fn = this_fn
prev_rsp = rsp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment