From 9822c95c37ac2d9c0829d080d8a83cd8bacaae4c Mon Sep 17 00:00:00 2001 From: Elnath Date: Sun, 18 May 2025 23:37:09 +0200 Subject: [PATCH] Added breakpoint reset to cont_syscall as well --- src/debug_target/stopped_target.rs | 5 ++++- src/main.rs | 9 +++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/debug_target/stopped_target.rs b/src/debug_target/stopped_target.rs index 15311e8..a89ab10 100644 --- a/src/debug_target/stopped_target.rs +++ b/src/debug_target/stopped_target.rs @@ -54,7 +54,10 @@ impl StoppedTarget { Ok(self.to_running()) } - pub fn cont_syscall(self) -> Result { + pub fn cont_syscall(mut self) -> Result { + if self.on_breakpoint()? { + self.breakpoint_remove_and_rewind()?; + } nix::sys::ptrace::syscall(self.pid, None).map_err(PTraceError)?; Ok(self.to_running()) } diff --git a/src/main.rs b/src/main.rs index e2daf01..b9f96d1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -57,7 +57,7 @@ fn main() -> color_eyre::Result<()> { let mut target = StoppedTarget::new(child_pid)?; println!("✔️ Child ready!"); - let breakpoint1 = 0x401019; + let breakpoint1 = 0x40101b; println!("🛑 Adding breakpoint at {breakpoint1:#x}"); target.add_breakpoint(breakpoint1)?; let target = target.cont()?.wait_for_something()?; @@ -67,17 +67,14 @@ fn main() -> color_eyre::Result<()> { println!("🚧 We are on a breakpoint!") } println!("🔎 rip: {:#x}", t.get_registers()?.rip); - single_step_all(t)?; + // single_step_all(t)?; + strace(t)?; } Either::Right(ExitedTarget { exit_code, .. }) => { println!("👋 Child exited with code {exit_code}"); } } Ok(()) - - - // single_step_all(target) - // strace(target) } Err(e) => { println!("❌ Fork failed: {e}");