-
-
Notifications
You must be signed in to change notification settings - Fork 54
Support read exec-file #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8f0aa74
Support read exec-file
bet4it 01e83cf
Some small fixes
bet4it ca15972
Try to pass buf as an argument of get_exec_file
bet4it 3b37ee9
Set type of offset and length to usize
bet4it 3949c68
Check return size
bet4it 3a5c666
Apply suggestions from code review
bet4it 92026bc
Lint
bet4it e9a721e
Change type of offset to u64
bet4it File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 | ||
daniel5151 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
target extended-remote :9001 |
This file contains hidden or 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 hidden or 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; | ||
daniel5151 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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); | ||
bet4it marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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 hidden or 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 hidden or 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. | ||
bet4it marked this conversation as resolved.
Show resolved
Hide resolved
|
||
fn get_exec_file(&self, pid: Option<Pid>) -> &[u8]; | ||
} | ||
|
||
define_ext!(ExecFileOps, ExecFile); |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.