Add test for setflags command (#2056)

pull/2057/head
Gulshan Singh 2 years ago committed by GitHub
parent 8a09a89c34
commit 5be38a5bf3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,33 @@
from __future__ import annotations
import gdb
import pwndbg.gdblib.regs
import tests
REFERENCE_BINARY = tests.binaries.get("reference-binary.out")
def test_flags_command(start_binary):
start_binary(REFERENCE_BINARY)
old_eflags = pwndbg.gdblib.regs.eflags
# Verify CF is not set
assert old_eflags & 0x1 == 0
gdb.execute("setflag cf 1")
# Verify CF is set and no other flags have changed
assert (old_eflags | 1) == pwndbg.gdblib.regs.eflags
gdb.execute("setflag cf 0")
# Verify CF is not set and no other flags have changed
assert old_eflags == pwndbg.gdblib.regs.eflags
# Test setting an invalid value
gdb.execute("setflag cf 2")
# Verify no flags have changed
assert old_eflags == pwndbg.gdblib.regs.eflags
Loading…
Cancel
Save