From 35585eb5fc2da9ef25d5305f2165af7fe3ef2e21 Mon Sep 17 00:00:00 2001 From: k4lizen <124312252+k4lizen@users.noreply.github.com> Date: Fri, 12 Dec 2025 02:11:49 +0100 Subject: [PATCH] Minor fixups (#3483) * fix typo * fixups --- pwndbg/aglib/heap/ptmalloc.py | 7 ++----- pwndbg/commands/ptmalloc2.py | 2 ++ tests/library/dbg/tests/test_commands_elf.py | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/pwndbg/aglib/heap/ptmalloc.py b/pwndbg/aglib/heap/ptmalloc.py index ad9dff44d..6cf3bba26 100644 --- a/pwndbg/aglib/heap/ptmalloc.py +++ b/pwndbg/aglib/heap/ptmalloc.py @@ -1271,12 +1271,12 @@ class GlibcMemoryAllocator(pwndbg.aglib.heap.heap.MemoryAllocator, Generic[TheTy # this will break expected output during tests, so we skip it if ( pwndbg.glibc.get_version() >= (2, 42) - and not not hasattr(GlibcMemoryAllocator.tcachebins, "tcache_2_42_warning_issued") + and not hasattr(GlibcMemoryAllocator.tcachebins, "tcache_2_42_warning_issued") and os.environ.get("PWNDBG_IN_TEST") is None ): print( message.warn( - "Changes to tcache in GLIBC 2.42 have not been fully implemented. " + "Support for tcache large bins (a GLIBC 2.42 addition) has not been fully implemented. " "PR contributions are highly appreciated!" ) ) @@ -1632,9 +1632,6 @@ class DebugSymsHeap(GlibcMemoryAllocator[pwndbg.dbg_mod.Type, pwndbg.dbg_mod.Val "tcache", prefer_static=True, ) - if not tcache_ptr: - tcache_ptr = pwndbg.aglib.symbol.lookup_symbol_addr("tcache", prefer_static=True) - if tcache_ptr and (tcache_addr := pwndbg.aglib.memory.read_pointer_width(tcache_ptr)): tcache = tcache_addr elif not self.multithreaded: diff --git a/pwndbg/commands/ptmalloc2.py b/pwndbg/commands/ptmalloc2.py index 9f90a809d..2baedde79 100644 --- a/pwndbg/commands/ptmalloc2.py +++ b/pwndbg/commands/ptmalloc2.py @@ -362,6 +362,7 @@ parser.add_argument("addr", nargs="?", type=int, default=None, help="Address of @pwndbg.commands.Command(parser, category=CommandCategory.PTMALLOC2) @pwndbg.commands.OnlyWithResolvedHeapSyms +@pwndbg.commands.OnlyWhenHeapIsInitialized @pwndbg.commands.OnlyWithTcache @pwndbg.commands.OnlyWhenUserspace def tcache(addr: int | None = None) -> None: @@ -744,6 +745,7 @@ parser.add_argument( @pwndbg.commands.Command(parser, category=CommandCategory.PTMALLOC2) @pwndbg.commands.OnlyWithResolvedHeapSyms +@pwndbg.commands.OnlyWhenHeapIsInitialized @pwndbg.commands.OnlyWithTcache @pwndbg.commands.OnlyWhenUserspace def tcachebins(addr: int | None = None, verbose: bool = False) -> None: diff --git a/tests/library/dbg/tests/test_commands_elf.py b/tests/library/dbg/tests/test_commands_elf.py index 4399e2288..d7b4576d8 100644 --- a/tests/library/dbg/tests/test_commands_elf.py +++ b/tests/library/dbg/tests/test_commands_elf.py @@ -77,7 +77,7 @@ async def test_command_elf(ctrl: Controller, binary_name: str, is_pie: bool) -> pytest.skip("TODO multiarch") out = (await ctrl.execute_and_capture("elf")).splitlines() - # Never versions of gcc emit an additional `.sframe` section. + # Newer versions of gcc emit an additional `.sframe` section. assert len(out) == 25 or len(out) == 26 # test for default