From 2d790a6c95c06359acaf9821fac919c5a3f11c18 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Mon, 16 Aug 2021 15:21:46 -0400 Subject: Move py debugger functions to __init__.py --- python/__init__.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'python/__init__.py') diff --git a/python/__init__.py b/python/__init__.py index 54936753..0ed7b47c 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -263,4 +263,26 @@ def open_view(*args, **kwargs): 128 """ - return BinaryViewType.get_view_of_file_with_options(*args, **kwargs) \ No newline at end of file + return BinaryViewType.get_view_of_file_with_options(*args, **kwargs) + + +def connect_pycharm_debugger(port=5678): + # Get pip install string from PyCharm's Python Debug Server Configuration + # e.g. for PyCharm 2021.1.1 #PY-7142.13: + # pip install --user pydevd-pycharm~=211.7142.13 + import pydevd_pycharm + pydevd_pycharm.settrace('localhost', port=port, stdoutToServer=True, stderrToServer=True, suspend=False) + + +def connect_vscode_debugger(port=5678): + # Note: Calling this from startup.py will cause Binary Ninja to hang on startup until VSCode starts debugging + # pip install --user debugpy + import debugpy + import sys + if sys.platform == "win32": + debugpy.configure(python=f"{sys.base_exec_prefix}/python", qt="pyside2") + else: + debugpy.configure(python=f"{sys.base_exec_prefix}/bin/python3", qt="pyside2") + debugpy.listen(("127.0.0.1", port)) + debugpy.wait_for_client() + execute_on_main_thread(lambda: debugpy.debug_this_thread()) -- cgit v1.3.1