Better error messages for nearpc

pull/162/head
Zach Riggle 9 years ago
parent 494e7ae13c
commit a109632530

@ -41,6 +41,8 @@ def nearpc(pc=None, lines=None, to_string=False, emulate=False):
""" """
Disassemble near a specified address. Disassemble near a specified address.
""" """
result = []
# Fix the case where we only have one argument, and # Fix the case where we only have one argument, and
# it's a small value. # it's a small value.
if lines is None and (pc is None or int(pc) < 0x100): if lines is None and (pc is None or int(pc) < 0x100):
@ -58,7 +60,7 @@ def nearpc(pc=None, lines=None, to_string=False, emulate=False):
# Check whether we can even read this address # Check whether we can even read this address
if not pwndbg.memory.peek(pc): if not pwndbg.memory.peek(pc):
return [pwndbg.color.red('Invalid address %#x' % pc)] result.append(pwndbg.color.red('Invalid address %#x' % pc))
# # Load source data if it's available # # Load source data if it's available
# pc_to_linenos = collections.defaultdict(lambda: []) # pc_to_linenos = collections.defaultdict(lambda: [])
@ -75,9 +77,11 @@ def nearpc(pc=None, lines=None, to_string=False, emulate=False):
# for line in symtab.linetable(): # for line in symtab.linetable():
# pc_to_linenos[line.pc].append(line.line) # pc_to_linenos[line.pc].append(line.line)
result = []
instructions = pwndbg.disasm.near(pc, lines, emulate=emulate) instructions = pwndbg.disasm.near(pc, lines, emulate=emulate)
if pwndbg.memory.peek(pc) and not instructions:
result.append(pwndbg.color.red('Invalid instructions at %#x' % pc))
# In case $pc is in a new map we don't know about, # In case $pc is in a new map we don't know about,
# this will trigger an exploratory search. # this will trigger an exploratory search.
pwndbg.vmmap.find(pc) pwndbg.vmmap.find(pc)

Loading…
Cancel
Save