debugger: Add stack frame multibuffer (#30395)

This PR adds the ability to expand a debugger stack trace into a multi
buffer and view each frame as it's own excerpt.

Release Notes:

- N/A

---------

Co-authored-by: Remco Smits <djsmits12@gmail.com>
This commit is contained in:
Anthony Eid 2025-05-13 16:55:05 +02:00 committed by GitHub
parent 6f297132b4
commit 68afe4fdda
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 604 additions and 37 deletions

View file

@ -1,6 +1,6 @@
pub mod running;
use std::sync::OnceLock;
use std::{cell::OnceCell, sync::OnceLock};
use dap::client::SessionId;
use gpui::{
@ -17,15 +17,16 @@ use workspace::{
item::{self, Item},
};
use crate::{debugger_panel::DebugPanel, persistence::SerializedLayout};
use crate::{StackTraceView, debugger_panel::DebugPanel, persistence::SerializedLayout};
pub struct DebugSession {
remote_id: Option<workspace::ViewId>,
running_state: Entity<RunningState>,
label: OnceLock<SharedString>,
stack_trace_view: OnceCell<Entity<StackTraceView>>,
_debug_panel: WeakEntity<DebugPanel>,
_worktree_store: WeakEntity<WorktreeStore>,
_workspace: WeakEntity<Workspace>,
workspace: WeakEntity<Workspace>,
_subscriptions: [Subscription; 1],
}
@ -66,8 +67,9 @@ impl DebugSession {
running_state,
label: OnceLock::new(),
_debug_panel,
stack_trace_view: OnceCell::new(),
_worktree_store: project.read(cx).worktree_store().downgrade(),
_workspace: workspace,
workspace,
})
}
@ -75,6 +77,32 @@ impl DebugSession {
self.running_state.read(cx).session_id()
}
pub(crate) fn stack_trace_view(
&mut self,
project: &Entity<Project>,
window: &mut Window,
cx: &mut Context<Self>,
) -> &Entity<StackTraceView> {
let workspace = self.workspace.clone();
let running_state = self.running_state.clone();
self.stack_trace_view.get_or_init(|| {
let stackframe_list = running_state.read(cx).stack_frame_list().clone();
let stack_frame_view = cx.new(|cx| {
StackTraceView::new(
workspace.clone(),
project.clone(),
stackframe_list,
window,
cx,
)
});
stack_frame_view
})
}
pub fn session(&self, cx: &App) -> Entity<Session> {
self.running_state.read(cx).session().clone()
}