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:
co-authored by
Piotr Osiewicz
Anthony Eid
Anthony
Piotr Osiewicz
Piotr
parent
ed4e654fdf
commit
41a60ffecf
@@ -315,13 +315,15 @@ message Envelope {
|
||||
|
||||
OpenUncommittedDiff open_uncommitted_diff = 297;
|
||||
OpenUncommittedDiffResponse open_uncommitted_diff_response = 298;
|
||||
|
||||
SetIndexText set_index_text = 299;
|
||||
|
||||
GitShow git_show = 300;
|
||||
GitReset git_reset = 301;
|
||||
GitCommitDetails git_commit_details = 302;
|
||||
|
||||
SetIndexText set_index_text = 299;
|
||||
GitCheckoutFiles git_checkout_files = 303;
|
||||
|
||||
|
||||
Push push = 304;
|
||||
Fetch fetch = 305;
|
||||
GetRemotes get_remotes = 306;
|
||||
@@ -345,13 +347,17 @@ message Envelope {
|
||||
|
||||
GitDiff git_diff = 319;
|
||||
GitDiffResponse git_diff_response = 320;
|
||||
|
||||
GitInit git_init = 321;
|
||||
|
||||
CodeLens code_lens = 322;
|
||||
GetCodeLens get_code_lens = 323;
|
||||
GetCodeLensResponse get_code_lens_response = 324;
|
||||
RefreshCodeLens refresh_code_lens = 325; // current max
|
||||
RefreshCodeLens refresh_code_lens = 325;
|
||||
|
||||
ToggleBreakpoint toggle_breakpoint = 326;
|
||||
BreakpointsForFile breakpoints_for_file = 327; // current max
|
||||
|
||||
|
||||
}
|
||||
|
||||
reserved 87 to 88;
|
||||
@@ -1798,6 +1804,7 @@ message UpdateActiveView {
|
||||
|
||||
enum PanelId {
|
||||
AssistantPanel = 0;
|
||||
DebugPanel = 1;
|
||||
}
|
||||
|
||||
message UpdateView {
|
||||
@@ -1852,6 +1859,7 @@ message View {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
message Collaborator {
|
||||
PeerId peer_id = 1;
|
||||
uint32 replica_id = 2;
|
||||
@@ -2592,6 +2600,531 @@ message GetLlmTokenResponse {
|
||||
|
||||
message RefreshLlmToken {}
|
||||
|
||||
// Remote debugging
|
||||
|
||||
enum BreakpointKind {
|
||||
Standard = 0;
|
||||
Log = 1;
|
||||
}
|
||||
|
||||
|
||||
message Breakpoint {
|
||||
Anchor position = 1;
|
||||
BreakpointKind kind = 3;
|
||||
optional string message = 4;
|
||||
}
|
||||
|
||||
message BreakpointsForFile {
|
||||
uint64 project_id = 1;
|
||||
string path = 2;
|
||||
repeated Breakpoint breakpoints = 3;
|
||||
}
|
||||
|
||||
message ToggleBreakpoint {
|
||||
uint64 project_id = 1;
|
||||
string path = 2;
|
||||
Breakpoint breakpoint = 3;
|
||||
}
|
||||
|
||||
enum DebuggerThreadItem {
|
||||
Console = 0;
|
||||
LoadedSource = 1;
|
||||
Modules = 2;
|
||||
Variables = 3;
|
||||
}
|
||||
|
||||
message DebuggerSetVariableState {
|
||||
string name = 1;
|
||||
DapScope scope = 2;
|
||||
string value = 3;
|
||||
uint64 stack_frame_id = 4;
|
||||
optional string evaluate_name = 5;
|
||||
uint64 parent_variables_reference = 6;
|
||||
}
|
||||
|
||||
message VariableListOpenEntry {
|
||||
oneof entry {
|
||||
DebuggerOpenEntryScope scope = 1;
|
||||
DebuggerOpenEntryVariable variable = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message DebuggerOpenEntryScope {
|
||||
string name = 1;
|
||||
}
|
||||
|
||||
message DebuggerOpenEntryVariable {
|
||||
string scope_name = 1;
|
||||
string name = 2;
|
||||
uint64 depth = 3;
|
||||
}
|
||||
|
||||
message VariableListEntrySetState {
|
||||
uint64 depth = 1;
|
||||
DebuggerSetVariableState state = 2;
|
||||
}
|
||||
|
||||
message VariableListEntryVariable {
|
||||
uint64 depth = 1;
|
||||
DapScope scope = 2;
|
||||
DapVariable variable = 3;
|
||||
bool has_children = 4;
|
||||
uint64 container_reference = 5;
|
||||
}
|
||||
|
||||
message DebuggerScopeVariableIndex {
|
||||
repeated uint64 fetched_ids = 1;
|
||||
repeated DebuggerVariableContainer variables = 2;
|
||||
}
|
||||
|
||||
message DebuggerVariableContainer {
|
||||
uint64 container_reference = 1;
|
||||
DapVariable variable = 2;
|
||||
uint64 depth = 3;
|
||||
}
|
||||
|
||||
enum DapThreadStatus {
|
||||
Running = 0;
|
||||
Stopped = 1;
|
||||
Exited = 2;
|
||||
Ended = 3;
|
||||
}
|
||||
|
||||
message VariableListScopes {
|
||||
uint64 stack_frame_id = 1;
|
||||
repeated DapScope scopes = 2;
|
||||
}
|
||||
|
||||
message VariableListVariables {
|
||||
uint64 stack_frame_id = 1;
|
||||
uint64 scope_id = 2;
|
||||
DebuggerScopeVariableIndex variables = 3;
|
||||
}
|
||||
|
||||
|
||||
enum VariablesArgumentsFilter {
|
||||
Indexed = 0;
|
||||
Named = 1;
|
||||
}
|
||||
|
||||
message ValueFormat {
|
||||
optional bool hex = 1;
|
||||
}
|
||||
|
||||
message VariablesRequest {
|
||||
uint64 project_id = 1;
|
||||
uint64 client_id = 2;
|
||||
uint64 variables_reference = 3;
|
||||
optional VariablesArgumentsFilter filter = 4;
|
||||
optional uint64 start = 5;
|
||||
optional uint64 count = 6;
|
||||
optional ValueFormat format = 7;
|
||||
}
|
||||
|
||||
enum SteppingGranularity {
|
||||
Statement = 0;
|
||||
Line = 1;
|
||||
Instruction = 2;
|
||||
}
|
||||
|
||||
message DapLocationsRequest {
|
||||
uint64 project_id = 1;
|
||||
uint64 session_id = 2;
|
||||
uint64 location_reference = 3;
|
||||
}
|
||||
|
||||
message DapLocationsResponse {
|
||||
DapSource source = 1;
|
||||
uint64 line = 2;
|
||||
optional uint64 column = 3;
|
||||
optional uint64 end_line = 4;
|
||||
optional uint64 end_column = 5;
|
||||
}
|
||||
|
||||
enum DapEvaluateContext {
|
||||
Repl = 0;
|
||||
Watch = 1;
|
||||
Hover = 2;
|
||||
Clipboard = 3;
|
||||
EvaluateVariables = 4;
|
||||
EvaluateUnknown = 5;
|
||||
}
|
||||
|
||||
message DapEvaluateRequest {
|
||||
uint64 project_id = 1;
|
||||
uint64 client_id = 2;
|
||||
string expression = 3;
|
||||
optional uint64 frame_id = 4;
|
||||
optional DapEvaluateContext context = 5;
|
||||
}
|
||||
|
||||
message DapEvaluateResponse {
|
||||
string result = 1;
|
||||
optional string evaluate_type = 2;
|
||||
uint64 variable_reference = 3;
|
||||
optional uint64 named_variables = 4;
|
||||
optional uint64 indexed_variables = 5;
|
||||
optional string memory_reference = 6;
|
||||
}
|
||||
|
||||
|
||||
message DapCompletionRequest {
|
||||
uint64 project_id = 1;
|
||||
uint64 client_id = 2;
|
||||
string query = 3;
|
||||
optional uint64 frame_id = 4;
|
||||
optional uint64 line = 5;
|
||||
uint64 column = 6;
|
||||
}
|
||||
|
||||
enum DapCompletionItemType {
|
||||
Method = 0;
|
||||
Function = 1;
|
||||
Constructor = 2;
|
||||
Field = 3;
|
||||
Variable = 4;
|
||||
Class = 5;
|
||||
Interface = 6;
|
||||
Module = 7;
|
||||
Property = 8;
|
||||
Unit = 9;
|
||||
Value = 10;
|
||||
Enum = 11;
|
||||
Keyword = 12;
|
||||
Snippet = 13;
|
||||
Text = 14;
|
||||
Color = 15;
|
||||
CompletionItemFile = 16;
|
||||
Reference = 17;
|
||||
Customcolor = 19;
|
||||
}
|
||||
|
||||
message DapCompletionItem {
|
||||
string label = 1;
|
||||
optional string text = 2;
|
||||
optional string sort_text = 3;
|
||||
optional string detail = 4;
|
||||
optional DapCompletionItemType typ = 5;
|
||||
optional uint64 start = 6;
|
||||
optional uint64 length = 7;
|
||||
optional uint64 selection_start = 8;
|
||||
optional uint64 selection_length = 9;
|
||||
}
|
||||
|
||||
message DapCompletionResponse {
|
||||
uint64 client_id = 1;
|
||||
repeated DapCompletionItem completions = 2;
|
||||
}
|
||||
|
||||
message DapScopesRequest {
|
||||
uint64 project_id = 1;
|
||||
uint64 client_id = 2;
|
||||
uint64 stack_frame_id = 3;
|
||||
}
|
||||
|
||||
message DapScopesResponse {
|
||||
repeated DapScope scopes = 1;
|
||||
}
|
||||
|
||||
message DapSetVariableValueRequest {
|
||||
uint64 project_id = 1;
|
||||
uint64 client_id = 2;
|
||||
string name = 3;
|
||||
string value = 4;
|
||||
uint64 variables_reference = 5;
|
||||
}
|
||||
|
||||
message DapSetVariableValueResponse {
|
||||
uint64 client_id = 1;
|
||||
string value = 2;
|
||||
optional string variable_type = 3;
|
||||
optional uint64 variables_reference = 4;
|
||||
optional uint64 named_variables = 5;
|
||||
optional uint64 indexed_variables = 6;
|
||||
optional string memory_reference = 7;
|
||||
}
|
||||
|
||||
message DapPauseRequest {
|
||||
uint64 project_id = 1;
|
||||
uint64 client_id = 2;
|
||||
uint64 thread_id = 3;
|
||||
}
|
||||
|
||||
message DapDisconnectRequest {
|
||||
uint64 project_id = 1;
|
||||
uint64 client_id = 2;
|
||||
optional bool restart = 3;
|
||||
optional bool terminate_debuggee = 4;
|
||||
optional bool suspend_debuggee = 5;
|
||||
}
|
||||
|
||||
message DapTerminateThreadsRequest {
|
||||
uint64 project_id = 1;
|
||||
uint64 client_id = 2;
|
||||
repeated uint64 thread_ids = 3;
|
||||
}
|
||||
|
||||
message DapThreadsRequest {
|
||||
uint64 project_id = 1;
|
||||
uint64 client_id = 2;
|
||||
}
|
||||
|
||||
message DapThreadsResponse {
|
||||
repeated DapThread threads = 1;
|
||||
}
|
||||
|
||||
message DapTerminateRequest {
|
||||
uint64 project_id = 1;
|
||||
uint64 client_id = 2;
|
||||
optional bool restart = 3;
|
||||
}
|
||||
|
||||
message DapRestartRequest {
|
||||
uint64 project_id = 1;
|
||||
uint64 client_id = 2;
|
||||
bytes raw_args = 3;
|
||||
}
|
||||
|
||||
message DapRestartStackFrameRequest {
|
||||
uint64 project_id = 1;
|
||||
uint64 client_id = 2;
|
||||
uint64 stack_frame_id = 3;
|
||||
}
|
||||
|
||||
message ToggleIgnoreBreakpoints {
|
||||
uint64 project_id = 1;
|
||||
uint32 session_id = 2;
|
||||
}
|
||||
|
||||
message IgnoreBreakpointState {
|
||||
uint64 project_id = 1;
|
||||
uint64 session_id = 2;
|
||||
bool ignore = 3;
|
||||
}
|
||||
|
||||
message DapNextRequest {
|
||||
uint64 project_id = 1;
|
||||
uint64 client_id = 2;
|
||||
uint64 thread_id = 3;
|
||||
optional bool single_thread = 4;
|
||||
optional SteppingGranularity granularity = 5;
|
||||
}
|
||||
|
||||
message DapStepInRequest {
|
||||
uint64 project_id = 1;
|
||||
uint64 client_id = 2;
|
||||
uint64 thread_id = 3;
|
||||
optional uint64 target_id = 4;
|
||||
optional bool single_thread = 5;
|
||||
optional SteppingGranularity granularity = 6;
|
||||
}
|
||||
|
||||
message DapStepOutRequest {
|
||||
uint64 project_id = 1;
|
||||
uint64 client_id = 2;
|
||||
uint64 thread_id = 3;
|
||||
optional bool single_thread = 4;
|
||||
optional SteppingGranularity granularity = 5;
|
||||
}
|
||||
|
||||
message DapStepBackRequest {
|
||||
uint64 project_id = 1;
|
||||
uint64 client_id = 2;
|
||||
uint64 thread_id = 3;
|
||||
optional bool single_thread = 4;
|
||||
optional SteppingGranularity granularity = 5;
|
||||
}
|
||||
|
||||
message DapContinueRequest {
|
||||
uint64 project_id = 1;
|
||||
uint64 client_id = 2;
|
||||
uint64 thread_id = 3;
|
||||
optional bool single_thread = 4;
|
||||
}
|
||||
|
||||
message DapContinueResponse {
|
||||
uint64 client_id = 1;
|
||||
optional bool all_threads_continued = 2;
|
||||
}
|
||||
|
||||
message DapModulesRequest {
|
||||
uint64 project_id = 1;
|
||||
uint64 client_id = 2;
|
||||
}
|
||||
|
||||
message DapModulesResponse {
|
||||
uint64 client_id = 1;
|
||||
repeated DapModule modules = 2;
|
||||
}
|
||||
|
||||
message DapLoadedSourcesRequest {
|
||||
uint64 project_id = 1;
|
||||
uint64 client_id = 2;
|
||||
}
|
||||
|
||||
message DapLoadedSourcesResponse {
|
||||
uint64 client_id = 1;
|
||||
repeated DapSource sources = 2;
|
||||
}
|
||||
|
||||
message DapStackTraceRequest {
|
||||
uint64 project_id = 1;
|
||||
uint64 client_id = 2;
|
||||
uint64 thread_id = 3;
|
||||
optional uint64 start_frame = 4;
|
||||
optional uint64 stack_trace_levels = 5;
|
||||
}
|
||||
|
||||
message DapStackTraceResponse {
|
||||
repeated DapStackFrame frames = 1;
|
||||
}
|
||||
|
||||
message DapStackFrame {
|
||||
uint64 id = 1;
|
||||
string name = 2;
|
||||
optional DapSource source = 3;
|
||||
uint64 line = 4;
|
||||
uint64 column = 5;
|
||||
optional uint64 end_line = 6;
|
||||
optional uint64 end_column = 7;
|
||||
optional bool can_restart = 8;
|
||||
optional string instruction_pointer_reference = 9;
|
||||
optional DapModuleId module_id = 10;
|
||||
optional DapStackPresentationHint presentation_hint = 11;
|
||||
}
|
||||
|
||||
message DebuggerLoadedSourceList {
|
||||
uint64 client_id = 1;
|
||||
repeated DapSource sources = 2;
|
||||
}
|
||||
|
||||
message DapVariables {
|
||||
uint64 client_id = 1;
|
||||
repeated DapVariable variables = 2;
|
||||
}
|
||||
|
||||
// Remote Debugging: Dap Types
|
||||
message DapVariable {
|
||||
string name = 1;
|
||||
string value = 2;
|
||||
optional string type = 3;
|
||||
// optional DapVariablePresentationHint presentation_hint = 4;
|
||||
optional string evaluate_name = 5;
|
||||
uint64 variables_reference = 6;
|
||||
optional uint64 named_variables = 7;
|
||||
optional uint64 indexed_variables = 8;
|
||||
optional string memory_reference = 9;
|
||||
}
|
||||
|
||||
message DapThread {
|
||||
uint64 id = 1;
|
||||
string name = 2;
|
||||
}
|
||||
|
||||
message DapScope {
|
||||
string name = 1;
|
||||
optional DapScopePresentationHint presentation_hint = 2;
|
||||
uint64 variables_reference = 3;
|
||||
optional uint64 named_variables = 4;
|
||||
optional uint64 indexed_variables = 5;
|
||||
bool expensive = 6;
|
||||
optional DapSource source = 7;
|
||||
optional uint64 line = 8;
|
||||
optional uint64 column = 9;
|
||||
optional uint64 end_line = 10;
|
||||
optional uint64 end_column = 11;
|
||||
}
|
||||
|
||||
message DapSource {
|
||||
optional string name = 1;
|
||||
optional string path = 2;
|
||||
optional uint64 source_reference = 3;
|
||||
optional DapSourcePresentationHint presentation_hint = 4;
|
||||
optional string origin = 5;
|
||||
repeated DapSource sources = 6;
|
||||
optional bytes adapter_data = 7;
|
||||
repeated DapChecksum checksums = 8;
|
||||
}
|
||||
|
||||
enum DapOutputCategory {
|
||||
ConsoleOutput = 0;
|
||||
Important = 1;
|
||||
Stdout = 2;
|
||||
Stderr = 3;
|
||||
Unknown = 4;
|
||||
}
|
||||
|
||||
enum DapOutputEventGroup {
|
||||
Start = 0;
|
||||
StartCollapsed = 1;
|
||||
End = 2;
|
||||
}
|
||||
|
||||
message DapOutputEvent {
|
||||
string output = 1;
|
||||
optional DapOutputCategory category = 2;
|
||||
optional uint64 variables_reference = 3;
|
||||
optional DapOutputEventGroup group = 4;
|
||||
optional DapSource source = 5;
|
||||
optional uint32 line = 6;
|
||||
optional uint32 column = 7;
|
||||
}
|
||||
|
||||
enum DapChecksumAlgorithm {
|
||||
CHECKSUM_ALGORITHM_UNSPECIFIED = 0;
|
||||
MD5 = 1;
|
||||
SHA1 = 2;
|
||||
SHA256 = 3;
|
||||
TIMESTAMP = 4;
|
||||
}
|
||||
|
||||
message DapChecksum {
|
||||
DapChecksumAlgorithm algorithm = 1;
|
||||
string checksum = 2;
|
||||
}
|
||||
|
||||
enum DapScopePresentationHint {
|
||||
Arguments = 0;
|
||||
Locals = 1;
|
||||
Registers = 2;
|
||||
ReturnValue = 3;
|
||||
ScopeUnknown = 4;
|
||||
}
|
||||
|
||||
enum DapSourcePresentationHint {
|
||||
SourceNormal = 0;
|
||||
Emphasize = 1;
|
||||
Deemphasize = 2;
|
||||
SourceUnknown = 3;
|
||||
}
|
||||
|
||||
enum DapStackPresentationHint {
|
||||
StackNormal = 0;
|
||||
Label = 1;
|
||||
Subtle = 2;
|
||||
StackUnknown = 3;
|
||||
}
|
||||
|
||||
message DapModule {
|
||||
DapModuleId id = 1;
|
||||
string name = 2;
|
||||
optional string path = 3;
|
||||
optional bool is_optimized = 4;
|
||||
optional bool is_user_code = 5;
|
||||
optional string version = 6;
|
||||
optional string symbol_status = 7;
|
||||
optional string symbol_file_path = 8;
|
||||
optional string date_time_stamp = 9;
|
||||
optional string address_range = 10;
|
||||
}
|
||||
|
||||
message DapModuleId {
|
||||
oneof id {
|
||||
uint32 number = 1;
|
||||
string string = 2;
|
||||
}
|
||||
}
|
||||
|
||||
// Remote FS
|
||||
|
||||
message AddWorktree {
|
||||
|
||||
Reference in New Issue
Block a user