diff --git a/pwndbg/commands/next.py b/pwndbg/commands/next.py index 337466360..a3f29af9b 100644 --- a/pwndbg/commands/next.py +++ b/pwndbg/commands/next.py @@ -31,7 +31,7 @@ def nextjump(*args): @pwndbg.commands.OnlyWhenRunning def nextcall(*args): """Breaks at the next call instruction""" - if pwndbg.next.break_next_call(): + if pwndbg.next.break_next_call(*args): pwndbg.commands.context.context() @pwndbg.commands.Command diff --git a/pwndbg/next.py b/pwndbg/next.py index 47a420b80..35f85dd22 100644 --- a/pwndbg/next.py +++ b/pwndbg/next.py @@ -9,6 +9,8 @@ from __future__ import division from __future__ import print_function from __future__ import unicode_literals +import re + import capstone import gdb @@ -78,14 +80,27 @@ def break_next_interrupt(address=None): gdb.execute('continue', from_tty=False, to_string=True) return ins -def break_next_call(address=None): +def break_next_call(symbol_regex=None): while pwndbg.proc.alive: - ins = break_next_branch(address) + ins = break_next_branch() if not ins: break - if capstone.CS_GRP_CALL in ins.groups: + # continue if not a call + if capstone.CS_GRP_CALL not in ins.groups: + continue + + # return call if we don't search for a symbol + if not symbol_regex: + return ins + + # return call if we match target address + if ins.target_const and re.match('%s$' % symbol_regex, hex(ins.target)): + return ins + + # return call if we match symbol name + if ins.symbol and re.match('%s$' % symbol_regex, ins.symbol): return ins def break_on_next(address=None):