Debugger implementation (#13433)

###  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:**


https://github.com/user-attachments/assets/c4deff07-80dd-4dc6-ad2e-0c252a478fe9


https://github.com/user-attachments/assets/e1ed2345-b750-4bb6-9c97-50961b76904f

----

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:
```cli
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

---------

Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
Co-authored-by: Anthony Eid <hello@anthonyeid.me>
Co-authored-by: Anthony <anthony@zed.dev>
Co-authored-by: Piotr Osiewicz <peterosiewicz@gmail.com>
Co-authored-by: Piotr <piotr@zed.dev>
This commit is contained in:
Remco Smits
2025-03-18 12:55:25 -04:00
committed by GitHub
co-authored by Piotr Osiewicz Anthony Eid Anthony Piotr Osiewicz Piotr
parent ed4e654fdf
commit 41a60ffecf
156 changed files with 25840 additions and 451 deletions
Generated
+134 -1
View File
@@ -13,7 +13,6 @@ dependencies = [
"futures 0.3.31",
"gpui",
"language",
"lsp",
"project",
"smallvec",
"ui",
@@ -2644,6 +2643,12 @@ dependencies = [
"zeroize",
]
[[package]]
name = "circular-buffer"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dacb91f972298e70fc507a2ffcaf1545807f1a36da586fb846646030adc542f"
[[package]]
name = "clang-sys"
version = "1.8.1"
@@ -2893,9 +2898,12 @@ dependencies = [
"clock",
"collab_ui",
"collections",
"command_palette_hooks",
"context_server",
"ctor",
"dap",
"dashmap 6.1.0",
"debugger_ui",
"derive_more",
"editor",
"env_logger 0.11.7",
@@ -3839,6 +3847,66 @@ dependencies = [
"syn 2.0.100",
]
[[package]]
name = "dap"
version = "0.1.0"
dependencies = [
"anyhow",
"async-compression",
"async-pipe",
"async-tar",
"async-trait",
"client",
"collections",
"dap-types",
"env_logger 0.11.7",
"fs",
"futures 0.3.31",
"gpui",
"http_client",
"language",
"log",
"node_runtime",
"parking_lot",
"paths",
"schemars",
"serde",
"serde_json",
"settings",
"smallvec",
"smol",
"task",
"util",
]
[[package]]
name = "dap-types"
version = "0.0.1"
source = "git+https://github.com/zed-industries/dap-types?rev=bfd4af0#bfd4af084bbaa5f344e6925370d7642e41d0b5b8"
dependencies = [
"schemars",
"serde",
"serde_json",
]
[[package]]
name = "dap_adapters"
version = "0.1.0"
dependencies = [
"anyhow",
"async-trait",
"dap",
"gpui",
"language",
"paths",
"regex",
"serde",
"serde_json",
"sysinfo",
"task",
"util",
]
[[package]]
name = "dashmap"
version = "5.5.3"
@@ -3912,6 +3980,58 @@ dependencies = [
"winapi",
]
[[package]]
name = "debugger_tools"
version = "0.1.0"
dependencies = [
"anyhow",
"dap",
"editor",
"futures 0.3.31",
"gpui",
"project",
"serde_json",
"settings",
"smol",
"util",
"workspace",
]
[[package]]
name = "debugger_ui"
version = "0.1.0"
dependencies = [
"anyhow",
"client",
"collections",
"command_palette_hooks",
"dap",
"editor",
"env_logger 0.11.7",
"feature_flags",
"futures 0.3.31",
"fuzzy",
"gpui",
"language",
"log",
"menu",
"picker",
"pretty_assertions",
"project",
"rpc",
"serde",
"serde_json",
"settings",
"sysinfo",
"task",
"terminal_view",
"theme",
"ui",
"unindent",
"util",
"workspace",
]
[[package]]
name = "deepseek"
version = "0.1.0"
@@ -4212,6 +4332,7 @@ dependencies = [
"db",
"emojis",
"env_logger 0.11.7",
"feature_flags",
"file_icons",
"fs",
"futures 0.3.31",
@@ -4228,6 +4349,7 @@ dependencies = [
"log",
"lsp",
"markdown",
"menu",
"multi_buffer",
"ordered-float 2.10.1",
"parking_lot",
@@ -10422,9 +10544,12 @@ dependencies = [
"askpass",
"async-trait",
"buffer_diff",
"circular-buffer",
"client",
"clock",
"collections",
"dap",
"dap_adapters",
"env_logger 0.11.7",
"extension",
"fancy-regex 0.14.0",
@@ -10437,6 +10562,7 @@ dependencies = [
"gpui",
"http_client",
"image",
"indexmap",
"itertools 0.14.0",
"language",
"log",
@@ -11100,6 +11226,7 @@ version = "0.1.0"
dependencies = [
"anyhow",
"auto_update",
"dap",
"editor",
"extension_host",
"file_finder",
@@ -13657,12 +13784,14 @@ version = "0.1.0"
dependencies = [
"anyhow",
"collections",
"dap-types",
"futures 0.3.31",
"gpui",
"hex",
"parking_lot",
"schemars",
"serde",
"serde_json",
"serde_json_lenient",
"sha2",
"shellexpand 2.1.2",
@@ -13675,7 +13804,9 @@ name = "tasks_ui"
version = "0.1.0"
dependencies = [
"anyhow",
"debugger_ui",
"editor",
"feature_flags",
"file_icons",
"fuzzy",
"gpui",
@@ -17218,6 +17349,8 @@ dependencies = [
"component_preview",
"copilot",
"db",
"debugger_tools",
"debugger_ui",
"diagnostics",
"editor",
"env_logger 0.11.7",