Add pwndb.events.start.on_stop

pull/157/head
Zach Riggle 9 years ago
parent 95f7a1d94c
commit b91b6218da

@ -32,6 +32,10 @@ pause = 0
# #
# We also get an Objfile event when we load up GDB, so we need # We also get an Objfile event when we load up GDB, so we need
# to detect when the binary is running or not. # to detect when the binary is running or not.
#
# Additionally, when attaching to a process running under QEMU, the
# very first event which is fired is a 'stop' event. We need to
# capture this so that we can fire off all of the 'start' events first.
class StartEvent(object): class StartEvent(object):
def __init__(self): def __init__(self):
self.registered = list() self.registered = list()
@ -49,11 +53,16 @@ class StartEvent(object):
self.running = True self.running = True
for function in self.registered: for function in self.registered:
if debug:
sys.stdout.write('%r %s.%s\n' % ('start', function.__module__, function.__name__))
function() function()
def on_exited(self): def on_exited(self):
self.running = False self.running = False
def on_stop(self):
self.on_new_objfile()
gdb.events.start = StartEvent() gdb.events.start = StartEvent()
# In order to support reloading, we must be able to re-fire # In order to support reloading, we must be able to re-fire
@ -164,9 +173,13 @@ def _start_newobjfile():
gdb.events.start.on_new_objfile() gdb.events.start.on_new_objfile()
@exit @exit
def _start_stop(): def _start_exit():
gdb.events.start.on_exited() gdb.events.start.on_exited()
@stop
def _start_stop():
gdb.events.start.on_stop()
@exit @exit
def _reset_objfiles(): def _reset_objfiles():
global objfile_cache global objfile_cache

Loading…
Cancel
Save