Skip to content

Commit dd80b55

Browse files
committed
Merge branch 'ptrace' of github.com:marmistrz/nix into ptrace
2 parents 8a85c39 + 067f937 commit dd80b55

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/sys/ptrace.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ use ::unistd::Pid;
55

66
//------------------ First part: a low-level wrapper for ptrace -----------------//
77

8+
<<<<<<< HEAD
89
#[cfg(all(target_os = "linux",
910
any(target_arch = "x86",
1011
target_arch = "x86_64",
1112
target_arch = "arm")),
1213
)]
14+
=======
15+
>>>>>>> 067f937f087c4fe00b7281d9829f33a3dae4a9bd
1316
pub mod ptrace {
1417
use libc::c_int;
1518

@@ -151,7 +154,11 @@ pub fn ptrace_setsiginfo(pid: Pid, sig: &siginfo_t) -> Result<()> {
151154
}
152155
}
153156

157+
<<<<<<< HEAD
154158
//-------------------------- Second part: a high-level wrapper for ptrace ----------------------//
159+
=======
160+
//-------------------------- Second part: a low-level wrapper for ptrace ----------------------//
161+
>>>>>>> 067f937f087c4fe00b7281d9829f33a3dae4a9bd
155162

156163
#[cfg(target_arch = "x86_64")]
157164
// We're going to export it anyway
@@ -187,15 +194,22 @@ pub enum Register {
187194
GS = 26 * 8,
188195
}
189196

197+
<<<<<<< HEAD
190198
type Word = usize;
191199

200+
=======
201+
>>>>>>> 067f937f087c4fe00b7281d9829f33a3dae4a9bd
192202
/// Makes the `PTRACE_SYSCALL` request to ptrace
193203
pub fn syscall(pid: Pid) -> Result<()> {
194204
ptrace(ptrace::PTRACE_SYSCALL, pid, ptr::null_mut(), ptr::null_mut()).map(|_| ()) // ignore the useless return value
195205
}
196206

197207
/// Makes the `PTRACE_PEEKUSER` request to ptrace
208+
<<<<<<< HEAD
198209
pub fn peekuser(pid: Pid, reg: Register) -> Result<Word> {
210+
=======
211+
pub fn peekuser(pid: Pid, reg: Register) -> Result<c_long> {
212+
>>>>>>> 067f937f087c4fe00b7281d9829f33a3dae4a9bd
199213
let reg_arg = (reg as i32) as *mut c_void;
200214
ptrace(ptrace::PTRACE_PEEKUSER, pid, reg_arg, ptr::null_mut())
201215
}
@@ -214,7 +228,11 @@ pub fn traceme() -> Result<()> {
214228
///
215229
/// This function allows to access arbitrary data in the traced process
216230
/// and may crash the inferior if used incorrectly and is thus marked `unsafe`.
231+
<<<<<<< HEAD
217232
pub unsafe fn peekdata(pid: Pid, addr: usize) -> Result<Word> {
233+
=======
234+
pub unsafe fn peekdata(pid: Pid, addr: c_long) -> Result<c_long> {
235+
>>>>>>> 067f937f087c4fe00b7281d9829f33a3dae4a9bd
218236
ptrace(ptrace::PTRACE_PEEKDATA, pid, addr as *mut c_void, ptr::null_mut())
219237
}
220238

@@ -223,13 +241,18 @@ pub unsafe fn peekdata(pid: Pid, addr: usize) -> Result<Word> {
223241
/// This function allows to access arbitrary data in the traced process
224242
/// and may crash the inferior or introduce race conditions if used
225243
/// incorrectly and is thus marked `unsafe`.
244+
<<<<<<< HEAD
226245
pub unsafe fn pokedata(pid: Pid, addr: usize, val: Word) -> Result<()> {
246+
=======
247+
pub unsafe fn pokedata(pid: Pid, addr: c_long, val: c_long) -> Result<()> {
248+
>>>>>>> 067f937f087c4fe00b7281d9829f33a3dae4a9bd
227249
ptrace(
228250
ptrace::PTRACE_POKEDATA,
229251
pid,
230252
addr as *mut c_void,
231253
val as *mut c_void,
232254
).map(|_| ()) // ignore the useless return value
255+
<<<<<<< HEAD
233256
}
234257

235258

@@ -255,3 +278,6 @@ mod tests {
255278
assert_eq!(len, 0);
256279
}
257280
}
281+
=======
282+
}
283+
>>>>>>> 067f937f087c4fe00b7281d9829f33a3dae4a9bd

0 commit comments

Comments
 (0)