2021-08-12 17:35:15 +04:00
|
|
|
use helix_dap::{Client, Result, SourceBreakpoint};
|
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
pub async fn main() -> Result<()> {
|
2021-08-12 17:45:01 +04:00
|
|
|
let base_config = fern::Dispatch::new().level(log::LevelFilter::Info);
|
|
|
|
|
|
|
|
let stderr_config = fern::Dispatch::new()
|
|
|
|
.format(|out, message, record| out.finish(format_args!("[{}] {}", record.level(), message)))
|
|
|
|
.chain(std::io::stderr());
|
|
|
|
|
|
|
|
base_config
|
|
|
|
.chain(stderr_config)
|
|
|
|
.apply()
|
|
|
|
.expect("Failed to set up logging");
|
|
|
|
|
2021-08-13 21:13:27 +04:00
|
|
|
let client = Client::tcp("127.0.0.1:7777".parse::<std::net::SocketAddr>().unwrap(), 0).await;
|
|
|
|
println!("create: {:?}", client);
|
|
|
|
let mut client = client?;
|
2021-08-12 17:35:15 +04:00
|
|
|
|
2021-08-13 21:18:15 +04:00
|
|
|
println!("init: {:?}", client.initialize("go".to_owned()).await);
|
2021-08-12 18:49:12 +04:00
|
|
|
println!("caps: {:#?}", client.capabilities());
|
2021-08-12 17:35:15 +04:00
|
|
|
println!(
|
|
|
|
"launch: {:?}",
|
|
|
|
client.launch("/tmp/godebug/main".to_owned()).await
|
|
|
|
);
|
|
|
|
|
|
|
|
println!(
|
2021-08-12 18:49:12 +04:00
|
|
|
"breakpoints: {:#?}",
|
2021-08-12 17:35:15 +04:00
|
|
|
client
|
|
|
|
.set_breakpoints(
|
|
|
|
"/tmp/godebug/main.go".to_owned(),
|
|
|
|
vec![SourceBreakpoint {
|
2021-08-12 21:47:14 +04:00
|
|
|
line: 8,
|
2021-08-12 17:35:15 +04:00
|
|
|
column: Some(2),
|
2021-08-12 22:23:55 +04:00
|
|
|
condition: None,
|
|
|
|
hit_condition: None,
|
|
|
|
log_message: None,
|
2021-08-12 17:35:15 +04:00
|
|
|
}]
|
|
|
|
)
|
|
|
|
.await
|
|
|
|
);
|
|
|
|
|
|
|
|
let mut _in = String::new();
|
|
|
|
std::io::stdin()
|
|
|
|
.read_line(&mut _in)
|
|
|
|
.expect("Failed to read line");
|
|
|
|
|
|
|
|
println!("configurationDone: {:?}", client.configuration_done().await);
|
|
|
|
println!("stopped: {:?}", client.wait_for_stopped().await);
|
2021-08-12 20:35:55 +04:00
|
|
|
println!("threads: {:#?}", client.threads().await);
|
2021-08-12 21:47:14 +04:00
|
|
|
let bt = client.stack_trace(1).await.expect("expected stack trace");
|
|
|
|
println!("stack trace: {:#?}", bt);
|
|
|
|
let scopes = client
|
|
|
|
.scopes(bt.0[0].id)
|
|
|
|
.await
|
|
|
|
.expect("expected scopes for thread");
|
|
|
|
println!("scopes: {:#?}", scopes);
|
|
|
|
println!(
|
|
|
|
"vars: {:#?}",
|
|
|
|
client.variables(scopes[1].variables_reference).await
|
|
|
|
);
|
2021-08-12 17:35:15 +04:00
|
|
|
|
|
|
|
let mut _in = String::new();
|
|
|
|
std::io::stdin()
|
|
|
|
.read_line(&mut _in)
|
|
|
|
.expect("Failed to read line");
|
|
|
|
|
|
|
|
println!("continued: {:?}", client.continue_thread(0).await);
|
|
|
|
|
|
|
|
let mut _in = String::new();
|
|
|
|
std::io::stdin()
|
|
|
|
.read_line(&mut _in)
|
|
|
|
.expect("Failed to read line");
|
|
|
|
|
|
|
|
println!("disconnect: {:?}", client.disconnect().await);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|