Skip to content

Commit

Permalink
Add cached symbol value lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
fidgetingbits committed May 24, 2024
1 parent 2b9beef commit 5bd9a2c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pwndbg/gdblib/symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,21 @@ def get(address: int | gdb.Value, gdb_only: bool = False) -> str:
return loc_string.replace(" + ", "+")


@pwndbg.lib.cache.cache_until("objfile")
def value(symbol):
"""Get gdb.Value object for given symbol"""

try:
symbol_obj = gdb.lookup_symbol(symbol)[0]
if symbol_obj:
return symbol_obj.value()
else:
return None
except gdb.error as e:
if all(x not in str(e) for x in skipped_exceptions):
raise e


@pwndbg.lib.cache.cache_until("objfile")
def address(symbol: str) -> int | None:
"""
Expand Down

0 comments on commit 5bd9a2c

Please sign in to comment.