mirror of https://github.com/pwndbg/pwndbg.git
Fix stepsyscall + add a test (#2884)
parent
df0e55ce40
commit
2ae0144759
@ -0,0 +1,33 @@
|
||||
section .text
|
||||
global _start
|
||||
|
||||
|
||||
write:
|
||||
mov rax, 1
|
||||
mov rdi, 1
|
||||
mov rsi, msg
|
||||
mov rdx, len
|
||||
syscall_write_label:
|
||||
syscall
|
||||
ret
|
||||
|
||||
_start:
|
||||
nop
|
||||
jmp label1
|
||||
nop
|
||||
|
||||
label1:
|
||||
call write
|
||||
|
||||
exit:
|
||||
mov rax, 60
|
||||
mov rdi, 0
|
||||
|
||||
syscall_exit_label:
|
||||
syscall
|
||||
|
||||
|
||||
|
||||
section .data
|
||||
msg db 'hello world', 0xA
|
||||
len equ $ - msg
|
||||
@ -0,0 +1,29 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import gdb
|
||||
|
||||
import pwndbg.aglib.regs
|
||||
import tests
|
||||
|
||||
STEPSYSCALL_X64_BINARY = tests.binaries.get("stepsyscall_x64.out")
|
||||
|
||||
|
||||
def test_command_stepsyscall(start_binary):
|
||||
start_binary(STEPSYSCALL_X64_BINARY)
|
||||
|
||||
# Test that the logic correctly handles multiple consecutive jumps
|
||||
gdb.execute("stepsyscall")
|
||||
address = int(gdb.parse_and_eval("&syscall_write_label"))
|
||||
assert pwndbg.aglib.regs.pc == address
|
||||
|
||||
gdb.execute("stepsyscall")
|
||||
address = int(gdb.parse_and_eval("&syscall_exit_label"))
|
||||
assert pwndbg.aglib.regs.pc == address
|
||||
|
||||
|
||||
def test_command_nextsyscall(start_binary):
|
||||
start_binary(STEPSYSCALL_X64_BINARY)
|
||||
|
||||
gdb.execute("nextsyscall")
|
||||
address = int(gdb.parse_and_eval("&syscall_exit_label"))
|
||||
assert pwndbg.aglib.regs.pc == address
|
||||
Loading…
Reference in new issue