mirror of https://github.com/pwndbg/pwndbg
Fix up some Python2 regressions
This commit is contained in:
parent
286206d163
commit
99403af8df
|
@ -33,17 +33,21 @@ def start(*a):
|
|||
"start",
|
||||
"_start",
|
||||
"init",
|
||||
"_init",
|
||||
pwndbg.elf.entry()]
|
||||
"_init"]
|
||||
|
||||
for address in filter(bool, map(pwndbg.symbol.address, symbols)):
|
||||
if address:
|
||||
b = gdb.Breakpoint('*%#x' % address, temporary=True)
|
||||
gdb.execute(run, from_tty=False, to_string=True)
|
||||
break
|
||||
# Try a symbolic breakpoint which GDB will automatically update.
|
||||
symbols = {s:pwndbg.symbol.address(s) for s in symbols}
|
||||
|
||||
else:
|
||||
entry(*a)
|
||||
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)
|
||||
return
|
||||
|
||||
# Try a breakpoint at the binary entry
|
||||
entry(*a)
|
||||
|
||||
|
||||
@pwndbg.commands.Command
|
||||
|
|
|
@ -24,7 +24,7 @@ class memoize(object):
|
|||
self.caches.append(self)
|
||||
functools.update_wrapper(self, func)
|
||||
|
||||
def __call__(self, *args):
|
||||
def __call__(self, *args, **kwargs):
|
||||
how = None
|
||||
|
||||
if not isinstance(args, collections.Hashable):
|
||||
|
@ -38,7 +38,7 @@ class memoize(object):
|
|||
|
||||
else:
|
||||
how = "Executed"
|
||||
value = self.func(*args)
|
||||
value = self.func(*args, **kwargs)
|
||||
self.cache[args] = value
|
||||
|
||||
if isinstance(value, list):
|
||||
|
|
|
@ -5,12 +5,18 @@ which prevent output from appearing on-screen inside of certain event handlers.
|
|||
import gdb
|
||||
import io
|
||||
import sys
|
||||
import pwndbg.compat
|
||||
|
||||
debug = True
|
||||
|
||||
def get(fd, mode):
|
||||
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:
|
||||
sys.stdin = get(0, 'rb')
|
||||
|
|
|
@ -17,7 +17,7 @@ import pwndbg.stack
|
|||
import pwndbg.vmmap
|
||||
|
||||
@pwndbg.memoize.reset_on_objfile
|
||||
def get(address):
|
||||
def get(address, gdb_only=False):
|
||||
"""
|
||||
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.
|
||||
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)
|
||||
exe = pwndbg.elf.exe()
|
||||
if exe:
|
||||
|
@ -65,6 +65,7 @@ def address(symbol):
|
|||
result = gdb.execute('info address %s' % symbol, to_string=True, from_tty=False)
|
||||
result = result.split()
|
||||
address = next(r for r in result if r.startswith('0x'))
|
||||
address = address.rstrip('.')
|
||||
return int(address, 0)
|
||||
except gdb.error:
|
||||
return None
|
||||
|
|
Loading…
Reference in New Issue