From b91b6218da233088c198ead6028f7010e9aa7e7d Mon Sep 17 00:00:00 2001 From: Zach Riggle Date: Tue, 31 Jan 2017 15:13:08 -0500 Subject: [PATCH] Add pwndb.events.start.on_stop --- pwndbg/events.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pwndbg/events.py b/pwndbg/events.py index 7f8fb6256..14878e6ef 100644 --- a/pwndbg/events.py +++ b/pwndbg/events.py @@ -32,6 +32,10 @@ pause = 0 # # We also get an Objfile event when we load up GDB, so we need # 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): def __init__(self): self.registered = list() @@ -49,11 +53,16 @@ class StartEvent(object): self.running = True for function in self.registered: + if debug: + sys.stdout.write('%r %s.%s\n' % ('start', function.__module__, function.__name__)) function() def on_exited(self): self.running = False + def on_stop(self): + self.on_new_objfile() + gdb.events.start = StartEvent() # 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() @exit -def _start_stop(): +def _start_exit(): gdb.events.start.on_exited() +@stop +def _start_stop(): + gdb.events.start.on_stop() + @exit def _reset_objfiles(): global objfile_cache