Change check style in `{gdblib,aglib}.memory.convert_gdb_value_to_python_value` (#2415)

pull/2419/head
Matt. 1 year ago committed by GitHub
parent d15f6716a6
commit df8a9d4dc6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -8,6 +8,7 @@ import pwndbg.aglib.arch
import pwndbg.aglib.typeinfo
import pwndbg.lib.cache
import pwndbg.lib.memory
from pwndbg.dbg import TypeCode
from pwndbg.lib.memory import PAGE_SIZE
GdbDict = Dict[str, Union["GdbDict", int]]
@ -375,11 +376,9 @@ def pack_struct_into_dictionary(
def convert_pwndbg_value_to_python_value(dbg_value: pwndbg.dbg_mod.Value) -> int | GdbDict:
ty = dbg_value.type.strip_typedefs()
if ty.code == pwndbg.dbg_mod.TypeCode.POINTER:
if ty.code == TypeCode.POINTER or ty.code == TypeCode.INT:
return int(dbg_value)
elif ty.code == pwndbg.dbg_mod.TypeCode.INT:
return int(dbg_value)
elif ty.code == pwndbg.dbg_mod.TypeCode.STRUCT:
elif ty.code == TypeCode.STRUCT:
return pack_struct_into_dictionary(dbg_value)
raise NotImplementedError

@ -432,9 +432,7 @@ def pack_struct_into_dictionary(
def convert_gdb_value_to_python_value(gdb_value: gdb.Value) -> int | GdbDict:
gdb_type = gdb_value.type.strip_typedefs()
if gdb_type.code == gdb.TYPE_CODE_PTR:
return int(gdb_value)
elif gdb_type.code == gdb.TYPE_CODE_INT:
if gdb_type.code == gdb.TYPE_CODE_PTR or gdb_type.code == gdb.TYPE_CODE_INT:
return int(gdb_value)
elif gdb_type.code == gdb.TYPE_CODE_STRUCT:
return pack_struct_into_dictionary(gdb_value)

Loading…
Cancel
Save