From d61ebba69ee8434fc8b25365a6bc41da03344d93 Mon Sep 17 00:00:00 2001 From: Zach Riggle Date: Sun, 17 May 2015 05:18:17 -0700 Subject: [PATCH] Docs and slightly better performance --- pwndbg/commands/next.py | 11 +++++++++-- pwndbg/disasm/arch.py | 6 +++++- pwndbg/next.py | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/pwndbg/commands/next.py b/pwndbg/commands/next.py index abc6e353c..32f8a93c7 100644 --- a/pwndbg/commands/next.py +++ b/pwndbg/commands/next.py @@ -10,25 +10,32 @@ import pwndbg.next @pwndbg.commands.Command @pwndbg.commands.OnlyWhenRunning def nextjmp(*args): - pwndbg.next.break_next_branch() + """Breaks at the next jump instruction""" + if pwndbg.next.break_next_branch(): + pwndbg.commands.context.context() @pwndbg.commands.Command @pwndbg.commands.OnlyWhenRunning def nextj(*args): + """Breaks at the next jump instruction""" nextjmp(*args) @pwndbg.commands.Command @pwndbg.commands.OnlyWhenRunning def nextjump(*args): + """Breaks at the next jump instruction""" nextjmp(*args) @pwndbg.commands.Command @pwndbg.commands.OnlyWhenRunning def nextcall(*args): - pwndbg.next.break_next_call() + """Breaks at the next call instruction""" + if pwndbg.next.break_next_call(): + pwndbg.commands.context.context() @pwndbg.commands.Command @pwndbg.commands.OnlyWhenRunning def nextc(*args): + """Breaks at the next call instruction""" nextcall(*args) diff --git a/pwndbg/disasm/arch.py b/pwndbg/disasm/arch.py index b884ebba5..cd2afd40d 100644 --- a/pwndbg/disasm/arch.py +++ b/pwndbg/disasm/arch.py @@ -4,6 +4,8 @@ import capstone import collections from capstone import * +debug = False + groups = {v:k for k,v in globals().items() if k.startswith('CS_GRP_')} ops = {v:k for k,v in globals().items() if k.startswith('CS_OP_')} access = {v:k for k,v in globals().items() if k.startswith('CS_AC_')} @@ -40,7 +42,9 @@ class DisassemblyAssistant(object): enhancer.enhance_symbol(instruction) enhancer.enhance_conditional(instruction) enhancer.enhance_next(instruction) - print(enhancer.dump(instruction)) + + if debug: + print(enhancer.dump(instruction)) def enhance_conditional(self, instruction): """ diff --git a/pwndbg/next.py b/pwndbg/next.py index 390d1a241..97271eb72 100644 --- a/pwndbg/next.py +++ b/pwndbg/next.py @@ -36,7 +36,7 @@ def break_next_branch(address=None): ins = next_branch(address) if ins: - gdb.Breakpoint("*%#x" % ins.address, temporary=True) + gdb.Breakpoint("*%#x" % ins.address, internal=True, temporary=True) gdb.execute('continue') return ins