ba0f3 / ptrace.nim

ptrace wrapper and helpers for Nim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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)

About

ptrace wrapper and helpers for Nim

License:MIT License


Languages

Language:Nim 95.4%Language:C 4.6%