-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
162 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use gdbstub::common::Pid; | ||
use gdbstub::target; | ||
|
||
use crate::emu::Emu; | ||
|
||
impl target::ext::exec_file::ExecFile for Emu { | ||
fn get_exec_file(&self, _pid: Option<Pid>) -> &[u8] { | ||
b"/test.elf" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
file test.elf | ||
target extended-remote :9001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use super::prelude::*; | ||
use crate::protocol::commands::ext::ExecFile; | ||
|
||
impl<T: Target, C: Connection> GdbStubImpl<T, C> { | ||
pub(crate) fn handle_exec_file( | ||
&mut self, | ||
res: &mut ResponseWriter<C>, | ||
target: &mut T, | ||
command: ExecFile, | ||
) -> Result<HandlerStatus, Error<T::Error, C::Error>> { | ||
let ops = match target.exec_file() { | ||
Some(ops) => ops, | ||
None => return Ok(HandlerStatus::Handled), | ||
}; | ||
|
||
crate::__dead_code_marker!("exec_file", "impl"); | ||
|
||
let handler_status = match command { | ||
ExecFile::qXferExecFileRead(cmd) => { | ||
let filename = ops.get_exec_file(cmd.pid); | ||
res.write_binary_range(filename, cmd.offset, cmd.len)?; | ||
HandlerStatus::Handled | ||
} | ||
}; | ||
|
||
Ok(handler_status) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use super::prelude::*; | ||
|
||
use crate::common::Pid; | ||
|
||
#[derive(Debug)] | ||
pub struct qXferExecFileRead { | ||
pub pid: Option<Pid>, | ||
pub offset: usize, | ||
pub len: usize, | ||
} | ||
|
||
impl<'a> ParseCommand<'a> for qXferExecFileRead { | ||
fn from_packet(buf: PacketBuf<'a>) -> Option<Self> { | ||
let body = buf.into_body(); | ||
|
||
if body.is_empty() { | ||
return None; | ||
} | ||
|
||
let mut body = body.split(|b| *b == b':').skip(1); | ||
let pid = decode_hex(body.next()?).ok().and_then(Pid::new); | ||
|
||
let mut body = body.next()?.split(|b| *b == b','); | ||
let offset = decode_hex(body.next()?).ok()?; | ||
let len = decode_hex(body.next()?).ok()?; | ||
|
||
Some(qXferExecFileRead {pid, offset, len}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//! Provide exec-file path for the target. | ||
use crate::target::Target; | ||
|
||
use crate::common::Pid; | ||
|
||
/// Target Extension - Provide current exec-file. | ||
pub trait ExecFile: Target { | ||
/// Return the full absolute name of the file that was executed to create a | ||
/// process running on the remote system. | ||
fn get_exec_file(&self, pid: Option<Pid>) -> &[u8]; | ||
} | ||
|
||
define_ext!(ExecFileOps, ExecFile); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters