mirror of
https://github.com/ba0f3/ptrace.nim
synced 2026-01-15 08:01:47 +00:00
No description
| .github | ||
| src | ||
| tests | ||
| .gitignore | ||
| LICENSE | ||
| ptrace.nimble | ||
| README.md | ||
ptrace.nim
ptrace wrapper and helpers for Nim
Installation
$ nimble install ptrace
Example
import posix, 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: Registers
getRegs(child, addr regs)
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)