Home Explore Blog CI



zed

1st chunk of `docs/src/development/debuggers.md`
50c90ccac385ef67ee2baa16eb1a441bf4410ab8863bb0420000000100000c6a
# Using a debugger

> **DISCLAIMER**: This is not documentation for the [planned debugger support in Zed](https://github.com/zed-industries/zed/issues/5065).
> Rather, it is intended to provide information on how to use an external debugger while developing Zed itself to both Zed employees and external contributors.
> Once debugger support is implemented, this section will be updated to provide information on how to use the built-in debugger as part of Zed development.

## Build profile considerations

By default, builds using the dev and release profiles (release is the profile used for production builds, i.e. nightly, preview, and stable) include limited debug info.

This is done by setting the `profile.(release|dev).debug` field in the root `Cargo.toml` field to `"limited"`.

The official documentation for the `debug` field can be found [here](https://doc.rust-lang.org/cargo/reference/profiles.html#debug).
But the TLDR is that `"limited"` strips type and variable level debug info.

In release builds, this is done to reduce the binary size, as type and variable level debug info is not required, and does not impact the usability of generated stack traces.

In debug builds, this is done to reduce compilation (especially incremental compilation) time.

However, while the type and variable level debug info is not required for good stack traces, it is very important for a good experience using debuggers,
as without the type and variable level debug info, the debugger has no way to resolve local variables, inspect them, format them using pretty-printers, etc.

Therefore, in order to use a debugger to it's fullest extent, you must compile a new Zed binary, with full debug info.

The simplest way to do this, is to use the `--config` flag to override the `debug` field in the root `Cargo.toml` file when running `cargo run` or `cargo build` like so:

```sh
cargo run --config 'profile.dev.debug="full"'
cargo build --config 'profile.dev.debug="full"'
```

> If you wish to avoid passing the `--config` flag on every invocation of `cargo`. You may also change the section in the [root `Cargo.toml`](https://github.com/zed-industries/zed/blob/main/Cargo.toml)
>
> from
>
> ```toml
> [profile.dev]
> debug = "limited"
> ```
>
> to
>
> ```toml
> [profile.dev]
> debug = "full"
> ```
>
> This will ensure all invocations of `cargo run` or `cargo build` will compile with full debug info.
>
> **WARNING:** Make sure to avoid committing these changes!

## GDB/LLDB

### Background

When installing rust through rustup, (the recommended way to do so when developing Zed, see the documentation for getting started on your platform [here](../development.md))
a few additional scripts are installed and put on your path to assist with debugging binaries compiled with rust.

These are `rust-gdb` and `rust-lldb` respectively.

You can read more information about these scripts and why they are useful [here](https://michaelwoerister.github.io/2015/03/27/rust-xxdb.html) if you are interested.

However, the summary is that they are simple shell scripts that wrap the standard `gdb` and `lldb` commands, injecting the relevant commands and flags to enable additional

Title: Using a Debugger in Zed Development
Summary
This section provides instructions on using an external debugger for Zed development, as Zed's built-in debugger is still in development. It emphasizes the importance of compiling Zed with full debug info by setting `profile.dev.debug` to `"full"` in `Cargo.toml` to enable proper variable inspection in the debugger. It also introduces `rust-gdb` and `rust-lldb`, scripts that enhance the standard `gdb` and `lldb` debuggers with Rust-specific features.