Import Upstream version 20180207
[hcoop/debian/mlton.git] / basis-library / mlton / ptrace.sml
CommitLineData
7f918cf1
CE
1(* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
2 * Jagannathan, and Stephen Weeks.
3 * Copyright (C) 1997-2000 NEC Research Institute.
4 *
5 * MLton is released under a BSD-style license.
6 * See the file MLton-LICENSE for details.
7 *)
8
9structure MLtonPtrace: MLTON_PTRACE =
10 struct
11 open Primitive.Ptrace
12
13 type pid = Pid.t
14
15 local
16 fun make request pid = PosixError.checkResult(ptrace2(request, pid))
17 in
18 val attach = make ATTACH
19 val cont = make CONT
20 val detach = make DETACH
21 val kill = make KILL
22 val singleStep = make SINGLESTEP
23 val sysCall = make SYSCALL
24 end
25
26 local
27 in
28 fun peekText(pid, addr) =
29 let val data: word ref = ref 0w0
30 in PosixError.checkResult(ptrace4(PEEKTEXT, pid, addr, data))
31 ; !data
32 end
33 end
34 end