import gdb import gef.memoize @gef.memoize.reset_on_objfile def get(address): """ Retrieve the textual name for a symbol """ # 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 ''