Verified Commit 2d93df68 authored by jD91mZM2's avatar jD91mZM2

Implement qfThreadInfo

This stops an internal GDB error when stepping past the program
boundaries.
parent dd84c4b8
......@@ -44,7 +44,6 @@ 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)",
......@@ -56,7 +55,7 @@ dependencies = [
name = "gdbserver"
version = "0.1.0"
dependencies = [
"gdb-remote-protocol 0.1.0 (git+https://github.com/luser/rust-gdb-remote-protocol?rev=3e2f7c7204f85781f8b37d601217b05935547a7f)",
"gdb-remote-protocol 0.1.0",
"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)",
......@@ -250,7 +249,6 @@ 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", rev = "3e2f7c7204f85781f8b37d601217b05935547a7f" }
# 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"
......@@ -13,5 +13,5 @@ let
"$@"
'';
in pkgs.mkShell {
nativeBuildInputs = [ gdb-init gdb-test ];
nativeBuildInputs = [ gdb-init gdb-test pkgs.musl ];
}
use gdb_remote_protocol::{
Error, Handler, MemoryRegion, ProcessType, StopReason, ThreadId, VCont, VContFeature,
Error, Handler, Id, MemoryRegion, ProcessType, StopReason, ThreadId, VCont, VContFeature,
};
use structopt::StructOpt;
......@@ -63,8 +63,26 @@ impl Handler for App {
VContFeature::RangeStep,
]))
}
fn thread_list(&self, reset: bool) -> Result<Vec<ThreadId>> {
if reset {
let id = Id::Id(self.tracee.pid());
Ok(vec![
ThreadId { pid: id, tid: id },
])
} else {
Ok(Vec::new())
}
}
fn vcont(&self, actions: Vec<(VCont, Option<ThreadId>)>) -> Result<StopReason> {
if let Some((cmd, _id)) = actions.first() {
for (cmd, id) in &actions {
let id = id.unwrap_or(ThreadId { pid: Id::All, tid: Id::All });
dbg!(id);
dbg!(self.tracee.pid());
match (id.pid, id.tid) {
(Id::Id(pid), _) if pid != self.tracee.pid() => continue,
(_, Id::Id(tid)) if tid != self.tracee.pid() => continue,
(_, _) => (),
}
match *cmd {
VCont::Continue => {
self.tracee.cont(None)?;
......@@ -84,6 +102,7 @@ impl Handler for App {
}
_ => return Err(Error::Unimplemented),
}
break;
}
Ok(self.tracee.status())
......
......@@ -160,6 +160,10 @@ impl super::Target for Os {
}
}
fn pid(&self) -> u32 {
return self.pid as _;
}
fn getregs(&self) -> Result<Registers> {
let int = unsafe {
let mut int: MaybeUninit<libc::user_regs_struct> = MaybeUninit::uninit();
......@@ -344,7 +348,6 @@ impl super::Target for Os {
}
fn setmem(&self, src: &[u8], dest: usize) -> Result<()> {
println!("Writing {:02X?} to address {:X}", src, dest);
setmem(
src,
dest,
......@@ -379,7 +382,6 @@ impl super::Target for Os {
));
Some(rip as u64)
} else {
dbg!(self.status());
None
},
)
......
......@@ -20,6 +20,9 @@ pub trait Target: Sized {
/// Get the last status of the tracee
fn status(&self) -> StopReason;
/// Get the process/thread id
fn pid(&self) -> u32;
/// Read all the process register
fn getregs(&self) -> Result<Registers>;
......
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