@@ -0,0 +1,114 @@
1+use helix_dap::{Client, Event, OutputEventBody, Result, SourceBreakpoint, StoppedEventBody};
2+use serde::{Deserialize, Serialize};
3+use serde_json::from_value;
4+use tokio::sync::mpsc::Receiver;
6+#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
7+#[serde(rename_all = "camelCase")]
8+struct LaunchArguments {
13+async fn output(mut output_event: Receiver<Event>) {
14+ let body: OutputEventBody =
15+ from_value(output_event.recv().await.unwrap().body.unwrap()).unwrap();
18+ body.category.unwrap_or("unknown".to_owned()),
24+pub async fn main() -> Result<()> {
25+ let base_config = fern::Dispatch::new().level(log::LevelFilter::Info);
27+ let stderr_config = fern::Dispatch::new()
28+ .format(|out, message, record| out.finish(format_args!("[{}] {}", record.level(), message)))
29+ .chain(std::io::stderr());
32+ .chain(stderr_config)
34+ .expect("Failed to set up logging");
36+ let client = Client::tcp("127.0.0.1:7777".parse::<std::net::SocketAddr>().unwrap(), 0).await;
37+ println!("create: {:?}", client);
38+ let mut client = client?;
40+ let output_event = client.listen_for_event("output".to_owned()).await;
41+ tokio::spawn(output(output_event));
43+ println!("init: {:?}", client.initialize("lldb".to_owned()).await);
44+ println!("caps: {:?}", client.capabilities());
46+ let args = LaunchArguments {
47+ program: "/tmp/cdebug/main".to_owned(),
48+ console: "internalConsole".to_owned(),
51+ println!("launch: {:?}", client.launch(args).await);
54+ "breakpoints: {:#?}",
57+ "/tmp/cdebug/main.c".to_owned(),
58+ vec![SourceBreakpoint {
69+ let mut _in = String::new();
72+ .expect("Failed to read line");
74+ let mut stopped_event = client.listen_for_event("stopped".to_owned()).await;
76+ println!("configurationDone: {:?}", client.configuration_done().await);
78+ let stop: StoppedEventBody =
79+ from_value(stopped_event.recv().await.unwrap().body.unwrap()).unwrap();
80+ println!("stopped: {:?}", stop);
82+ let threads = client.threads().await?;
83+ println!("threads: {:#?}", threads);
85+ .stack_trace(threads[2].id)
87+ .expect("expected stack trace");
88+ println!("stack trace: {:#?}", bt);
92+ .expect("expected scopes for thread");
93+ println!("scopes: {:#?}", scopes);
96+ client.variables(scopes[1].variables_reference).await
99+ let mut _in = String::new();
101+ .read_line(&mut _in)
102+ .expect("Failed to read line");
104+ println!("continued: {:?}", client.continue_thread(0).await);
106+ let mut _in = String::new();
108+ .read_line(&mut _in)
109+ .expect("Failed to read line");
111+ println!("disconnect: {:?}", client.disconnect().await);