Commit f24d0b86 authored by Guido van Rossum's avatar Guido van Rossum

Add the same recovering behavior as for stat.py.

parent 2fcdaaa0
...@@ -97,13 +97,28 @@ def main(): ...@@ -97,13 +97,28 @@ def main():
sim.printheader() sim.printheader()
# Read trace file, simulating cache behavior # Read trace file, simulating cache behavior
offset = 0
records = 0
f_read = f.read
struct_unpack = struct.unpack
while 1: while 1:
# Read a record # Read a record and decode it
r = f.read(24) r = f_read(8)
if len(r) < 24: if len(r) < 8:
break break
# Decode it offset += 8
ts, code, oid, serial = struct.unpack(">ii8s8s", r) ts, code = struct_unpack(">ii", r)
if ts == 0:
# Must be a misaligned record caused by a crash
print "Skipping 8 bytes at offset", offset-8
continue
r = f_read(16)
if len(r) < 16:
break
offset += 16
records += 1
oid, serial = struct_unpack(">8s8s", r)
# Decode the code
dlen, version, code, current = (code & 0x7fffff00, dlen, version, code, current = (code & 0x7fffff00,
code & 0x80, code & 0x80,
code & 0x7e, code & 0x7e,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment