ptrace

ptrace wrapper for Nim


Keywords
ptrace, trace, process, syscal, system, call
License
MIT
Install
nimble install ptrace

Documentation

ptrace.nim

ptrace wrapper and helpers for Nim

Installation

$ nimble install ptrace

Example

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)