From 04c06fa450e42b1740b1cc73ef645d1f2b7b2632 Mon Sep 17 00:00:00 2001 From: k4lizen <124312252+k4lizen@users.noreply.github.com> Date: Sat, 29 Nov 2025 00:46:49 +0100 Subject: [PATCH] Make mallocng test more consistent (#3444) * add disable_debuginfod endpoint * note --- tests/host/__init__.py | 9 +++++++++ tests/host/gdb/pytests_launcher.py | 4 ++++ tests/host/lldb/launch_guest.py | 4 ++++ tests/library/dbg/tests/test_mallocng.py | 3 +++ 4 files changed, 20 insertions(+) diff --git a/tests/host/__init__.py b/tests/host/__init__.py index 954e9b650..df4570535 100644 --- a/tests/host/__init__.py +++ b/tests/host/__init__.py @@ -203,6 +203,15 @@ class Controller: """ raise NotImplementedError() + def disable_debuginfod(self) -> Awaitable[None]: + """ + Tells the debugger not to use debuginfod (for retrieving + debugging information / symbols). + + This should be called before .launch(). + """ + raise NotImplementedError() + def start(controller: Callable[[Controller], Coroutine[Any, Any, None]]) -> None: """ diff --git a/tests/host/gdb/pytests_launcher.py b/tests/host/gdb/pytests_launcher.py index 4903b5313..a5ebdcc9b 100644 --- a/tests/host/gdb/pytests_launcher.py +++ b/tests/host/gdb/pytests_launcher.py @@ -59,6 +59,10 @@ class _GDBController(host.Controller): async def select_thread(self, tid: int) -> None: gdb.execute(f"thread {tid}") + async def disable_debuginfod(self) -> None: + gdb.execute("set debug-file-directory") + gdb.execute("set debuginfod enabled off") + def _start(outer: Callable[[host.Controller], Coroutine[Any, Any, None]]) -> None: # The GDB controller is entirely synchronous, so keep advancing the diff --git a/tests/host/lldb/launch_guest.py b/tests/host/lldb/launch_guest.py index 78bf9761f..b7b3740c7 100644 --- a/tests/host/lldb/launch_guest.py +++ b/tests/host/lldb/launch_guest.py @@ -58,6 +58,10 @@ async def _run(ctrl: Any, outer: Callable[..., Coroutine[Any, Any, None]]) -> No async def select_thread(self, tid: int) -> None: await self.pc.execute(f"thread select {tid}") + async def disable_debuginfod(self) -> None: + # Could also consider disabling `symbols.enable-external-lookup` + await self.pc.execute("settings set plugin.symbol-locator.debuginfod.server-urls {}") + await outer(_LLDBController(ctrl)) diff --git a/tests/library/dbg/tests/test_mallocng.py b/tests/library/dbg/tests/test_mallocng.py index c48d01b69..b121a480e 100644 --- a/tests/library/dbg/tests/test_mallocng.py +++ b/tests/library/dbg/tests/test_mallocng.py @@ -299,6 +299,9 @@ async def test_mallocng_meta(ctrl: Controller, binary: str): async def test_mallocng_malloc_context(ctrl: Controller, binary: str): import pwndbg.color as color + # Make sure we are not working with symbols when we think we aren't + await ctrl.disable_debuginfod() + await ctrl.launch(binary) # Check that we do not find it at the first program instruction