No description
Find a file
2022-10-12 22:55:27 +07:00
.github Create FUNDING.yml 2021-10-01 07:51:45 +07:00
src move source files into src folder, refs #5 2022-10-12 22:54:30 +07:00
tests added some minor changes 2020-11-14 16:59:42 +07:00
.gitignore Initial commit 2015-09-13 01:07:24 +07:00
LICENSE Initial commit 2015-09-13 01:07:24 +07:00
ptrace.nimble version bump 2022-10-12 22:55:27 +07:00
README.md fixed example in readme, and wrong parameter type for getRegs. closes #3 2020-08-02 20:14:34 +07:00

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)