mirror of
https://github.com/SpaceManiac/SpacemanDMM.git
synced 2025-12-23 05:36:47 +00:00
Show stdout/stderr of launched process in Debug Console
This commit is contained in:
parent
8a07b193ae
commit
591b404075
1 changed files with 39 additions and 2 deletions
|
|
@ -57,8 +57,8 @@ impl Launched {
|
|||
.arg(dmb)
|
||||
.arg("-trusted")
|
||||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null());
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped());
|
||||
|
||||
match params {
|
||||
Some(EngineParams::Extools { port, dll }) => {
|
||||
|
|
@ -88,6 +88,9 @@ impl Launched {
|
|||
let seq2 = seq.clone();
|
||||
let mutex2 = mutex.clone();
|
||||
|
||||
pipe_output(seq.clone(), "stdout", child.stdout.take())?;
|
||||
pipe_output(seq.clone(), "stderr", child.stderr.take())?;
|
||||
|
||||
std::thread::Builder::new()
|
||||
.name("launched debuggee manager thread".to_owned())
|
||||
.spawn(move || {
|
||||
|
|
@ -154,6 +157,40 @@ impl Launched {
|
|||
}
|
||||
}
|
||||
|
||||
fn pipe_output<R: std::io::Read + Send + 'static>(seq: Arc<SequenceNumber>, keyword: &'static str, stream: Option<R>) -> std::io::Result<()> {
|
||||
guard!(let Some(stream2) = stream else { return Ok(()); });
|
||||
std::thread::Builder::new()
|
||||
.name(format!("launched debuggee {} relay", keyword))
|
||||
.spawn(move || {
|
||||
use std::io::BufRead;
|
||||
|
||||
let mut line = String::new();
|
||||
let mut buf_stream = std::io::BufReader::new(stream2);
|
||||
loop {
|
||||
line.clear();
|
||||
match buf_stream.read_line(&mut line) {
|
||||
Ok(0) => break,
|
||||
Ok(_) => {
|
||||
seq.issue_event(super::dap_types::OutputEvent {
|
||||
output: line.clone(),
|
||||
category: Some(keyword.to_owned()),
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
Err(e) => {
|
||||
seq.issue_event(super::dap_types::OutputEvent {
|
||||
output: format!("[launched {}] {}", keyword, e),
|
||||
category: Some("console".to_owned()),
|
||||
..Default::default()
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
mod raw {
|
||||
pub type Handle = i32;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue