diff --git a/Cargo.lock b/Cargo.lock index 3fa191e..d1d630a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -715,6 +715,7 @@ dependencies = [ "bytes", "ckb-gdb-remote-protocol", "ckb-vm", + "env_logger 0.4.3", "gdbstub", "gdbstub_arch", "libc", diff --git a/ckb-debugger/Cargo.toml b/ckb-debugger/Cargo.toml index 3cbff9a..6ff9feb 100644 --- a/ckb-debugger/Cargo.toml +++ b/ckb-debugger/Cargo.toml @@ -24,8 +24,8 @@ ckb-vm-debug-utils = { path = "../ckb-vm-debug-utils", version = "0.117.0" } ckb-vm-pprof = { path = "../ckb-vm-pprof", version = "0.117.0" } env_logger = "0.4.3" ckb-gdb-remote-protocol = { path = "../ckb-gdb-remote-protocol", version = "0.117.0" } -gdbstub = "0.6.6" -gdbstub_arch = "0.2.4" +gdbstub = "0.7" +gdbstub_arch = "0.3" hex = "0.4" lazy_static = "1.4.0" libc = "0.2.132" diff --git a/ckb-debugger/src/main.rs b/ckb-debugger/src/main.rs index 9168d8c..4dd1cc5 100644 --- a/ckb-debugger/src/main.rs +++ b/ckb-debugger/src/main.rs @@ -447,7 +447,7 @@ fn main() -> Result<(), Box> { use ckb_vm_debug_utils::{GdbStubHandler, GdbStubHandlerEventLoop}; use gdbstub::{ conn::ConnectionExt, - stub::{DisconnectReason, GdbStub, GdbStubError}, + stub::{DisconnectReason, GdbStub}, }; use gdbstub_arch::riscv::Riscv64; let mut h: GdbStubHandler<_, Riscv64> = GdbStubHandler::new(machine); @@ -466,9 +466,6 @@ fn main() -> Result<(), Box> { } DisconnectReason::Kill => Err(Error::External("GDB sent a kill command!".to_string())), }, - Err(GdbStubError::TargetError(e)) => { - Err(Error::External(format!("target encountered a fatal error: {}", e))) - } Err(e) => Err(Error::External(format!("gdbstub encountered a fatal error: {}", e))), }; match result { diff --git a/ckb-gdb-remote-protocol/examples/noop-server.rs b/ckb-gdb-remote-protocol/examples/noop-server.rs index 12c217a..057333d 100644 --- a/ckb-gdb-remote-protocol/examples/noop-server.rs +++ b/ckb-gdb-remote-protocol/examples/noop-server.rs @@ -1,4 +1,4 @@ -use gdb_remote_protocol::{process_packets_from, Error, Handler, ProcessType, StopReason}; +use ckb_gdb_remote_protocol::{process_packets_from, Error, Handler, ProcessType, StopReason}; use std::net::TcpListener; struct NoopHandler; diff --git a/ckb-gdb-remote-protocol/tests/integration.rs b/ckb-gdb-remote-protocol/tests/integration.rs index 12b608a..270b792 100644 --- a/ckb-gdb-remote-protocol/tests/integration.rs +++ b/ckb-gdb-remote-protocol/tests/integration.rs @@ -14,7 +14,7 @@ extern crate log; use assert_cli::Assert; -use gdb_remote_protocol::{process_packets_from, Error, Handler, ProcessType, StopReason}; +use ckb_gdb_remote_protocol::{process_packets_from, Error, Handler, ProcessType, StopReason}; use std::net::TcpListener; use std::thread; diff --git a/ckb-vm-debug-utils/Cargo.toml b/ckb-vm-debug-utils/Cargo.toml index 5d1d525..634bc5b 100644 --- a/ckb-vm-debug-utils/Cargo.toml +++ b/ckb-vm-debug-utils/Cargo.toml @@ -18,5 +18,6 @@ ckb-gdb-remote-protocol = { path = "../ckb-gdb-remote-protocol", version = "0.11 libc = { version = "0.2.47", optional = true } log = "0.4.0" nix = { version = "0.26.2", optional = true } -gdbstub = "0.6.6" -gdbstub_arch = "0.2.4" +gdbstub = "0.7" +gdbstub_arch = "0.3" +env_logger = "0.4.3" diff --git a/ckb-vm-debug-utils/examples/gdb_remote_protocol_debugger.rs b/ckb-vm-debug-utils/examples/gdb_remote_protocol_debugger.rs index 6ab0c9e..7786111 100644 --- a/ckb-vm-debug-utils/examples/gdb_remote_protocol_debugger.rs +++ b/ckb-vm-debug-utils/examples/gdb_remote_protocol_debugger.rs @@ -10,7 +10,7 @@ use ckb_vm::{ use ckb_vm_debug_utils::GdbHandler; #[cfg(feature = "stdio")] use ckb_vm_debug_utils::Stdio; -use gdb_remote_protocol::process_packets_from; +use ckb_gdb_remote_protocol::process_packets_from; use std::env; use std::fs::File; use std::io::Read; diff --git a/ckb-vm-debug-utils/src/gdbstub.rs b/ckb-vm-debug-utils/src/gdbstub.rs index 58d6099..9cffb39 100644 --- a/ckb-vm-debug-utils/src/gdbstub.rs +++ b/ckb-vm-debug-utils/src/gdbstub.rs @@ -6,7 +6,7 @@ use ckb_vm::{ Bytes, Error, Memory, Register, }; use gdbstub::{ - arch::{Arch, SingleStepGdbBehavior}, + arch::Arch, common::Signal, conn::{Connection, ConnectionExt}, stub::{ @@ -179,7 +179,18 @@ impl { + continue_step = false; + } + _ => {} + }; + + if !continue_step { + break event; + } } executed_cycles += 1; @@ -229,10 +240,6 @@ impl< fn support_catch_syscalls(&mut self) -> Option> { Some(self) } - - fn guard_rail_single_step_gdb_behavior(&self) -> SingleStepGdbBehavior { - SingleStepGdbBehavior::Optional - } } impl< @@ -258,7 +265,7 @@ impl< Ok(()) } - fn read_addrs(&mut self, start_addr: ::Usize, data: &mut [u8]) -> TargetResult<(), Self> { + fn read_addrs(&mut self, start_addr: ::Usize, data: &mut [u8]) -> TargetResult { for i in 0..data.len() { data[i] = self .machine @@ -267,7 +274,7 @@ impl< .map_err(TargetError::Fatal)? .to_u8(); } - Ok(()) + Ok(data.len()) } fn write_addrs(&mut self, start_addr: ::Usize, data: &[u8]) -> TargetResult<(), Self> {