aboutsummaryrefslogtreecommitdiff
path: root/src/target/ext/exec_file.rs
blob: a819638ae6b77de603321c53838ae65e7f1a9cb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//! Provide exec-file path for the target.
use crate::common::Pid;
use crate::target::Target;
use crate::target::TargetResult;

/// Target Extension - Provide current exec-file.
///
/// NOTE: this extension is primarily intended to be used alongside the [`Host
/// I/O Extensions`](crate::target::ext::host_io), which enables the GDB client
/// to read the executable file directly from the target
pub trait ExecFile: Target {
    /// Get full absolute path of the file that was executed to create
    /// process `pid` running on the remote system.
    ///
    /// If `pid` is `None`, return the filename corresponding to the
    /// currently executing process.
    ///
    /// Return the number of bytes written into `buf` (which may be less than
    /// `length`).
    ///
    /// If `offset` is greater than the length of the underlying data, return
    /// `Ok(0)`.
    fn get_exec_file(
        &self,
        pid: Option<Pid>,
        offset: u64,
        length: usize,
        buf: &mut [u8],
    ) -> TargetResult<usize, Self>;
}

define_ext!(ExecFileOps, ExecFile);