From b9b7000d2f296314c5ede6514b6a489d1f7102a5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 23 Sep 2025 09:02:25 +0000 Subject: [PATCH 1/2] Initial plan From c7016d385a0fdf763d9d0829f8236f287583c2b8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 23 Sep 2025 09:09:37 +0000 Subject: [PATCH 2/2] Implement dbg magic variable registration for Python scripting Co-authored-by: xusheng6 <94503187+xusheng6@users.noreply.github.com> --- api/python/debuggercontroller.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/api/python/debuggercontroller.py b/api/python/debuggercontroller.py index 47570178..767ea2c4 100644 --- a/api/python/debuggercontroller.py +++ b/api/python/debuggercontroller.py @@ -1652,3 +1652,15 @@ def __ne__(self, other): def __hash__(self): return hash(ctypes.addressof(self.handle.contents)) + + +def _get_debugger(instance: binaryninja.PythonScriptingInstance): + if instance.interpreter.active_view is None: + return None + return DebuggerController(instance.interpreter.active_view) + + +binaryninja.PythonScriptingProvider.register_magic_variable( + "dbg", + _get_debugger +)