From d264a075bea23e2ec08902d6e408a98ad903dd9b Mon Sep 17 00:00:00 2001 From: patryk4815 Date: Wed, 23 Apr 2025 02:23:38 +0200 Subject: [PATCH] gdbinit, lldbinit: detect and prevent double-loading of pwndbg (#2912) * gdbinit, lldbinit: detect and prevent double-loading of pwndbg --- gdbinit.py | 10 ++++++++++ lldbinit.py | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/gdbinit.py b/gdbinit.py index e55b99fe5..c864774e7 100644 --- a/gdbinit.py +++ b/gdbinit.py @@ -162,6 +162,16 @@ def init_logger(): def main() -> None: + if "pwndbg" in sys.modules: + print( + "Detected double-loading of Pwndbg (likely from both .gdbinit and the Pwndbg portable build)." + ) + print( + "To fix this, please remove the line 'source your-path/gdbinit.py' from your .gdbinit file." + ) + sys.stdout.flush() + os._exit(1) + profiler = cProfile.Profile() start_time = None diff --git a/lldbinit.py b/lldbinit.py index 94698511c..f9fcb31fa 100644 --- a/lldbinit.py +++ b/lldbinit.py @@ -125,6 +125,11 @@ def skip_venv(src_root) -> bool: def main(debugger: lldb.SBDebugger, major: int, minor: int, debug: bool = False) -> None: + if "pwndbg" in sys.modules: + print("Detected double-loading of Pwndbg.") + print("This should not happen. Please report this issue if you're not sure how to fix it.") + sys.exit(1) + profiler = cProfile.Profile() start_time = None