Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugger implementation #13433

Draft
wants to merge 343 commits into
base: main
Choose a base branch
from
Draft

Conversation

RemcoSmitsDev
Copy link
Contributor

@RemcoSmitsDev RemcoSmitsDev commented Jun 23, 2024

Closes #5307
Closes #5065

The current state of the debugger implementation:

Screen.Recording.2024-08-12.at.22.25.49.mov
Screen.Recording.2024-10-03.at.22.34.34.mov

All the todo's are in the following channel, so it's easier to work on this together:
https://zed.dev/channel/zed-debugger-11370

If you are on Linux, and you want to join the debugger channel, you can message me on discord and I will invite you.
https://discord.com/channels/869392257814519848/1255246362220691456

Current Features

  • Breakpoints
    • Log breakpoints
    • line breakpoints
    • Persistent between zed sessions (configurable)
    • Multi buffer support
  • Stack frames
    • Click on stack frame
      • View variables that belong to the stack frame
      • Visit the source file
  • Loaded Sources
    • View all used loaded sources if supported by adapter.
  • Modules
    • View all used modules if supported by adapter.
  • Variables
    • Copy value
    • Copy name
    • Copy memory reference
    • Set value (if adapter supports this)
  • Debug Console
    • See logs
    • Evaluate code
      • Updates the variable list
      • Auto completion
        • If not supported by adapter, we will show auto-completion for existing variables
  • Debug Output
    • View output that was sent from debug adapter
  • Controls
    • Continue
    • Step into
      • Stepping granularity (configurable)
    • Step over
      • Stepping granularity (configurable)
    • Step out
      • Stepping granularity (configurable)
    • Disconnect
    • Restart
    • Stop
  • Warning when a debug session exited without hitting any breakpoint

Release Notes:

  • Added debugger implementation.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jun 23, 2024
@davidbuzz
Copy link
Contributor

Add documententation and/or an example on how to configure and/enable this for a specific debugger... if not as part of this PR then to the todo list ?

@osiewicz
Copy link
Contributor

Change client id to be language id because you should only run one client per language at the same time

What if you have e.g. a monorepo with multiple services written in the same language?

@RemcoSmitsDev
Copy link
Contributor Author

Uhm, I think most of the debug adapters support multiple threads, but need to look more in to that. Not sure how VS Code handles this, if they allow you to run the same debugger adapter twice or more.

@davidbuzz
Copy link
Contributor

I'd love to see another more up-to-date video of the current status of this, if u can find time. :-)

@RemcoSmitsDev RemcoSmitsDev force-pushed the debugger branch 3 times, most recently from ac95fbd to 515122c Compare July 3, 2024 21:20
@jonahcui
Copy link

jonahcui commented Jul 4, 2024

HI, I have started a dlv(go dap server) to debug go program, but i need bring env to the dlv commend. I read the code DebugAdapterClient, i think when create_tcp_client or create_stdio_client, we should bring env configuration to command.

@RemcoSmitsDev
Copy link
Contributor Author

RemcoSmitsDev commented Jul 4, 2024

HI, I have started a dlv(go dap server) to debug go program, but i need bring env to the dlv commend. I read the code DebugAdapterClient, i think when create_tcp_client or create_stdio_client, we should bring env configuration to command.

Hey, I think most debug adapters support this already by passing in an env prop through the launch or attach request. See the JS debugger config options. We already support passing in your own config values, so I don't think we need to add more configuration for this. Because it's on the debug adapter for getting this data and handling it how they want.

@jonahcui
Copy link

jonahcui commented Jul 4, 2024

HI, I have started a dlv(go dap server) to debug go program, but i need bring env to the dlv commend. I read the code DebugAdapterClient, i think when create_tcp_client or create_stdio_client, we should bring env configuration to command.

Hey, I think most debug adapters support this already by passing in an env prop through the launch or attach request. See the JS debugger config options. We already support passing in your own config values, so I don't think we need to add more configuration for this. Because it's on the debug adapter for getting this data and handling it how they want.

Ok, understand.... I will test it on js debugger and go delve and study your code.

RemcoSmitsDev and others added 10 commits October 4, 2024 20:23
* WIP Move stack frame list to own module

* Add missing notify

* Remove some more duplicated state for the current stack frame

* Clear highlights when stack frame has changed

* Fix go to stack frame again
* Pass http client to dap store

* Set up DapAdapterDelegate to use for DAP binary fetches

* WIP to get debug adapters to use zed directory for installs

* Get debugpy automatic download working

* Change DapAdapter fetch_or_install to return a Result

* Add node_runtime to dap delegate

Co-authored-by: Remco Smits <[email protected]>

* Create dap_adapter crate & move language dap adapter code to that crate

This is the first phase of dap::client refactor to organize debug adapters with zed lsp adapters.
Eventually dap::client will have a TransportParams pass to it instead of an adapter, and adapters
will handle custom debug events.

Co-authored-by: Remco Smits <[email protected]>

* Move language specific dap adapter code to their own files

* Move DebugAdapter member out of ClientDebugAdapter struct

This change was done to make dap::client more in line with zed's lsp::client, it might be reverted depending
on if this solution is cleaner or not.

* Get php debug adapter to auto download when needed

* Get adapter_path argument to work with auto download dap adapters

---------

Co-authored-by: Remco Smits <[email protected]>
This also fixes an issue that you could not add your own initialize_args for non custom adapters
* Clean up how adapters install and fetch their binary

Before this was in one method, which was hard to read and doing to many things.

* Add javascript debug adapter

* Get node binary from node_runtime

* Undo remove request args for lldb

* Remove initialize value for now

* Remove default values

* Fix did not compile javascript

* Fix php did not build
Also simplify the DebugAdapterBInary struct
Before this change the debug panel was still in the running state, which is/was wrong. So updating the status to Ended, will update the UI to an correct state.
* Remove not needed notify

* Add loaded sources list

* Remove not needed double nested div.child()

* Remove not needed block

* Fix todo for updating loaded source
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Microsoft Debug Adapter Protocol support Build and Debug support
9 participants