Fix empty trace file (#39)

* Improve .trace generation

* Rm unused self.trace stuff
This commit is contained in:
Mark Mossberg 2017-03-01 13:47:55 -05:00 committed by GitHub
parent f0069792c3
commit 04d95735ac
2 changed files with 4 additions and 13 deletions

View File

@ -100,7 +100,6 @@ class State(object):
return ret
def __init__(self, constraints, model):
self.trace = []
self.model = model
self.forks = 0
self.co = self.get_new_id()
@ -140,7 +139,6 @@ class State(object):
assert self._child is None
new_state = State(self.constraints.__enter__(), self.model)
new_state.visited = set(self.visited)
new_state.trace = self.last_pc
new_state.forks = self.forks + 1
new_state.co = State.get_new_id()
new_state.input_symbols = self.input_symbols
@ -681,11 +679,10 @@ class Executor(object):
f.write(output.getvalue())
output.close()
# Save execution trace
tracefile = 'test_{:08x}.trace'.format(test_number)
with open(self._getFilename(tracefile), 'wb') as f:
f.write('\n'.join(["0x%08x"%i[1] for i in state.trace]))
with open(self._getFilename(tracefile), 'w') as f:
for _, pc in state.visited:
f.write('0x{:08x}\n'.format(pc))
# Save constraints formula
smtfile = 'test_{:08x}.smt'.format(test_number)
@ -881,12 +878,6 @@ class Executor(object):
if not current_state.execute():
break
if replay_path:
if self.replay_path[len(current_state.trace)-1] != current_state.trace[-1][1]:
logger.debug("Silently ignoring state, trace dosen't match the replay")
current_state = None
continue
#TODO: maybe generalize as hook
if current_state.last_pc not in local_visited:
local_visited.add(current_state.last_pc)

View File

@ -34,7 +34,7 @@ for filename in saved_states:
#load the whole saved state (memory/cpu/solver/..)
state = cPickle.loads(f.read())
lastpc = 'ROOT'
for proc, pc in state.trace:
for proc, pc in state.visited:
assert proc == 0, 'Multi process no supported'
db[pc] = db.setdefault(pc,0) + 1
edges.setdefault(lastpc,[]).append(pc)