emacs-lsp / dap-mode

Emacs :heart: Debug Adapter Protocol
https://emacs-lsp.github.io/dap-mode
GNU General Public License v3.0
1.3k stars 182 forks source link

Feature request: support docker #406

Open ztlevi opened 3 years ago

ztlevi commented 3 years ago

Hi,

I'm trying to use the vscode's docker debug config to run the app.

My basic vscode debug template is over here. Everything is pretty much learned from here.

I'm able to use vscode to set breakpoint in app.py and run "Docker: Python - General" to debug it. But for emacs, it pops the following error.

user-error: Have you loaded the ‘docker’ specific dap package?

It turns out dap-mode couldn't handle docker on the fly. Maybe there is a missing feature for dap? Any idea?

Thanks!

nbfalcon commented 3 years ago

We don't support docker the same way VSCode does, so "type": "docker" is invalid (this is a missing feature of dap-mode).

ztlevi commented 3 years ago

Got it. Thanks. I'll change this to feature request.

nbfalcon commented 3 years ago

Roadmap:

nbfalcon commented 3 years ago

However, note that dap-mode might still suffice for your use-case: debugpy supports attach requests. If you can start a debugpy server from within your docker application and if you can expose the required ports, you could use an attach configuration (as in VSCode). To do this, you'll need to enable debugpy for dap-mode:

(setq dap-python-debugger 'debugpy)
ztlevi commented 3 years ago

@nbfalcon Thanks.

I am able to get vscode debugpy working using this setup.

But when I use the same launch config in emacs and set the dap-python-debugger to debugpy, it pops No message handler for debugpyWaitingForServer error and the debug session is killed.

Do you know how to make it working?

nbfalcon commented 3 years ago

The message is strange, given that we have a message handler for debugpyWaitingForServer (no typo?) in dap-python. Try the following launch configuration (one item in "configurations": ...):

{
    "name": "Debug",
    "type": "python",
    "port": 5768,
    "host": "localhost",
    "request": "attach"
}
ztlevi commented 3 years ago

@nbfalcon Same error. I need to use --wait-for-client to attach to it BTW.

ztlevi commented 3 years ago

You can easily reproduce this by clone this repo.

nbfalcon commented 3 years ago

@ztlevi you have dap-python-debugger as debugpy in your current session, right? The no handler for... is just a message, not an error.

ztlevi commented 3 years ago

@nbfalcon Right. But the session just end without attaching...

I got this message eventually.

Warning (emacs): Initialize request failed: Timed out waiting for debug server to connect.
nbfalcon commented 3 years ago

Remote debugging indeed doesn't work for python. I'll need to investigate...

ztlevi commented 3 years ago

Got it. Thanks!

mcuckson commented 3 years ago

This would be a super useful feature for working with Azure Functions. I'll watch this thread closely and would be happy to help out with any testing/documentation, etc.