From 7d479e1a218aca736adc813984a517ce09d5d03e Mon Sep 17 00:00:00 2001 From: patryk4815 Date: Fri, 14 Feb 2025 03:04:33 +0100 Subject: [PATCH] fix ptmalloc2 commands: arena, tcache (#2729) --- pwndbg/aglib/heap/structs.py | 2 +- pwndbg/commands/ptmalloc2.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pwndbg/aglib/heap/structs.py b/pwndbg/aglib/heap/structs.py index 46a2436a7..0d7a6ad45 100644 --- a/pwndbg/aglib/heap/structs.py +++ b/pwndbg/aglib/heap/structs.py @@ -155,7 +155,7 @@ class CStruct2GDB: def __eq__(self, other: Any) -> bool: return self.address == int(other) - def __str__(self) -> str: + def value_to_human_readable(self) -> str: """ Returns a string representation of the C struct like `pwndbg.dbg_mod.Value` does. """ diff --git a/pwndbg/commands/ptmalloc2.py b/pwndbg/commands/ptmalloc2.py index 27164d142..d5f8594f8 100644 --- a/pwndbg/commands/ptmalloc2.py +++ b/pwndbg/commands/ptmalloc2.py @@ -292,7 +292,7 @@ def arena(addr: int | None = None) -> None: ) ) - print(arena._gdbValue) # Breaks encapsulation, find a better way. + print(arena._gdbValue.value_to_human_readable()) # Breaks encapsulation, find a better way. parser = argparse.ArgumentParser(description="List this process's arenas.") @@ -382,13 +382,13 @@ def tcache(addr: int | None = None) -> None: if tcache: print( message.notice( - f"tcache is pointing to: {message.hint(hex(tcache.address))} for thread {message.hint(tid)}" + f"tcache is pointing to: {message.hint(hex(int(tcache.address)))} for thread {message.hint(tid)}" ) ) else: print_no_tcache_bins_found_error(tid) if tcache: - print(tcache) + print(tcache.value_to_human_readable()) parser = argparse.ArgumentParser(description="Print the mp_ struct's contents.")