From a8b14a643a4264ee249747cf6de08c435cb50989 Mon Sep 17 00:00:00 2001 From: Tai Dinh Date: Tue, 13 Oct 2020 23:30:02 +0200 Subject: [PATCH] dap-python: support debugging of 3rd modules - Add configuration handling to support step into 3rd modules. - justMyCode is the single configuration needed to be specified regardless the selected back end debugger. - DebugStdLib is also supported for backward compatibility, and a warning message will be printed suggesting for a migration if debugpy is selected as the debugger. --- dap-python.el | 18 +++++++++++++++--- docs/page/configuration.md | 6 ++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/dap-python.el b/dap-python.el index 5be2838a..e9749de4 100644 --- a/dap-python.el +++ b/dap-python.el @@ -194,7 +194,9 @@ overriden in individual `dap-python' launch configurations." (plist-get conf :program) (buffer-file-name))) (module (plist-get conf :module)) - (debugger (plist-get conf :debugger))) + (debugger (plist-get conf :debugger)) + (justmycode (plist-get conf :justMyCode)) + (debug-options (plist-get conf :debugOptions))) (cl-remf conf :debugger) (pcase (or debugger dap-python-debugger) ('ptvsd @@ -216,7 +218,12 @@ overriden in individual `dap-python' launch configurations." (plist-put conf :debugServer debug-port) (plist-put conf :port debug-port) (plist-put conf :hostName host) - (plist-put conf :host host))) + (plist-put conf :host host) + (when (and (not (null justmycode)) + (equal justmycode :json-false)) + (setq debug-options (cl-pushnew "DebugStdLib" debug-options :test #'equal)) + (plist-put conf :debugOptions debug-options) + (cl-remf conf :justMyCode)))) ('debugpy ;; If certain properties are nil, issues will arise, as debugpy expects ;; them to unspecified instead. Some templates in this file set such @@ -238,7 +245,12 @@ overriden in individual `dap-python' launch configurations." (cl-remf conf :module)) (unless (plist-get conf :cwd) (cl-remf conf :cwd)) - + (when (and debug-options + (sequencep debug-options) + (seq-contains debug-options "DebugStdLib") + (null justmycode)) + (warn "DebugStdLib is deprecated, use justMyCode, please consider to update your configuration.") + (plist-put conf :justMyCode :json-false)) (plist-put conf :dap-server-path (list python-executable "-m" "debugpy.adapter")))) (plist-put conf :program program) diff --git a/docs/page/configuration.md b/docs/page/configuration.md index 09113ad1..f85eea65 100644 --- a/docs/page/configuration.md +++ b/docs/page/configuration.md @@ -95,8 +95,9 @@ settings. A template named "Python :: Run Configuration" will appear, which will execute the currently visited module. This will fall short - whenever you need to specify arguments, environment variables or - execute a setuptools based script. In such case, define a template: + whenever you need to specify arguments, environment variables, + enable debugging of 3rd modules or execute a setuptools based script. + In such case, define a template: ``` elisp (dap-register-debug-template "My App" @@ -105,6 +106,7 @@ settings. :cwd nil :env '(("DEBUG" . "1")) :target-module (expand-file-name "~/src/myapp/.env/bin/myapp") + :justMyCode :json-false :request "launch" :name "My App")) ```