Fix up some Python2 regressions

pull/10/head
Zach Riggle 11 years ago
parent 286206d163
commit 99403af8df

@ -33,16 +33,20 @@ def start(*a):
"start", "start",
"_start", "_start",
"init", "init",
"_init", "_init"]
pwndbg.elf.entry()]
for address in filter(bool, map(pwndbg.symbol.address, symbols)): # Try a symbolic breakpoint which GDB will automatically update.
if address: symbols = {s:pwndbg.symbol.address(s) for s in symbols}
b = gdb.Breakpoint('*%#x' % address, temporary=True)
for name, address in symbols.items():
if not address:
continue
b = gdb.Breakpoint(name, temporary=True)
gdb.execute(run, from_tty=False, to_string=True) gdb.execute(run, from_tty=False, to_string=True)
break return
else: # Try a breakpoint at the binary entry
entry(*a) entry(*a)

@ -24,7 +24,7 @@ class memoize(object):
self.caches.append(self) self.caches.append(self)
functools.update_wrapper(self, func) functools.update_wrapper(self, func)
def __call__(self, *args): def __call__(self, *args, **kwargs):
how = None how = None
if not isinstance(args, collections.Hashable): if not isinstance(args, collections.Hashable):
@ -38,7 +38,7 @@ class memoize(object):
else: else:
how = "Executed" how = "Executed"
value = self.func(*args) value = self.func(*args, **kwargs)
self.cache[args] = value self.cache[args] = value
if isinstance(value, list): if isinstance(value, list):

@ -5,12 +5,18 @@ which prevent output from appearing on-screen inside of certain event handlers.
import gdb import gdb
import io import io
import sys import sys
import pwndbg.compat
debug = True debug = True
def get(fd, mode): def get(fd, mode):
file = io.open(1, mode=mode, buffering=0, closefd=False) file = io.open(1, mode=mode, buffering=0, closefd=False)
return io.TextIOWrapper(file, write_through=True)
kw = {}
if pwndbg.compat.python3:
kw['write_through']=True
return io.TextIOWrapper(file, **kw)
if debug: if debug:
sys.stdin = get(0, 'rb') sys.stdin = get(0, 'rb')

@ -17,7 +17,7 @@ import pwndbg.stack
import pwndbg.vmmap import pwndbg.vmmap
@pwndbg.memoize.reset_on_objfile @pwndbg.memoize.reset_on_objfile
def get(address): def get(address, gdb_only=False):
""" """
Retrieve the textual name for a symbol Retrieve the textual name for a symbol
""" """
@ -32,7 +32,7 @@ def get(address):
# This sucks, but there's not a GDB API for this. # This sucks, but there's not a GDB API for this.
result = gdb.execute('info symbol %#x' % int(address), to_string=True, from_tty=False) result = gdb.execute('info symbol %#x' % int(address), to_string=True, from_tty=False)
if result.startswith('No symbol'): if not gdb_only and result.startswith('No symbol'):
address = int(address) address = int(address)
exe = pwndbg.elf.exe() exe = pwndbg.elf.exe()
if exe: if exe:
@ -65,6 +65,7 @@ def address(symbol):
result = gdb.execute('info address %s' % symbol, to_string=True, from_tty=False) result = gdb.execute('info address %s' % symbol, to_string=True, from_tty=False)
result = result.split() result = result.split()
address = next(r for r in result if r.startswith('0x')) address = next(r for r in result if r.startswith('0x'))
address = address.rstrip('.')
return int(address, 0) return int(address, 0)
except gdb.error: except gdb.error:
return None return None

Loading…
Cancel
Save