debugger: Fix gdb adapter and logger (#28280)
There were two bugs that caused the gdb adapter not to work properly, one on our end and one their end. The bug on our end was sending `stopOnEntry: null` in our launch request when stop on entry had no value. I fixed that bug across all dap adapters The other bug had to do with python's "great" type system and how we serialized our unit structs to json; mainly, `ConfigurationDoneArguments` and `ThreadsArguments`. Gdb seems to follow a pattern for handling requests where they pass `**args` to a function, this errors out when the equivalent json is `"arguments": null`. ```py @capability("supportsConfigurationDoneRequest") @request("configurationDone", on_dap_thread=True) def config_done(**args): ### BUG!! ... ``` Release Notes: - N/A
This commit is contained in:
parent
56ed5dcc89
commit
862d0c07ca
13 changed files with 120 additions and 64 deletions
|
@ -10,7 +10,7 @@ use super::dap_command::{
|
|||
VariablesCommand,
|
||||
};
|
||||
use super::dap_store::DapAdapterDelegate;
|
||||
use anyhow::{Result, anyhow};
|
||||
use anyhow::{Context as _, Result, anyhow};
|
||||
use collections::{HashMap, HashSet, IndexMap, IndexSet};
|
||||
use dap::adapters::{DebugAdapter, DebugAdapterBinary};
|
||||
use dap::messages::Response;
|
||||
|
@ -190,7 +190,7 @@ impl LocalMode {
|
|||
delegate: DapAdapterDelegate,
|
||||
messages_tx: futures::channel::mpsc::UnboundedSender<Message>,
|
||||
cx: AsyncApp,
|
||||
) -> Task<Result<(Self, Capabilities)>> {
|
||||
) -> Task<Result<Self>> {
|
||||
Self::new_inner(
|
||||
debug_adapters,
|
||||
session_id,
|
||||
|
@ -214,7 +214,7 @@ impl LocalMode {
|
|||
caps: Capabilities,
|
||||
fail: bool,
|
||||
cx: AsyncApp,
|
||||
) -> Task<Result<(Self, Capabilities)>> {
|
||||
) -> Task<Result<Self>> {
|
||||
use task::DebugRequestDisposition;
|
||||
|
||||
let request = match config.request.clone() {
|
||||
|
@ -349,7 +349,7 @@ impl LocalMode {
|
|||
messages_tx: futures::channel::mpsc::UnboundedSender<Message>,
|
||||
on_initialized: impl AsyncFnOnce(&mut LocalMode, AsyncApp) + 'static,
|
||||
cx: AsyncApp,
|
||||
) -> Task<Result<(Self, Capabilities)>> {
|
||||
) -> Task<Result<Self>> {
|
||||
cx.spawn(async move |cx| {
|
||||
let (adapter, binary) =
|
||||
Self::get_adapter_binary(®istry, &config, &delegate, cx).await?;
|
||||
|
@ -374,11 +374,11 @@ impl LocalMode {
|
|||
message_handler,
|
||||
cx.clone(),
|
||||
)
|
||||
.await?
|
||||
.await
|
||||
.with_context(|| "Failed to start communication with debug adapter")?
|
||||
},
|
||||
);
|
||||
|
||||
let adapter_id = adapter.name().to_string().to_owned();
|
||||
let mut session = Self {
|
||||
client,
|
||||
adapter,
|
||||
|
@ -387,11 +387,8 @@ impl LocalMode {
|
|||
};
|
||||
|
||||
on_initialized(&mut session, cx.clone()).await;
|
||||
let capabilities = session
|
||||
.request(Initialize { adapter_id }, cx.background_executor().clone())
|
||||
.await?;
|
||||
|
||||
Ok((session, capabilities))
|
||||
Ok(session)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -541,6 +538,12 @@ impl LocalMode {
|
|||
self.config.label.clone()
|
||||
}
|
||||
|
||||
fn request_initialization(&self, cx: &App) -> Task<Result<Capabilities>> {
|
||||
let adapter_id = self.adapter.name().to_string();
|
||||
|
||||
self.request(Initialize { adapter_id }, cx.background_executor().clone())
|
||||
}
|
||||
|
||||
fn initialize_sequence(
|
||||
&self,
|
||||
capabilities: &Capabilities,
|
||||
|
@ -590,7 +593,7 @@ impl LocalMode {
|
|||
cx.update(|cx| this.send_all_breakpoints(false, cx))?.await;
|
||||
|
||||
if configuration_done_supported {
|
||||
this.request(ConfigurationDone, cx.background_executor().clone())
|
||||
this.request(ConfigurationDone {}, cx.background_executor().clone())
|
||||
} else {
|
||||
Task::ready(Ok(()))
|
||||
}
|
||||
|
@ -849,7 +852,7 @@ impl Session {
|
|||
let (message_tx, message_rx) = futures::channel::mpsc::unbounded();
|
||||
|
||||
cx.spawn(async move |cx| {
|
||||
let (mode, capabilities) = LocalMode::new(
|
||||
let mode = LocalMode::new(
|
||||
debug_adapters,
|
||||
session_id,
|
||||
parent_session.clone(),
|
||||
|
@ -870,7 +873,6 @@ impl Session {
|
|||
initialized_tx,
|
||||
message_rx,
|
||||
mode,
|
||||
capabilities,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
|
@ -893,7 +895,7 @@ impl Session {
|
|||
let (message_tx, message_rx) = futures::channel::mpsc::unbounded();
|
||||
|
||||
cx.spawn(async move |cx| {
|
||||
let (mode, capabilities) = LocalMode::new_fake(
|
||||
let mode = LocalMode::new_fake(
|
||||
session_id,
|
||||
parent_session.clone(),
|
||||
breakpoint_store.clone(),
|
||||
|
@ -915,7 +917,6 @@ impl Session {
|
|||
initialized_tx,
|
||||
message_rx,
|
||||
mode,
|
||||
capabilities,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
|
@ -1007,6 +1008,25 @@ impl Session {
|
|||
}
|
||||
}
|
||||
|
||||
pub(super) fn request_initialize(&mut self, cx: &mut Context<Self>) -> Task<Result<()>> {
|
||||
match &self.mode {
|
||||
Mode::Local(local_mode) => {
|
||||
let capabilities = local_mode.clone().request_initialization(cx);
|
||||
|
||||
cx.spawn(async move |this, cx| {
|
||||
let capabilities = capabilities.await?;
|
||||
this.update(cx, |session, _| {
|
||||
session.capabilities = capabilities;
|
||||
})?;
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
Mode::Remote(_) => Task::ready(Err(anyhow!(
|
||||
"Cannot send initialize request from remote session"
|
||||
))),
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn initialize_sequence(
|
||||
&mut self,
|
||||
initialize_rx: oneshot::Receiver<()>,
|
||||
|
@ -1947,7 +1967,6 @@ fn create_local_session(
|
|||
initialized_tx: oneshot::Sender<()>,
|
||||
mut message_rx: futures::channel::mpsc::UnboundedReceiver<Message>,
|
||||
mode: LocalMode,
|
||||
capabilities: Capabilities,
|
||||
cx: &mut Context<Session>,
|
||||
) -> Session {
|
||||
let _background_tasks = vec![cx.spawn(async move |this: WeakEntity<Session>, cx| {
|
||||
|
@ -2003,7 +2022,7 @@ fn create_local_session(
|
|||
child_session_ids: HashSet::default(),
|
||||
parent_id: parent_session.map(|session| session.read(cx).id),
|
||||
variables: Default::default(),
|
||||
capabilities,
|
||||
capabilities: Capabilities::default(),
|
||||
thread_states: ThreadStates::default(),
|
||||
output_token: OutputToken(0),
|
||||
ignore_breakpoints: false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue