mirror of https://github.com/pwndbg/pwndbg.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
744 B
Python
27 lines
744 B
Python
import gdb
|
|
import gef.memoize
|
|
import gef.memory
|
|
@gef.memoize.reset_on_objfile
|
|
def get(address):
|
|
"""
|
|
Retrieve the textual name for a symbol
|
|
"""
|
|
# Fast path
|
|
if address < gef.memory.MMAP_MIN_ADDR:
|
|
return ''
|
|
|
|
# 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)
|
|
|
|
# Expected format looks like this:
|
|
# main in section .text of /bin/bash
|
|
# main + 3 in section .text of /bin/bash
|
|
# system + 1 in section .text of /lib/x86_64-linux-gnu/libc.so.6
|
|
# No symbol matches system-1.
|
|
a, b, c, _ = result.split(None, 3)
|
|
|
|
if b == '+':
|
|
return "%s+%s" % (a, c)
|
|
if b == 'in':
|
|
return a
|
|
return '' |