Skip to content

Debugger implementation #13433

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

Merged
merged 977 commits into from
Mar 18, 2025
Merged

Debugger implementation #13433

merged 977 commits into from
Mar 18, 2025

Conversation

RemcoSmitsDev
Copy link
Contributor

@RemcoSmitsDev RemcoSmitsDev commented Jun 23, 2024

DISCLAIMER

As of 6th March 2025, debugger is still in development. We plan to merge it behind a staff-only feature flag for staff use only, followed by non-public release and then finally a public one (akin to how Git panel release was handled). This is done to ensure the best experience when it gets released.

END OF DISCLAIMER

The current state of the debugger implementation:

Screen.Recording.2024-10-16.at.15.02.20.mov
Screen.Recording.2025-01-19.at.17.45.06.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, you can use the following command to join the channel:

zed https://zed.dev/channel/zed-debugger-11370 

Current Features

  • Collab
    • Breakpoints
      • Sync when you (re)join a project
      • Sync when you add/remove a breakpoint
    • Sync active debug line
    • Stack frames
      • Click on stack frame
        • View variables that belong to the stack frame
        • Visit the source file
      • Restart stack frame (if adapter supports this)
    • Variables
    • Loaded sources
    • Modules
    • Controls
      • Continue
      • Step back
        • Stepping granularity (configurable)
      • Step into
        • Stepping granularity (configurable)
      • Step over
        • Stepping granularity (configurable)
      • Step out
        • Stepping granularity (configurable)
    • Debug console
  • Breakpoints
    • Log breakpoints
    • line breakpoints
    • Persistent between zed sessions (configurable)
    • Multi buffer support
    • Toggle disable/enable all breakpoints
  • Stack frames
    • Click on stack frame
      • View variables that belong to the stack frame
      • Visit the source file
      • Show collapsed stack frames
    • Restart stack frame (if adapter supports this)
  • Loaded sources
    • View all used loaded sources if supported by adapter.
  • Modules
    • View all used modules (if adapter supports this)
  • Variables
    • Copy value
    • Copy name
    • Copy memory reference
    • Set value (if adapter supports this)
    • keyboard navigation
  • Debug Console
    • See logs
    • View output that was sent from debug adapter
      • Output grouping
    • Evaluate code
      • Updates the variable list
      • Auto completion
        • If not supported by adapter, we will show auto-completion for existing variables
  • Debug Terminal
    • Run custom commands and change env values right inside your Zed terminal
  • Attach to process (if adapter supports this)
    • Process picker
  • Controls
    • Continue
    • Step back
      • Stepping granularity (configurable)
    • 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
  • Debug view to see Adapter/RPC log messages
  • Testing
    • Fake debug adapter
      • Fake requests & events

Release Notes:

  • N/A

@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.

@RemcoSmitsDev RemcoSmitsDev force-pushed the debugger branch 2 times, most recently from c71eb06 to 47a5f0c Compare June 29, 2024 14:47
@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 RemcoSmitsDev force-pushed the debugger branch 4 times, most recently from 7eacd30 to 3f8581a Compare July 5, 2024 14:54
@RemcoSmitsDev RemcoSmitsDev force-pushed the debugger branch 2 times, most recently from 8adc489 to 8d99f9b Compare July 12, 2024 20:01
@davidbuzz
Copy link
Contributor

davidbuzz commented Jul 15, 2024

for those of us trying to follow-along at home on this PR, it would be helpful of there was a sample tasks.json ( or wherever the debug settings are being stored if not there ) and any relevent settings.json we need enable, as I compiled and ran this PR, but was unable to get the same behaviour as either of the screen recordings.
for example: ctrl-shift-p[command palette] -> 'debug panel: open panel' gave me an empty lower panel with no start/stop/pause etc, and none of the other demonstrated command-palette/s seemed to do anything.

@RemcoSmitsDev
Copy link
Contributor Author

RemcoSmitsDev commented Jul 15, 2024

Hey @davidbuzz, sorry for not posting any examples of starting a debug adapter. I did this for a reason, because I'm not happy yet with the naming of the fields & structure of the task. But here is an example task to start a debug adapter:

If you want to follow a bit more about what we are working on, you can join the following channel: https://zed.dev/channel/zed-debugger-11370.

{
  "label": "Xdebug debug adapter",
  "command": "bun",
  "args": [
    "/Users/remcosmits/Documents/code/vscode-php-debug/out/phpDebug.js",
    "--server=8132"
  ],
  "task_type": "debug",
  "cwd": "/Users/remcosmits/Documents/code/symfony_demo",
  "debug_adapter": {
    "id": "xdebug",
    "port": 8132,
    "request_args": {
      "skipFiles": ["**/vendor/**"],
      "pathMappings": {
        "/Users/remcosmits/Documents/code/symfony_demo/public": "/Users/remcosmits/Documents/code/symfony_demo/public"
      },
      "localSourceRoot": "/Users/remcosmits/Documents/code/symfony_demo",
      "serverSourceRoot": "/Users/remcosmits/Documents/code/symfony_demo",
      "xdebugSettings": {
        "show_hidden": 1
      }
    }
  }
}

@RemcoSmitsDev RemcoSmitsDev force-pushed the debugger branch 2 times, most recently from d9461c3 to b6e677e Compare July 15, 2024 16:44
@davidbuzz
Copy link
Contributor

davidbuzz commented Jul 16, 2024

i think u mean this discord channel, but u were close.. https://discord.com/channels/869392257814519848/1255246362220691456 ... i pop in to the Zed discord occassionally. :-)

@RemcoSmitsDev
Copy link
Contributor Author

i think u mean this discord channel, but u were close.. https://discord.com/channels/869392257814519848/1255246362220691456 ... i pop in to the Zed discord occassionally. :-)

No, that's not what I mean. What do you mean by I'm close? It sounds a bit disparaging...

@davidbuzz
Copy link
Contributor

I was just trying to say that the link u gave starting with https://zed.dev doesn't work for me.

@RemcoSmitsDev
Copy link
Contributor Author

Ahh oké. it seems to work for other people. Also it's the same as the one that i posted in the discord channel. Does it still not work for you?

@davidbuzz
Copy link
Contributor

Ahh oké. it seems to work for other people. Also it's the same as the one that i posted in the discord channel. Does it still not work for you?

... im on linux. :-)

@Anthony-Eid Anthony-Eid merged commit 41a60ff into zed-industries:main Mar 18, 2025
15 checks passed
@berkus
Copy link
Contributor

berkus commented Mar 18, 2025

zomg zomg!

@asumaran
Copy link

@Jhooomn
Copy link

Jhooomn commented Mar 18, 2025

solid

image

@pzurek
Copy link

pzurek commented Mar 18, 2025

Amazing work!

celebrate

@tarsioonofrio
Copy link

tetra-pele

@matfat55
Copy link

lets go!

@RemiDesgrange
Copy link

Huge congrat 🎉 !!!!

@ruizdiazever
Copy link

Leeets goooo!

@davidstevens37
Copy link

Amazing work @Anthony-Eid and team! Such a herculean effort. Thank you for taking this on! You've just made so many people's day. 🎉

@pgodschalk
Copy link

Looks like brew uninstall --cask visual-studio-code is back on the menu. 🎉

@mokeyish
Copy link

Huge congrat 🎉 !!!!

@haras-unicorn
Copy link

holy moly i cant believe u did it :)
congrats!
ive been subscribed to this for like 6 months waiting patiently
speaking of do you know when this will be released?

@kelvinchin12070811
Copy link

holy moly i cant believe u did it :)

congrats!

ive been subscribed to this for like 6 months waiting patiently

speaking of do you know when this will be released?

I think based in the description part of the pr stated that they might not know the actual schedule yet. So I think we could just wait a few months more first as this is just ready to be tested internally.

@merlinz01
Copy link

You can run it from source on the default branch if you want to test it.

git clone https://github.com/zed-industries/zed
cd zed
script/linux
cargo run

SomeoneToIgnore added a commit that referenced this pull request Mar 20, 2025
…rged (#27184)

Follow-up of #13433
Closes #27124
Closes #27066

After this change, both old global task source, `tasks.json` and new,
`debug.json` started to call for the same task update method:


https://github.com/zed-industries/zed/blob/14920ab910c6d0208d23ce6b6e2ed644e6f20f2e/crates/project/src/task_inventory.rs#L414

erasing previous declarations.

The PR puts this data under different paths instead and adjusts the code
around it.

Release Notes:

- Fixed custom tasks not shown
gcp-cherry-pick-bot bot pushed a commit that referenced this pull request Mar 20, 2025
…rged (#27184)

Follow-up of #13433
Closes #27124
Closes #27066

After this change, both old global task source, `tasks.json` and new,
`debug.json` started to call for the same task update method:


https://github.com/zed-industries/zed/blob/14920ab910c6d0208d23ce6b6e2ed644e6f20f2e/crates/project/src/task_inventory.rs#L414

erasing previous declarations.

The PR puts this data under different paths instead and adjusts the code
around it.

Release Notes:

- Fixed custom tasks not shown
SomeoneToIgnore added a commit that referenced this pull request Mar 20, 2025
…rged (cherry-pick #27184) (#27187)

Cherry-picked debugger: Ensure both debug and regular global tasks are
correctly merged (#27184)

Follow-up of #13433
Closes #27124
Closes #27066

After this change, both old global task source, `tasks.json` and new,
`debug.json` started to call for the same task update method:



https://github.com/zed-industries/zed/blob/14920ab910c6d0208d23ce6b6e2ed644e6f20f2e/crates/project/src/task_inventory.rs#L414

erasing previous declarations.

The PR puts this data under different paths instead and adjusts the code
around it.

Release Notes:

- Fixed custom tasks not shown

Co-authored-by: Kirill Bulatov <[email protected]>
@scorphus
Copy link

scorphus commented Mar 28, 2025

Hey, this seems amazing!

I am sorry to bring this up, but I definitely need help understanding how debugging works in Zed.

I'm on a macbook with:

Zed 0.179.3 
83d9f19234df4e0f327e95530658ad65d781235e

Cmd+Shift+P then typing debug: gives me this:

image

Here's how .zed/debug.json reads:

[
    {
        "label": "Debug active PHP file",
        "adapter": "php",
        "program": "$ZED_FILE",
        "request": "launch",
        "cwd": "$ZED_WORKTREE_ROOT"
    },
    {
        "label": "Debug active Python file",
        "adapter": "python",
        "program": "$ZED_FILE",
        "request": "launch",
        "cwd": "$ZED_WORKTREE_ROOT"
    },
    {
        "label": "Debug active JavaScript file",
        "adapter": "javascript",
        "program": "$ZED_FILE",
        "request": "launch",
        "cwd": "$ZED_WORKTREE_ROOT"
    },
    {
        "label": "JavaScript debug terminal",
        "adapter": "javascript",
        "request": "launch",
        "cwd": "$ZED_WORKTREE_ROOT",
        "initialize_args": {
            "console": "integratedTerminal"
        }
    }
]

I really wonder what I'm missing. Any hint is more than appreciated. Thanks!

@bennetbo
Copy link
Contributor

@scorphus The debugger feature is not released yet, you can test the current state if you build from source. There is still a lot to do and development is ongoing

@trylix
Copy link

trylix commented Mar 28, 2025

Hey, this seems amazing!

I am sorry to bring this up, but I definitely need help understanding how debugging works in Zed.

I'm on a macbook with:


Zed 0.179.3 

83d9f19234df4e0f327e95530658ad65d781235e

Cmd+Shift+P then typing debug: gives me this:

image

Here's how .zed/debug.json reads:

[

    {

        "label": "Debug active PHP file",

        "adapter": "php",

        "program": "$ZED_FILE",

        "request": "launch",

        "cwd": "$ZED_WORKTREE_ROOT"

    },

    {

        "label": "Debug active Python file",

        "adapter": "python",

        "program": "$ZED_FILE",

        "request": "launch",

        "cwd": "$ZED_WORKTREE_ROOT"

    },

    {

        "label": "Debug active JavaScript file",

        "adapter": "javascript",

        "program": "$ZED_FILE",

        "request": "launch",

        "cwd": "$ZED_WORKTREE_ROOT"

    },

    {

        "label": "JavaScript debug terminal",

        "adapter": "javascript",

        "request": "launch",

        "cwd": "$ZED_WORKTREE_ROOT",

        "initialize_args": {

            "console": "integratedTerminal"

        }

    }

]

I really wonder what I'm missing. Any hint is more than appreciated. Thanks!

The feature is not yet complete and is currently only available to staff. You can clone the main branch and make a few changes in the User Store to enable staff permissions. Once compiled and after authenticating with your Zed account, the feature should become available. Last time I tested it (about a week ago), it was quite unstable, so I wouldn’t recommend using it for daily work

@osiewicz
Copy link
Contributor

@scorphus it should show up for you when this line is commented out.

@trylix thank you for checking out our debugger (even if you've found it lackluster)! We'll get it to a good spot, I promise :)

@trylix
Copy link

trylix commented Mar 28, 2025

@osiewicz actually, I’ve really liked how the debugger has been evolving! I’ve been testing it weekly and trying to find ways to contribute to its development. There are still a few issues that make it hard to use it for daily work, but it’s definitely heading in a great direction — looking forward to seeing it improve even more!

@bant-gurtam
Copy link

@scorphus it should show up for you when this line is commented out.

@trylix thank you for checking out our debugger (even if you've found it lackluster)! We'll get it to a good spot, I promise :)

Hi, I'm using the nightly build. Is it possible to pass this debug feature flag in? Or is building from source the only way?

@LiberQuack
Copy link

LiberQuack commented Apr 3, 2025

Hey @bant-gurtam, I could run it locally... It seems you need to build it locally

Following the steps below did the trick for me

1) Install dependencies

./script/linux # install system dependencies

2) Comment out this line

(As mentioned by @scorphus previously)

3) Execute the command below to build and run the project

export CARGO_NET_GIT_FETCH_WITH_CLI=true
cargo build --profile release

4) Make sure you login to zed ai, there's an icon on the bottom right of the IDE for that

@LiberQuack
Copy link

I was able to debug some javascript, in the future I'll try checking how it works with golang. The status now is

"Looks very promising" 😃

@bant-gurtam
Copy link

Hey @bant-gurtam, I could run it locally... It seems you need to build it locally

Following the steps below did the trick for me

1) Install dependencies

./script/linux # install system dependencies

2) Comment out this line

(As mentioned by @scorphus previously)

3) Execute the command below to build and run the project

export CARGO_NET_GIT_FETCH_WITH_CLI=true
cargo run

4) Make sure you login to zed ai, there's an icon on the bottom right of the IDE for that

Hey, thanks for reply. However, I'm using it on my work laptop(mac), so I don't want to install additional software just to compile zed 🥲

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.