Skip to content

Auto-detect Rust for CodeLLDB panic breakpoints#48236

Merged
Anthony-Eid merged 2 commits intozed-industries:mainfrom
littleKitchen:fix-rust-panic-breakpoints
Feb 4, 2026
Merged

Auto-detect Rust for CodeLLDB panic breakpoints#48236
Anthony-Eid merged 2 commits intozed-industries:mainfrom
littleKitchen:fix-rust-panic-breakpoints

Conversation

@littleKitchen
Copy link
Contributor

@littleKitchen littleKitchen commented Feb 3, 2026

Fixes #48231

Problem

When debugging Rust programs with CodeLLDB, panic breakpoints ("Rust: on panic") don't work unless sourceLanguages: ["rust"] is explicitly set in the debug configuration.

Without this setting, CodeLLDB doesn't return the rust_panic exception filter, so the breakpoint shows locations = 0 (pending) and never triggers.

Root Cause

The Cargo locator correctly adds sourceLanguages: ["rust"] (cargo.rs:97-100), but other code paths may not:

  • VSCode launch.json imports
  • Manual debug configurations

Solution

Auto-detect Rust binaries in CodeLldbDebugAdapter::get_binary() by checking if the program path contains /target/debug/ or /target/release/ (Cargo's standard output directories).

If detected and sourceLanguages isn't already set, we automatically add ["rust"].

Release Notes:

  • Fixed Rust panic breakpoints not working in debugger when using CodeLLDB with non-Cargo debug configurations

Fixes zed-industries#48231

When debugging Rust programs with CodeLLDB, panic breakpoints require
`sourceLanguages: ["rust"]` to be set. Without this, CodeLLDB doesn't
return the `rust_panic` exception filter, so the "Rust: on panic"
breakpoint never resolves.

The Cargo locator already sets this correctly, but other code paths
(VSCode launch.json imports, manual configs) may not include it.

This fix auto-detects Rust binaries by checking if the program path
contains `/target/debug/` or `/target/release/` (Cargo's output dirs).
If detected and `sourceLanguages` isn't already set, we add it
automatically.

Release Notes:
- Fixed Rust panic breakpoints not working in debugger when using
  CodeLLDB with non-Cargo debug configurations
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 3, 2026
@maxdeviant maxdeviant changed the title fix: auto-detect Rust for CodeLLDB panic breakpoints Auto-detect Rust for CodeLLDB panic breakpoints Feb 3, 2026
Copy link
Member

@osiewicz osiewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine to me. I have a vague recollection that CodeLLDB does not like having superfluous sourceLanguages set (we started out with sourceLanguages: [cpp, rust] for sure), but since this can be opted out of by just setting the languages explicitly it should be ok.

@Anthony-Eid Anthony-Eid merged commit e27924a into zed-industries:main Feb 4, 2026
27 checks passed
adb-sh pushed a commit to adb-sh/zed that referenced this pull request Feb 5, 2026
Fixes zed-industries#48231

## Problem
When debugging Rust programs with CodeLLDB, panic breakpoints ("Rust: on
panic") don't work unless `sourceLanguages: ["rust"]` is explicitly set
in the debug configuration.

Without this setting, CodeLLDB doesn't return the `rust_panic` exception
filter, so the breakpoint shows `locations = 0 (pending)` and never
triggers.

## Root Cause
The Cargo locator correctly adds `sourceLanguages: ["rust"]`
([cargo.rs:97-100](https://github.com/zed-industries/zed/blob/main/crates/project/src/debugger/locators/cargo.rs#L97-L100)),
but other code paths may not:
- VSCode launch.json imports
- Manual debug configurations

## Solution
Auto-detect Rust binaries in `CodeLldbDebugAdapter::get_binary()` by
checking if the program path contains `/target/debug/` or
`/target/release/` (Cargo's standard output directories).

If detected and `sourceLanguages` isn't already set, we automatically
add `["rust"]`.

Release Notes:

- Fixed Rust panic breakpoints not working in debugger when using
CodeLLDB with non-Cargo debug configurations
rtfeldman pushed a commit that referenced this pull request Feb 5, 2026
Fixes #48231

## Problem
When debugging Rust programs with CodeLLDB, panic breakpoints ("Rust: on
panic") don't work unless `sourceLanguages: ["rust"]` is explicitly set
in the debug configuration.

Without this setting, CodeLLDB doesn't return the `rust_panic` exception
filter, so the breakpoint shows `locations = 0 (pending)` and never
triggers.

## Root Cause
The Cargo locator correctly adds `sourceLanguages: ["rust"]`
([cargo.rs:97-100](https://github.com/zed-industries/zed/blob/main/crates/project/src/debugger/locators/cargo.rs#L97-L100)),
but other code paths may not:
- VSCode launch.json imports
- Manual debug configurations

## Solution
Auto-detect Rust binaries in `CodeLldbDebugAdapter::get_binary()` by
checking if the program path contains `/target/debug/` or
`/target/release/` (Cargo's standard output directories).

If detected and `sourceLanguages` isn't already set, we automatically
add `["rust"]`.

Release Notes:

- Fixed Rust panic breakpoints not working in debugger when using
CodeLLDB with non-Cargo debug configurations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rust debugger doesn't break on panics

3 participants