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 17:55:25 +01:00 committed by GitHub
parent ed4e654fdf
commit 41a60ffecf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
156 changed files with 25840 additions and 451 deletions

View file

@ -68,6 +68,7 @@ impl ThemeColors {
icon_disabled: neutral().light().step_9(),
icon_placeholder: neutral().light().step_10(),
icon_accent: blue().light().step_11(),
debugger_accent: red().light().step_10(),
status_bar_background: neutral().light().step_2(),
title_bar_background: neutral().light().step_2(),
title_bar_inactive_background: neutral().light().step_3(),
@ -94,6 +95,7 @@ impl ThemeColors {
editor_subheader_background: neutral().light().step_2(),
editor_active_line_background: neutral().light_alpha().step_3(),
editor_highlighted_line_background: neutral().light_alpha().step_3(),
editor_debugger_active_line_background: yellow().dark_alpha().step_3(),
editor_line_number: neutral().light().step_10(),
editor_hover_line_number: neutral().light().step_12(),
editor_active_line_number: neutral().light().step_11(),
@ -181,6 +183,7 @@ impl ThemeColors {
icon_disabled: neutral().dark().step_9(),
icon_placeholder: neutral().dark().step_10(),
icon_accent: blue().dark().step_11(),
debugger_accent: red().light().step_10(),
status_bar_background: neutral().dark().step_2(),
title_bar_background: neutral().dark().step_2(),
title_bar_inactive_background: neutral().dark().step_3(),
@ -206,7 +209,8 @@ impl ThemeColors {
editor_gutter_background: neutral().dark().step_1(),
editor_subheader_background: neutral().dark().step_3(),
editor_active_line_background: neutral().dark_alpha().step_3(),
editor_highlighted_line_background: neutral().dark_alpha().step_4(),
editor_highlighted_line_background: yellow().dark_alpha().step_4(),
editor_debugger_active_line_background: yellow().dark_alpha().step_3(),
editor_line_number: neutral().dark_alpha().step_10(),
editor_hover_line_number: neutral().dark_alpha().step_12(),
editor_active_line_number: neutral().dark_alpha().step_11(),

View file

@ -114,6 +114,7 @@ pub(crate) fn zed_default_dark() -> Theme {
icon_disabled: hsla(220.0 / 360., 6.4 / 100., 45.7 / 100., 1.0),
icon_placeholder: hsla(220.0 / 360., 6.4 / 100., 45.7 / 100., 1.0),
icon_accent: blue,
debugger_accent: red,
status_bar_background: bg,
title_bar_background: bg,
title_bar_inactive_background: bg,
@ -128,6 +129,12 @@ pub(crate) fn zed_default_dark() -> Theme {
editor_subheader_background: bg,
editor_active_line_background: hsla(222.9 / 360., 13.5 / 100., 20.4 / 100., 1.0),
editor_highlighted_line_background: hsla(207.8 / 360., 81. / 100., 66. / 100., 0.1),
editor_debugger_active_line_background: hsla(
207.8 / 360.,
81. / 100.,
66. / 100.,
0.2,
),
editor_line_number: hsla(222.0 / 360., 11.5 / 100., 34.1 / 100., 1.0),
editor_active_line_number: hsla(216.0 / 360., 5.9 / 100., 49.6 / 100., 1.0),
editor_hover_line_number: hsla(216.0 / 360., 5.9 / 100., 56.7 / 100., 1.0),

View file

@ -188,7 +188,7 @@ pub struct ThemeColorsContent {
/// Background Color. Used for the active state of an element that should have a different background than the surface it's on.
///
/// Active states are triggered by the mouse button being pressed down on an element, or the Return button or other activator being pressd.
/// Active states are triggered by the mouse button being pressed down on an element, or the Return button or other activator being pressed.
#[serde(rename = "element.active")]
pub element_active: Option<String>,
@ -226,7 +226,7 @@ pub struct ThemeColorsContent {
/// Background Color. Used for the active state of a ghost element that should have the same background as the surface it's on.
///
/// Active states are triggered by the mouse button being pressed down on an element, or the Return button or other activator being pressd.
/// Active states are triggered by the mouse button being pressed down on an element, or the Return button or other activator being pressed.
#[serde(rename = "ghost_element.active")]
pub ghost_element_active: Option<String>,
@ -292,6 +292,11 @@ pub struct ThemeColorsContent {
#[serde(rename = "icon.accent")]
pub icon_accent: Option<String>,
/// Color used to accent some of the debuggers elements
/// Only accent breakpoint & breakpoint related symbols right now
#[serde(rename = "debugger.accent")]
pub debugger_accent: Option<String>,
#[serde(rename = "status_bar.background")]
pub status_bar_background: Option<String>,
@ -382,6 +387,10 @@ pub struct ThemeColorsContent {
#[serde(rename = "editor.highlighted_line.background")]
pub editor_highlighted_line_background: Option<String>,
/// Background of active line of debugger
#[serde(rename = "editor.debugger_active_line.background")]
pub editor_debugger_active_line_background: Option<String>,
/// Text Color. Used for the text of the line number in the editor gutter.
#[serde(rename = "editor.line_number")]
pub editor_line_number: Option<String>,
@ -707,6 +716,10 @@ impl ThemeColorsContent {
.icon_accent
.as_ref()
.and_then(|color| try_parse_color(color).ok()),
debugger_accent: self
.debugger_accent
.as_ref()
.and_then(|color| try_parse_color(color).ok()),
status_bar_background: self
.status_bar_background
.as_ref()
@ -817,6 +830,10 @@ impl ThemeColorsContent {
.editor_highlighted_line_background
.as_ref()
.and_then(|color| try_parse_color(color).ok()),
editor_debugger_active_line_background: self
.editor_debugger_active_line_background
.as_ref()
.and_then(|color| try_parse_color(color).ok()),
editor_line_number: self
.editor_line_number
.as_ref()

View file

@ -43,7 +43,7 @@ pub struct ThemeColors {
pub element_hover: Hsla,
/// Background Color. Used for the active state of an element that should have a different background than the surface it's on.
///
/// Active states are triggered by the mouse button being pressed down on an element, or the Return button or other activator being pressd.
/// Active states are triggered by the mouse button being pressed down on an element, or the Return button or other activator being pressed.
pub element_active: Hsla,
/// Background Color. Used for the selected state of an element that should have a different background than the surface it's on.
///
@ -69,7 +69,7 @@ pub struct ThemeColors {
pub ghost_element_hover: Hsla,
/// Background Color. Used for the active state of a ghost element that should have the same background as the surface it's on.
///
/// Active states are triggered by the mouse button being pressed down on an element, or the Return button or other activator being pressd.
/// Active states are triggered by the mouse button being pressed down on an element, or the Return button or other activator being pressed.
pub ghost_element_active: Hsla,
/// Background Color. Used for the selected state of a ghost element that should have the same background as the surface it's on.
///
@ -109,6 +109,9 @@ pub struct ThemeColors {
///
/// This might be used to show when a toggleable icon button is selected.
pub icon_accent: Hsla,
/// Color used to accent some debugger elements
/// Is used by breakpoints
pub debugger_accent: Hsla,
// ===
// UI Elements
@ -148,6 +151,8 @@ pub struct ThemeColors {
pub editor_subheader_background: Hsla,
pub editor_active_line_background: Hsla,
pub editor_highlighted_line_background: Hsla,
/// Line color of the line a debugger is currently stopped at
pub editor_debugger_active_line_background: Hsla,
/// Text Color. Used for the text of the line number in the editor gutter.
pub editor_line_number: Hsla,
/// Text Color. Used for the text of the line number in the editor gutter when the line is highlighted.