Migrate prompt into prompt.py

Do not fire start events via prompt-hook.

Further fixes #88
pull/106/head
Zach Riggle 9 years ago
parent 00150efce7
commit c443b466b2

@ -56,6 +56,7 @@ import pwndbg.inthook
import pwndbg.memory
import pwndbg.net
import pwndbg.proc
import pwndbg.prompt
import pwndbg.regs
import pwndbg.stack
import pwndbg.stdio
@ -130,27 +131,3 @@ handle SIGSEGV stop print nopass
for line in pre_commands.strip().splitlines():
gdb.execute(line)
msg = "Loaded %i commands. Type pwndbg [filter] for a list." % len(pwndbg.commands._Command.commands)
print(pwndbg.color.red(msg))
cur = (gdb.selected_inferior(), gdb.selected_thread())
def prompt_hook(*a):
global cur
new = (gdb.selected_inferior(), gdb.selected_thread())
if cur != new:
pwndbg.events.after_reload()
cur = new
if pwndbg.proc.alive:
prompt_hook_on_stop(*a)
@pwndbg.memoize.reset_on_stop
def prompt_hook_on_stop(*a):
with pwndbg.stdio.stdio:
pwndbg.commands.context.context()
gdb.prompt_hook = prompt_hook

@ -41,5 +41,3 @@ def ropper(argument):
io = subprocess.call(cmd)
except Exception:
print("Could not run ropper. Please ensure it's installed and in $PATH.")

@ -19,9 +19,9 @@ module, for example:
"""
from __future__ import unicode_literals
import collections
import sys
import types
import collections
import six

@ -141,12 +141,12 @@ def log_objfiles(ofile=None):
gdb.events.new_objfile.connect(log_objfiles)
def after_reload():
def after_reload(start=True):
if gdb.selected_inferior().pid:
for f in registered[gdb.events.stop]:
f()
for f in registered[gdb.events.start]:
f()
if start: f()
for f in registered[gdb.events.new_objfile]:
f()

@ -0,0 +1,27 @@
import gdb
import pwndbg.events
import pwndbg.memoize
import pwndbg.stdio
msg = "Loaded %i commands. Type pwndbg [filter] for a list." % len(pwndbg.commands._Command.commands)
print(pwndbg.color.red(msg))
cur = (gdb.selected_inferior(), gdb.selected_thread())
def prompt_hook(*a):
global cur
new = (gdb.selected_inferior(), gdb.selected_thread())
if cur != new:
pwndbg.events.after_reload(start=False)
cur = new
if pwndbg.proc.alive:
prompt_hook_on_stop(*a)
@pwndbg.memoize.reset_on_stop
def prompt_hook_on_stop(*a):
with pwndbg.stdio.stdio:
pwndbg.commands.context.context()
gdb.prompt_hook = prompt_hook
Loading…
Cancel
Save