Milestone4

This commit is contained in:
ridethepig 2023-03-06 11:29:08 +08:00
parent acdea334d5
commit 710b7f10fa

View File

@ -1,8 +1,8 @@
use crate::debugger_command::DebuggerCommand;
use crate::dwarf_data::{DwarfData, Error as DwarfError};
use crate::inferior::{Inferior, Status};
use rustyline::error::ReadlineError;
use rustyline::Editor;
use crate::dwarf_data::{DwarfData, Error as DwarfError};
pub struct Debugger {
target: String,
@ -73,12 +73,20 @@ impl Debugger {
self.inferior = None
}
Status::Signaled(_) => (),
Status::Stopped(_signal, _) => {
Status::Stopped(_signal, _rip) => {
println!("Child stopped (signal {})", _signal);
let file_line = self.debug_data.get_line_from_addr(_rip).unwrap_or(
crate::dwarf_data::Line {
file: String::from("Unknown"),
number: 0,
address: 0,
},
);
println!("Stopped at {}[rip={:#x}]", file_line, _rip);
}
}
} else {
eprintln!("Error running(continue) subprocess");
eprintln!("Error running subprocess");
}
} else {
println!("Error starting subprocess");
@ -103,16 +111,28 @@ impl Debugger {
self.inferior = None
}
Status::Signaled(_) => (),
Status::Stopped(_signal, _) => {
Status::Stopped(_signal, _rip) => {
println!("Child stopped (signal {})", _signal);
let file_line = self.debug_data.get_line_from_addr(_rip).unwrap_or(
crate::dwarf_data::Line {
file: String::from("Unknown"),
number: 0,
address: 0,
},
);
println!("Stopped at {}[rip={:#x}]", file_line, _rip);
}
}
} else {
eprintln!("Error running(continue) subprocess");
eprintln!("Error continuing subprocess");
}
}
DebuggerCommand::Backtrace => {
let res = self.inferior.as_ref().unwrap().print_backtrace(&self.debug_data);
let res = self
.inferior
.as_ref()
.unwrap()
.print_backtrace(&self.debug_data);
if let Err(res) = res {
eprintln!("Error backtracing: {}", res);
}