Assign context object to Manticore itself (#13)
* Make Manticore behave like a dict; slim callback * Update all sample scripts to not take a context * Add a sample script (count_instructions.py) * We no longer need to close over Manticore state; add callback directly * Move Manticore's context to a public attribute
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
|
||||
import sys
|
||||
from manticore import Manticore
|
||||
|
||||
'''
|
||||
Count the number of emulated instructions.
|
||||
|
||||
This example uses the context property of the Manticore object to store data
|
||||
that's updated by the hook function. Manticore.context is needed to properly
|
||||
share data when running with multiple worker processes.
|
||||
'''
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) < 2:
|
||||
sys.stderr.write("Usage: %s [binary]\n"%(sys.argv[0],))
|
||||
sys.exit(2)
|
||||
|
||||
m = Manticore(sys.argv[1])
|
||||
m.workers = 3
|
||||
m.context['count'] = 0
|
||||
|
||||
def explore(state):
|
||||
m.context['count'] += 1
|
||||
|
||||
m.add_hook(None, explore)
|
||||
|
||||
m.start()
|
||||
|
||||
print "Executed ", m.context['count'], " instructions."
|
||||
Reference in New Issue
Block a user