{"id":9959,"library":"mozdebug","title":"Mozdebug Library","description":"Mozdebug provides utilities for running applications under native code debuggers, primarily intended for use within Mozilla testing workflows. It offers a Python client to interact with Mozilla's custom debug protocol. The current version is 0.4.0. Its release cadence appears infrequent, typically tied to specific Mozilla project requirements.","status":"active","version":"0.4.0","language":"en","source_language":"en","source_url":"https://github.com/mozilla/mozdebug","tags":["debugging","mozilla","protocol","native","rr"],"install":[{"cmd":"pip install mozdebug","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"MozDebugClient","correct":"from mozdebug.client import MozDebugClient"},{"symbol":"SymbolFetcher","correct":"from mozdebug.symbols import SymbolFetcher"}],"quickstart":{"code":"import os\nfrom mozdebug.client import MozDebugClient\n\n# In a real scenario, you would launch a debug server (e.g., rr, gdbserver)\n# and configure it to listen on a host/port, then connect to it.\n# This example just demonstrates the client instantiation and connection attempt.\n# A ConnectionRefusedError is expected if no server is running at the specified address.\n\ntry:\n    # Attempt to connect to a debug server.\n    # Replace 'localhost' and 9000 with your server's actual host and port.\n    client = MozDebugClient(host=os.environ.get('DEBUG_SERVER_HOST', 'localhost'),\n                           port=int(os.environ.get('DEBUG_SERVER_PORT', 9000)))\n    print(f\"Attempting to connect to {client.host}:{client.port}...\")\n    client.connect()\n    print(\"Successfully connected to debug server.\")\n\n    # In a real application, you would now interact with the debug client, e.g.,\n    # client.attach_to_process(pid), client.continue_execution(), client.get_stack().\n\n    # Example: Disconnect\n    client.disconnect()\n    print(\"Disconnected.\")\n\nexcept ConnectionRefusedError:\n    print(\"Could not connect to the debug server. Ensure a debug server (e.g., rr, gdbserver) is running and listening on the specified host/port.\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")\n","lang":"python","description":"This quickstart demonstrates how to instantiate and attempt to connect a `MozDebugClient` to a running debug server. It includes basic error handling for a `ConnectionRefusedError`, which is common if no server is active. Ensure a debug server compatible with Mozilla's protocol is running at the specified host and port for a successful connection."},"warnings":[{"fix":"Launch your debug server process manually before attempting to connect with `MozDebugClient`.","message":"The `mozdebug` library is a client-side tool; it does not launch or manage the debuggee process or the debugger itself. You must ensure a compatible debug server (e.g., `rr`, `gdbserver` with specific configurations) is already running and listening on the target host/port before the `MozDebugClient` can connect.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Verify that your debug server or target application is configured to expose the Mozilla debugging protocol, or use a tool specifically designed to interoperate with `mozdebug`.","message":"Mozdebug implements Mozilla's custom debugging protocol, which is distinct from standard GDB or LLDB remote protocols. It may not be compatible with generic debug servers without specific bridging or shim layers designed for this protocol.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Ensure a debug server (e.g., `rr replay -s 9000` or `gdbserver host:port program`) is active and listening on the target host/port before running your `mozdebug` client script. Check firewall rules if the server is remote.","cause":"The `MozDebugClient` failed to connect because no debug server was running or listening at the specified host and port, or a firewall blocked the connection.","error":"ConnectionRefusedError: [Errno 111] Connection refused"},{"fix":"Install the library using `pip install mozdebug`. If using a virtual environment, ensure it is activated before installation and execution.","cause":"The `mozdebug` library is not installed in the active Python environment, or the script is being run with a different Python interpreter than where it was installed.","error":"ModuleNotFoundError: No module named 'mozdebug'"},{"fix":"Consult the official `mozdebug` source code on GitHub or any available documentation for the correct API methods and their signatures for your installed version (0.4.0).","cause":"Attempting to call a method or access an attribute that does not exist on the `MozDebugClient` instance, or has been renamed in the installed version.","error":"AttributeError: 'MozDebugClient' object has no attribute 'some_nonexistent_method'"}]}