Skip to content

Instantly share code, notes, and snippets.

@Mistobaan
Created November 12, 2024 06:11
Show Gist options
  • Save Mistobaan/be50d12061b2a2c633c14b6050f39ba9 to your computer and use it in GitHub Desktop.
Save Mistobaan/be50d12061b2a2c633c14b6050f39ba9 to your computer and use it in GitHub Desktop.
How to debug Zed with Zed

Overview

A descriptio of all the steps to be able to debug Zed using Zed. This is useful if you want to add features and fix errors within the Zed codebase using Zed itself.

1. Compile Debugger Branch

First you need to download and compile the debugger branch:

$ cd zed
$ git checkout pull/13433/head

Assuming you have followed the Building Zed instructions

you should be able to run:

$ cargo run --profile release-fast

This now will be your ned zed editor environment. You have to use this app and not your default zed editor for the following commands to work.

2. Configure the Zed Project folder

Open your zed codebase (this folder should be different from the prevoius checked out debugger codebase to avoid confusion).

CTRL+O

create a new debug.json file inside the project $ZED_ROOT/.zed/debug.json:

[
  {
    "label": "Zed debugger",
    "adapter": "lldb",
    "program": "$ZED_WORKTREE_ROOT/target/debug/zed"
  }
]

make sure you have lldb and rust-analyzer installed.

# on macosx
$ brew install lldb rust-analyzer

3. Run the debugger

Add a breakpoint by clicking on the gutter of rust file:

image

Show the task selection dialog with

CTRL+ALT+P

and select debugger:start (type debug to autocomplete)

image

After a while you should see a panel like this (as of Nov 2024). Notice that the console is giving us some warnings. image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment