From 710b7f10fab74dc704ddc1d54399afe27d83ecb4 Mon Sep 17 00:00:00 2001 From: ridethepig Date: Mon, 6 Mar 2023 11:29:08 +0800 Subject: [PATCH] Milestone4 --- proj-1/deet/src/debugger.rs | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/proj-1/deet/src/debugger.rs b/proj-1/deet/src/debugger.rs index 055f8b8..cda999e 100644 --- a/proj-1/deet/src/debugger.rs +++ b/proj-1/deet/src/debugger.rs @@ -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); }