blob: 943d816b248331fcee51a34d72f4dca9b42df04d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
(** Process.ml
*
* process context implementation
*
* @author copyright (c) 2005 alex ho
* @see <www.cl.cam.ac.uk/netos/pdb> pervasive debugger
* @version 1
*)
open Int32
open Intel
type context_t =
{
mutable domain : int;
mutable process : int;
mutable evtchn : int;
mutable ring : int32;
}
let default_context = { domain = 0; process = 0; evtchn = 0; ring = 0l }
let new_context dom proc = { domain = dom; process = proc;
evtchn = 0; ring = 0l }
let string_of_context ctx =
Printf.sprintf "{process} domain: %d, process: %d"
ctx.domain ctx.process
let set_domain ctx value =
ctx.domain <- value;
print_endline (Printf.sprintf "ctx.domain <- %d" ctx.domain)
let set_process ctx value =
ctx.process <- value;
print_endline (Printf.sprintf "ctx.process <- %d" ctx.process)
let get_domain ctx =
ctx.domain
let get_process ctx =
ctx.process
external _attach_debugger : context_t -> unit = "proc_attach_debugger"
external detach_debugger : context_t -> unit = "proc_detach_debugger"
external pause_target : context_t -> unit = "proc_pause_target"
(* save the event channel and ring for the domain for future use *)
let attach_debugger proc_ctx dom_ctx =
print_endline (Printf.sprintf "%d %lx"
(Xen_domain.get_evtchn dom_ctx)
(Xen_domain.get_ring dom_ctx));
proc_ctx.evtchn <- Xen_domain.get_evtchn dom_ctx;
proc_ctx.ring <- Xen_domain.get_ring dom_ctx;
_attach_debugger proc_ctx
external read_registers : context_t -> registers = "proc_read_registers"
external write_register : context_t -> register -> int32 -> unit =
"proc_write_register"
external read_memory : context_t -> int32 -> int -> int list =
"proc_read_memory"
external write_memory : context_t -> int32 -> int list -> unit =
"proc_write_memory"
external continue : context_t -> unit = "proc_continue_target"
external step : context_t -> unit = "proc_step_target"
external insert_memory_breakpoint : context_t -> int32 -> int -> unit =
"proc_insert_memory_breakpoint"
external remove_memory_breakpoint : context_t -> int32 -> int -> unit =
"proc_remove_memory_breakpoint"
let pause ctx =
pause_target ctx
|