Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stepsyscall and rename next_syscall to nextsyscall #447

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 31 additions & 5 deletions pwndbg/commands/next.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from __future__ import print_function
from __future__ import unicode_literals

import gdb

import pwndbg.commands
import pwndbg.next

Expand Down Expand Up @@ -66,19 +68,43 @@ def so(*args):

@pwndbg.commands.Command
@pwndbg.commands.OnlyWhenRunning
def next_syscall(*args):
def nextsyscall(*args):
"""
Breaks at the next syscall.
Breaks at the next syscall not taking branches.
"""
while pwndbg.proc.alive and not pwndbg.next.break_next_interrupt() and pwndbg.next.break_next_branch():
continue
pwndbg.commands.context.context()

if pwndbg.proc.alive:
pwndbg.commands.context.context()


@pwndbg.commands.Command
@pwndbg.commands.OnlyWhenRunning
def nextsc(*args):
"""
Breaks at the next syscall.
Breaks at the next syscall not taking branches.
"""
nextsyscall(*args)


@pwndbg.commands.Command
@pwndbg.commands.OnlyWhenRunning
def stepsyscall(*args):
"""
Breaks at the next syscall by taking branches.
"""
next_syscall(*args)
while pwndbg.proc.alive and not pwndbg.next.break_next_interrupt() and pwndbg.next.break_next_branch():
# Here we are e.g. on a CALL instruction (temporarily breakpointed by `break_next_branch`)
# We need to step so that we take this branch instead of ignoring it
gdb.execute('si')
continue

if pwndbg.proc.alive:
pwndbg.commands.context.context()


@pwndbg.commands.Command
@pwndbg.commands.OnlyWhenRunning
def stepsc(*args):
stepsyscall(*args)