mirror of https://github.com/pwndbg/pwndbg
Restore GDB 7.7 compatibility
This commit is contained in:
parent
a672dfc6ff
commit
bbd140bfdf
|
@ -218,25 +218,40 @@ arch_to_regs = {
|
||||||
'powerpc': powerpc,
|
'powerpc': powerpc,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@pwndbg.proc.OnlyWhenRunning
|
||||||
|
def gdb77_get_register(name):
|
||||||
|
return gdb.parse_and_eval('$' + name)
|
||||||
|
|
||||||
|
@pwndbg.proc.OnlyWhenRunning
|
||||||
|
def gdb79_get_register(name):
|
||||||
|
return gdb.newest_frame().read_register(name)
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
gdb.Frame.read_register
|
||||||
|
get_register = gdb79_get_register
|
||||||
|
except AttributeError:
|
||||||
|
get_register = gdb77_get_register
|
||||||
|
|
||||||
|
|
||||||
class module(ModuleType):
|
class module(ModuleType):
|
||||||
last = {}
|
last = {}
|
||||||
|
|
||||||
@pwndbg.memoize.reset_on_stop
|
@pwndbg.memoize.reset_on_stop
|
||||||
def __getattr__(self, attr):
|
def __getattr__(self, attr):
|
||||||
|
attr = attr.lstrip('$')
|
||||||
try:
|
try:
|
||||||
# Seriously, gdb? Only accepts uint32.
|
# Seriously, gdb? Only accepts uint32.
|
||||||
if 'eflags' in attr:
|
if 'eflags' in attr:
|
||||||
value = gdb.parse_and_eval('$' + attr.lstrip('$'))
|
value = gdb77_get_register(attr)
|
||||||
value = value.cast(pwndbg.typeinfo.uint32)
|
value = value.cast(pwndbg.typeinfo.uint32)
|
||||||
else:
|
else:
|
||||||
value = gdb.newest_frame().read_register(attr)
|
value = get_register(attr)
|
||||||
value = value.cast(pwndbg.typeinfo.ptrdiff)
|
value = value.cast(pwndbg.typeinfo.ptrdiff)
|
||||||
|
|
||||||
value = int(value)
|
value = int(value)
|
||||||
return value & pwndbg.arch.ptrmask
|
return value & pwndbg.arch.ptrmask
|
||||||
except ValueError:
|
except (ValueError, gdb.error):
|
||||||
# Unknown register
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@pwndbg.memoize.reset_on_stop
|
@pwndbg.memoize.reset_on_stop
|
||||||
|
|
Loading…
Reference in New Issue