Fixing things back up for Python3

pull/3/head
Zach Riggle 11 years ago
parent 29e20acafc
commit 07159546bd

@ -1,4 +1,7 @@
import __builtin__
try:
from __builtins__ import reload as _reload
except:
from imp import reload as _reload
import imp
import os
import sys
@ -8,7 +11,6 @@ import pwndbg.events
import pwndbg.commands
import pwndbg
_reload = __builtin__.reload
def rreload(module, mdict=None):
"""Recursively reload modules."""
name = module.__name__
@ -25,13 +27,11 @@ def rreload(module, mdict=None):
try:
_reload(module)
except Exception as e:
print e
pass
@pwndbg.commands.Command
def reload(*a):
print "BYTE"
pwndbg.events.on_reload()
rreload(pwndbg)
pwndbg.events.after_reload()

@ -57,8 +57,6 @@ shellcmds = [
"zsh",
]
print "RELOADED"
def register_shell_function(cmd):
def handler(*a):
"""Invokes %s""" % cmd

@ -18,4 +18,4 @@ def start():
gdb.execute('run', from_tty=False, to_string=True)
break
else:
print "Could not find a good place to start :("
print("Could not find a good place to start :(")

@ -1,31 +1,33 @@
# This hook is necessary for compatibility with Python2.7 versions of GDB
# since they cannot directly cast to integer a gdb.Value object that is
# not already an integer type.
import __builtin__
import gdb
import sys
import pwndbg.typeinfo
_int = __builtin__.int
if sys.version_info < (3,0):
import __builtin__ as builtins
_int = builtins.int
# We need this class to get isinstance(7, xint) to return True
class IsAnInt(type):
def __instancecheck__(self, other):
return isinstance(other, _int)
# We need this class to get isinstance(7, xint) to return True
class IsAnInt(type):
def __instancecheck__(self, other):
return isinstance(other, _int)
class xint(__builtin__.int):
__metaclass__ = IsAnInt
def __new__(cls, value, *a, **kw):
if isinstance(value, gdb.Value):
if pwndbg.typeinfo.is_pointer(value):
value = value.cast(pwndbg.typeinfo.ulong)
else:
value = value.cast(pwndbg.typeinfo.long)
return _int(_int(value, *a, **kw))
class xint(builtins.int):
__metaclass__ = IsAnInt
def __new__(cls, value, *a, **kw):
if isinstance(value, gdb.Value):
if pwndbg.typeinfo.is_pointer(value):
value = value.cast(pwndbg.typeinfo.ulong)
else:
value = value.cast(pwndbg.typeinfo.long)
return _int(_int(value, *a, **kw))
__builtin__.int = xint
globals()['int'] = xint
builtins.int = xint
globals()['int'] = xint
# Additionally, we need to compensate for Python2
if 'long' in globals():
__builtin__.long = xint
globals()['long'] = xint
# Additionally, we need to compensate for Python2
if 'long' in globals():
builtins.long = xint
globals()['long'] = xint
Loading…
Cancel
Save