Skip to content

Commit a8b14a6

Browse files
committed
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.
1 parent 2d861a3 commit a8b14a6

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

dap-python.el

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,9 @@ overriden in individual `dap-python' launch configurations."
194194
(plist-get conf :program)
195195
(buffer-file-name)))
196196
(module (plist-get conf :module))
197-
(debugger (plist-get conf :debugger)))
197+
(debugger (plist-get conf :debugger))
198+
(justmycode (plist-get conf :justMyCode))
199+
(debug-options (plist-get conf :debugOptions)))
198200
(cl-remf conf :debugger)
199201
(pcase (or debugger dap-python-debugger)
200202
('ptvsd
@@ -216,7 +218,12 @@ overriden in individual `dap-python' launch configurations."
216218
(plist-put conf :debugServer debug-port)
217219
(plist-put conf :port debug-port)
218220
(plist-put conf :hostName host)
219-
(plist-put conf :host host)))
221+
(plist-put conf :host host)
222+
(when (and (not (null justmycode))
223+
(equal justmycode :json-false))
224+
(setq debug-options (cl-pushnew "DebugStdLib" debug-options :test #'equal))
225+
(plist-put conf :debugOptions debug-options)
226+
(cl-remf conf :justMyCode))))
220227
('debugpy
221228
;; If certain properties are nil, issues will arise, as debugpy expects
222229
;; them to unspecified instead. Some templates in this file set such
@@ -238,7 +245,12 @@ overriden in individual `dap-python' launch configurations."
238245
(cl-remf conf :module))
239246
(unless (plist-get conf :cwd)
240247
(cl-remf conf :cwd))
241-
248+
(when (and debug-options
249+
(sequencep debug-options)
250+
(seq-contains debug-options "DebugStdLib")
251+
(null justmycode))
252+
(warn "DebugStdLib is deprecated, use justMyCode, please consider to update your configuration.")
253+
(plist-put conf :justMyCode :json-false))
242254
(plist-put conf :dap-server-path
243255
(list python-executable "-m" "debugpy.adapter"))))
244256
(plist-put conf :program program)

docs/page/configuration.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,9 @@ settings.
9595
9696
A template named "Python :: Run Configuration" will appear, which
9797
will execute the currently visited module. This will fall short
98-
whenever you need to specify arguments, environment variables or
99-
execute a setuptools based script. In such case, define a template:
98+
whenever you need to specify arguments, environment variables,
99+
enable debugging of 3rd modules or execute a setuptools based script.
100+
In such case, define a template:
100101
101102
``` elisp
102103
(dap-register-debug-template "My App"
@@ -105,6 +106,7 @@ settings.
105106
:cwd nil
106107
:env '(("DEBUG" . "1"))
107108
:target-module (expand-file-name "~/src/myapp/.env/bin/myapp")
109+
:justMyCode :json-false
108110
:request "launch"
109111
:name "My App"))
110112
```

0 commit comments

Comments
 (0)