File tree 3 files changed +14
-7
lines changed
3 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ impl target::ext::exec_file::ExecFile for Emu {
15
15
let filename = b"/test.elf" ;
16
16
let len = filename. len ( ) ;
17
17
let data =
18
- & filename[ ( offset as usize ) . min ( len) as usize ..( ( offset + length) as usize ) . min ( len) ] ;
18
+ & filename[ offset. min ( len) ..( offset + length) . min ( len) ] ;
19
19
let buf = & mut buf[ ..data. len ( ) ] ;
20
20
buf. copy_from_slice ( data) ;
21
21
Ok ( data. len ( ) )
Original file line number Diff line number Diff line change @@ -21,7 +21,10 @@ impl<'a> ParseCommand<'a> for qXferExecFileRead<'a> {
21
21
}
22
22
23
23
let mut body = body. split ( |b| * b == b':' ) . skip ( 1 ) ;
24
- let pid = decode_hex ( body. next ( ) ?) . ok ( ) . and_then ( Pid :: new) ;
24
+ let pid = match body. next ( ) ? {
25
+ [ ] => None ,
26
+ buf => Some ( Pid :: new ( decode_hex ( buf) . ok ( ) ?) ?)
27
+ } ;
25
28
26
29
let mut body = body. next ( ) ?. split ( |b| * b == b',' ) ;
27
30
let offset = decode_hex ( body. next ( ) ?) . ok ( ) ?;
Original file line number Diff line number Diff line change @@ -9,11 +9,15 @@ use crate::common::Pid;
9
9
/// I/O Extensions`](crate::target::ext::host_io), which enables the GDB client
10
10
/// to read the executable file directly from the target
11
11
pub trait ExecFile : Target {
12
- /// Get full absolute name of the file that was executed to create
13
- /// process `pid` running on the remote system, or the filename
14
- /// corresponding to the currently executing process if no `pid` is
15
- /// provided.
16
- /// Store the name into `buf`, and return the length of name.
12
+ /// Get full absolute path of the file that was executed to create
13
+ /// process `pid` running on the remote system.
14
+ ///
15
+ /// If `pid` is `None`, return the filename corresponding to the
16
+ /// currently executing process.
17
+ ///
18
+ /// Return the number of bytes written into `buf` (which may be less than `length`).
19
+ ///
20
+ /// If `offset` is greater than the length of the underlying data, return `Ok(0)`.
17
21
fn get_exec_file (
18
22
& self ,
19
23
pid : Option < Pid > ,
You can’t perform that action at this time.
0 commit comments