-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
1 changed file
with
34 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,35 @@ | ||
# ptrace.nim | ||
ptrace wrapper for Nim | ||
ptrace wrapper and helpers for Nim | ||
|
||
|
||
## Installation | ||
|
||
$ nimble install ptrace | ||
|
||
## Example | ||
|
||
```nim | ||
import ptrace/ptrace | ||
var child: Pid; | ||
var syscallNum: clong; | ||
child = fork() | ||
if child == 0: | ||
traceMe() | ||
discard execl("/bin/ls", "ls") | ||
else: | ||
var a: cint | ||
wait(nil) | ||
var regs = getRegs(child) | ||
echo "Syscall number: ", regs.orig_rax | ||
if errno != 0: | ||
echo errno, " ", strerror(errno) | ||
syscallNum = peekUser(child, SYSCALL_NUM) | ||
if errno != 0: | ||
echo errno, " ", strerror(errno) | ||
echo "The child made a system call: ", syscallNum | ||
cont(child, nil) | ||
``` |