Verified Commit 1a4b1ac6 authored by jD91mZM2's avatar jD91mZM2

`cargo fmt`

parent 3476c15d
......@@ -44,6 +44,7 @@ dependencies = [
[[package]]
name = "gdb-remote-protocol"
version = "0.1.0"
source = "git+https://github.com/luser/rust-gdb-remote-protocol?rev=3e2f7c7204f85781f8b37d601217b05935547a7f#3e2f7c7204f85781f8b37d601217b05935547a7f"
dependencies = [
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"nom 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -55,7 +56,7 @@ dependencies = [
name = "gdbserver"
version = "0.1.0"
dependencies = [
"gdb-remote-protocol 0.1.0",
"gdb-remote-protocol 0.1.0 (git+https://github.com/luser/rust-gdb-remote-protocol?rev=3e2f7c7204f85781f8b37d601217b05935547a7f)",
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"structopt 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -249,6 +250,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd"
"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33"
"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9"
"checksum gdb-remote-protocol 0.1.0 (git+https://github.com/luser/rust-gdb-remote-protocol?rev=3e2f7c7204f85781f8b37d601217b05935547a7f)" = "<none>"
"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
"checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba"
"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
......
......@@ -5,8 +5,8 @@ authors = ["jD91mZM2 <me@krake.one>"]
edition = "2018"
[dependencies]
# gdb-remote-protocol = { git = "https://github.com/luser/rust-gdb-remote-protocol" }
gdb-remote-protocol = { path = "../external/rust-gdb-remote-protocol/" }
gdb-remote-protocol = { git = "https://github.com/luser/rust-gdb-remote-protocol", rev = "3e2f7c7204f85781f8b37d601217b05935547a7f" }
# gdb-remote-protocol = { path = "../external/rust-gdb-remote-protocol/" }
structopt = "0.2.18"
memchr = "2.2.1"
libc = "0.2.62"
use gdb_remote_protocol::{
Error,
Handler,
MemoryRegion,
ProcessType,
StopReason,
ThreadId,
VCont,
VContFeature,
Error, Handler, MemoryRegion, ProcessType, StopReason, ThreadId, VCont, VContFeature,
};
use structopt::StructOpt;
......@@ -63,20 +56,32 @@ impl Handler for App {
}
fn query_supported_vcont(&self) -> Result<Cow<'static, [VContFeature]>> {
Ok(Cow::Borrowed(&[
VContFeature::Continue, VContFeature::ContinueWithSignal,
VContFeature::Step, VContFeature::StepWithSignal,
VContFeature::Continue,
VContFeature::ContinueWithSignal,
VContFeature::Step,
VContFeature::StepWithSignal,
VContFeature::RangeStep,
]))
}
fn vcont(&self, actions: Vec<(VCont, Option<ThreadId>)>) -> Result<StopReason> {
if let Some((cmd, _id)) = actions.first() {
match *cmd {
VCont::Continue => { self.tracee.cont(None)?; },
VCont::ContinueWithSignal(signal) => { self.tracee.cont(Some(signal))?; },
VCont::Step => { self.tracee.step(None)?; },
VCont::StepWithSignal(signal) => { self.tracee.step(Some(signal))?; },
// std::ops::Range<T: Copy> should probably also be Copy, but it isn't.
VCont::RangeStep(ref range) => { self.tracee.resume(range.clone())?; },
VCont::Continue => {
self.tracee.cont(None)?;
}
VCont::ContinueWithSignal(signal) => {
self.tracee.cont(Some(signal))?;
}
VCont::Step => {
self.tracee.step(None)?;
}
VCont::StepWithSignal(signal) => {
self.tracee.step(Some(signal))?;
}
VCont::RangeStep(ref range) => {
// std::ops::Range<T: Copy> should probably also be Copy, but it isn't.
self.tracee.resume(range.clone())?;
}
_ => return Err(Error::Unimplemented),
}
}
......@@ -98,9 +103,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let tracee = Os::new(opt.program, opt.args)?;
gdb_remote_protocol::process_packets_from(&mut reader, &mut writer, App {
tracee,
});
gdb_remote_protocol::process_packets_from(&mut reader, &mut writer, App { tracee });
Ok(())
}
......@@ -143,9 +143,15 @@ impl super::Target for Os {
fn status(&self) -> StopReason {
unsafe {
if libc::WIFEXITED(self.last_status.get()) {
StopReason::Exited(self.pid as _, libc::WEXITSTATUS(self.last_status.get()) as _)
StopReason::Exited(
self.pid as _,
libc::WEXITSTATUS(self.last_status.get()) as _,
)
} else if libc::WIFSIGNALED(self.last_status.get()) {
StopReason::ExitedWithSignal(self.pid as _, libc::WTERMSIG(self.last_status.get()) as _)
StopReason::ExitedWithSignal(
self.pid as _,
libc::WTERMSIG(self.last_status.get()) as _,
)
} else if libc::WIFSTOPPED(self.last_status.get()) {
StopReason::Signal(libc::WSTOPSIG(self.last_status.get()) as _)
} else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment