compat: don't wait for launch and attach response
I could not get one from codelldb
This commit is contained in:
parent
e388079a0b
commit
d4c215b35d
1 changed files with 37 additions and 28 deletions
|
@ -12,6 +12,7 @@ use std::sync::{
|
||||||
use std::{collections::HashMap, process::Stdio};
|
use std::{collections::HashMap, process::Stdio};
|
||||||
use tokio::{
|
use tokio::{
|
||||||
io::{AsyncBufRead, AsyncWrite, BufReader, BufWriter},
|
io::{AsyncBufRead, AsyncWrite, BufReader, BufWriter},
|
||||||
|
join,
|
||||||
net::TcpStream,
|
net::TcpStream,
|
||||||
process::{Child, Command},
|
process::{Child, Command},
|
||||||
sync::{
|
sync::{
|
||||||
|
@ -449,7 +450,12 @@ impl Client {
|
||||||
self.request_counter.fetch_add(1, Ordering::Relaxed)
|
self.request_counter.fetch_add(1, Ordering::Relaxed)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn request(&self, command: String, arguments: Option<Value>) -> Result<Response> {
|
async fn request(
|
||||||
|
&self,
|
||||||
|
command: String,
|
||||||
|
arguments: Option<Value>,
|
||||||
|
response: bool,
|
||||||
|
) -> Result<Option<Response>> {
|
||||||
let (callback_rx, mut callback_tx) = channel(1);
|
let (callback_rx, mut callback_tx) = channel(1);
|
||||||
|
|
||||||
let req = Request {
|
let req = Request {
|
||||||
|
@ -464,10 +470,11 @@ impl Client {
|
||||||
.send(req)
|
.send(req)
|
||||||
.expect("Failed to send request to debugger");
|
.expect("Failed to send request to debugger");
|
||||||
|
|
||||||
callback_tx
|
if response {
|
||||||
.recv()
|
Ok(Some(callback_tx.recv().await.unwrap()?))
|
||||||
.await
|
} else {
|
||||||
.expect("Failed to receive response")
|
Ok(None)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn capabilities(&self) -> &DebuggerCapabilities {
|
pub fn capabilities(&self) -> &DebuggerCapabilities {
|
||||||
|
@ -494,25 +501,25 @@ impl Client {
|
||||||
};
|
};
|
||||||
|
|
||||||
let response = self
|
let response = self
|
||||||
.request("initialize".to_owned(), to_value(args).ok())
|
.request("initialize".to_owned(), to_value(args).ok(), true)
|
||||||
.await?;
|
.await?
|
||||||
|
.unwrap();
|
||||||
self.capabilities = from_value(response.body.unwrap()).ok();
|
self.capabilities = from_value(response.body.unwrap()).ok();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn disconnect(&mut self) -> Result<()> {
|
pub async fn disconnect(&mut self) -> Result<()> {
|
||||||
self.request("disconnect".to_owned(), None).await?;
|
self.request("disconnect".to_owned(), None, true).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn launch(&mut self, args: impl Serialize) -> Result<()> {
|
pub async fn launch(&mut self, args: impl Serialize) -> Result<()> {
|
||||||
let mut initialized = self.listen_for_event("initialized".to_owned()).await;
|
let mut initialized = self.listen_for_event("initialized".to_owned()).await;
|
||||||
|
|
||||||
self.request("launch".to_owned(), to_value(args).ok())
|
let res = self.request("launch".to_owned(), to_value(args).ok(), false);
|
||||||
.await?;
|
let ev = initialized.recv();
|
||||||
|
join!(res, ev).0?;
|
||||||
initialized.recv().await;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -520,10 +527,9 @@ impl Client {
|
||||||
pub async fn attach(&mut self, args: impl Serialize) -> Result<()> {
|
pub async fn attach(&mut self, args: impl Serialize) -> Result<()> {
|
||||||
let mut initialized = self.listen_for_event("initialized".to_owned()).await;
|
let mut initialized = self.listen_for_event("initialized".to_owned()).await;
|
||||||
|
|
||||||
self.request("attach".to_owned(), to_value(args).ok())
|
let res = self.request("attach".to_owned(), to_value(args).ok(), false);
|
||||||
.await?;
|
let ev = initialized.recv();
|
||||||
|
join!(res, ev).0?;
|
||||||
initialized.recv().await;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -549,15 +555,17 @@ impl Client {
|
||||||
};
|
};
|
||||||
|
|
||||||
let response = self
|
let response = self
|
||||||
.request("setBreakpoints".to_owned(), to_value(args).ok())
|
.request("setBreakpoints".to_owned(), to_value(args).ok(), true)
|
||||||
.await?;
|
.await?
|
||||||
|
.unwrap();
|
||||||
let body: Option<SetBreakpointsResponseBody> = from_value(response.body.unwrap()).ok();
|
let body: Option<SetBreakpointsResponseBody> = from_value(response.body.unwrap()).ok();
|
||||||
|
|
||||||
Ok(body.map(|b| b.breakpoints).unwrap())
|
Ok(body.map(|b| b.breakpoints).unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn configuration_done(&mut self) -> Result<()> {
|
pub async fn configuration_done(&mut self) -> Result<()> {
|
||||||
self.request("configurationDone".to_owned(), None).await?;
|
self.request("configurationDone".to_owned(), None, true)
|
||||||
|
.await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -565,8 +573,9 @@ impl Client {
|
||||||
let args = ContinueArguments { thread_id };
|
let args = ContinueArguments { thread_id };
|
||||||
|
|
||||||
let response = self
|
let response = self
|
||||||
.request("continue".to_owned(), to_value(args).ok())
|
.request("continue".to_owned(), to_value(args).ok(), true)
|
||||||
.await?;
|
.await?
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let body: Option<ContinueResponseBody> = from_value(response.body.unwrap()).ok();
|
let body: Option<ContinueResponseBody> = from_value(response.body.unwrap()).ok();
|
||||||
|
|
||||||
|
@ -585,8 +594,8 @@ impl Client {
|
||||||
};
|
};
|
||||||
|
|
||||||
let response = self
|
let response = self
|
||||||
.request("stackTrace".to_owned(), to_value(args).ok())
|
.request("stackTrace".to_owned(), to_value(args).ok(), true)
|
||||||
.await?;
|
.await?.unwrap();
|
||||||
|
|
||||||
let body: StackTraceResponseBody = from_value(response.body.unwrap()).unwrap();
|
let body: StackTraceResponseBody = from_value(response.body.unwrap()).unwrap();
|
||||||
|
|
||||||
|
@ -594,7 +603,7 @@ impl Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn threads(&mut self) -> Result<Vec<Thread>> {
|
pub async fn threads(&mut self) -> Result<Vec<Thread>> {
|
||||||
let response = self.request("threads".to_owned(), None).await?;
|
let response = self.request("threads".to_owned(), None, true).await?.unwrap();
|
||||||
|
|
||||||
let body: ThreadsResponseBody = from_value(response.body.unwrap()).unwrap();
|
let body: ThreadsResponseBody = from_value(response.body.unwrap()).unwrap();
|
||||||
|
|
||||||
|
@ -605,8 +614,8 @@ impl Client {
|
||||||
let args = ScopesArguments { frame_id };
|
let args = ScopesArguments { frame_id };
|
||||||
|
|
||||||
let response = self
|
let response = self
|
||||||
.request("scopes".to_owned(), to_value(args).ok())
|
.request("scopes".to_owned(), to_value(args).ok(), true)
|
||||||
.await?;
|
.await?.unwrap();
|
||||||
|
|
||||||
let body: ScopesResponseBody = from_value(response.body.unwrap()).unwrap();
|
let body: ScopesResponseBody = from_value(response.body.unwrap()).unwrap();
|
||||||
|
|
||||||
|
@ -623,8 +632,8 @@ impl Client {
|
||||||
};
|
};
|
||||||
|
|
||||||
let response = self
|
let response = self
|
||||||
.request("variables".to_owned(), to_value(args).ok())
|
.request("variables".to_owned(), to_value(args).ok(), true)
|
||||||
.await?;
|
.await?.unwrap();
|
||||||
|
|
||||||
let body: VariablesResponseBody = from_value(response.body.unwrap()).unwrap();
|
let body: VariablesResponseBody = from_value(response.body.unwrap()).unwrap();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue