2016-04-06 16:15:48 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
# This file was originally written by Matthew Naylor, University of
|
|
|
|
# Cambridge.
|
|
|
|
#
|
|
|
|
# This software was partly developed by the University of Cambridge
|
|
|
|
# Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237
|
|
|
|
# ("CTSRD"), as part of the DARPA CRASH research programme.
|
|
|
|
#
|
|
|
|
# This software was partly developed by the University of Cambridge
|
|
|
|
# Computer Laboratory under DARPA/AFRL contract FA8750-11-C-0249
|
|
|
|
# ("MRC2"), as part of the DARPA MRC research programme.
|
|
|
|
#
|
|
|
|
# This software was partly developed by the University of Cambridge
|
|
|
|
# Computer Laboratory as part of the Rigorous Engineering of
|
|
|
|
# Mainstream Systems (REMS) project, funded by EPSRC grant
|
|
|
|
# EP/K008528/1.
|
|
|
|
|
|
|
|
# -------
|
|
|
|
# Outline
|
|
|
|
# -------
|
|
|
|
|
|
|
|
# Usage:
|
|
|
|
#
|
|
|
|
# tracegen.py EMULATOR SEED
|
|
|
|
#
|
|
|
|
# This script generates a trace using the given emulator (built
|
|
|
|
# with CONFIG=TraceGenConfig). It waits until all cores have
|
|
|
|
# completed trace generation before terminating the emulator.
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import subprocess
|
|
|
|
import re
|
|
|
|
|
|
|
|
def main():
|
2016-07-05 22:50:17 +02:00
|
|
|
if len(sys.argv) != 3:
|
|
|
|
sys.stderr.write("Usage: tracegen.py EMULATOR SEED\n")
|
2016-04-06 16:15:48 +02:00
|
|
|
sys.exit(-1)
|
|
|
|
|
2016-05-23 18:02:15 +02:00
|
|
|
p = subprocess.Popen([sys.argv[1],
|
2016-07-05 22:50:17 +02:00
|
|
|
"+verbose", "-s" + sys.argv[2]],
|
2016-04-06 16:15:48 +02:00
|
|
|
stderr=subprocess.PIPE, stdout=subprocess.PIPE)
|
|
|
|
if p == None:
|
|
|
|
sys.stderr.write("File not found: " + sys.argv[1] + "\n")
|
|
|
|
sys.exit(-1)
|
|
|
|
|
|
|
|
numFinished = 0
|
|
|
|
while True:
|
|
|
|
line = p.stderr.readline()
|
|
|
|
if line[0:9] == "FINISHED ":
|
|
|
|
total = int(line[9:-1])
|
|
|
|
numFinished = numFinished + 1
|
|
|
|
if numFinished == total:
|
|
|
|
break
|
2016-11-22 20:05:30 +01:00
|
|
|
elif line[0:12] == "using random":
|
|
|
|
continue
|
2016-04-06 16:15:48 +02:00
|
|
|
else:
|
|
|
|
print line,
|
|
|
|
|
|
|
|
p.terminate()
|
|
|
|
|
|
|
|
try:
|
|
|
|
main()
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
sys.exit(-1)
|