Skip to content

Commit

Permalink
Merge pull request #1 from Tangdongle/master
Browse files Browse the repository at this point in the history
Fixed up package
  • Loading branch information
ba0f3 authored Feb 1, 2020
2 parents a29f551 + 8140901 commit 1dd4436
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 62 deletions.
4 changes: 2 additions & 2 deletions ptrace.nim
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ template syscall*(p: Pid) =
template singleStep*(p: Pid) =
ptrace(PTRACE_SINGLESTEP, p, 0, 0)

template peekUser*(p: Pid, a: clong): expr =
template peekUser*(p: Pid, a: clong): untyped =
ptrace(PTRACE_PEEKUSER, p, a, 0)

template getData*(p: Pid, a: clong): expr =
template getData*(p: Pid, a: clong): untyped =
ptrace(PTRACE_PEEKDATA, p, a, 0)

proc getData*[T: string|cstring|array|seq](p: Pid, a: clong, buf: var T, length: int) =
Expand Down
7 changes: 2 additions & 5 deletions ptrace.nimble
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
[Package]
name = "ptrace"
version = "0.0.3"
author = "Huy Doan"
description = "ptrace wrapper and helpers for Nim"
license = "MIT"

skipDirs = "tests"
skipDirs = @["tests"]

[Deps]
Requires: "nim >= 0.10.0"
requires "nim >= 0.10.0"
1 change: 1 addition & 0 deletions tests/config.nims
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
switch("path", "$projectDir/../")
7 changes: 4 additions & 3 deletions tests/test1.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import posix
import ../ptrace/ptrace
import ../ptrace/syscall
import ptrace
import private/syscall


var child: Pid
Expand Down Expand Up @@ -29,7 +29,8 @@ else:
params[2] = peekUser(child, SYSCALL_ARG3)
echo "Write called with ", params[0], ", ", params[1], ", ", params[2]

let regs: Registers = getRegs(child)
var regs: Registers
getRegs(child, addr regs)
echo regs.rdi, " ", regs.rsi, " ", regs.rdx

else:
Expand Down
4 changes: 2 additions & 2 deletions tests/test2.nim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import posix
import unicode
import ../ptrace/ptrace
import ../ptrace/syscall
import ptrace
import private/syscall

var child: Pid
var syscallNo: clong
Expand Down
6 changes: 3 additions & 3 deletions tests/test3.nim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import posix
import strutils
import ../ptrace/ptrace
import ../ptrace/syscall
import ptrace
import private/syscall

proc c_printf(frmt: cstring) {.importc: "printf", header: "<stdio.h>", varargs.}

Expand All @@ -25,7 +25,7 @@ else:
if WIFEXITED(status):
break

regs = getRegs(child)
getRegs(child, addr regs)
if start == 1:
ins = getData(child, regs.rip.clong)
c_printf("RIP: %lx Instruction executed: %lx\n", regs.rip, ins)
Expand Down
47 changes: 0 additions & 47 deletions tests/test4.nim

This file was deleted.

0 comments on commit 1dd4436

Please sign in to comment.