(* test stat message sctl *) let stest () = let argn = Array.length Sys.argv in if argn < 2 then begin ignore (Printf.fprintf stderr "Supply a process id\n"); flush_all (); exit 1 end; let sctl = Sctl.create_local() in let pid = Int64.of_string Sys.argv.(1) in let (prog,ctx) = Sctl.attach sctl pid in let (pid,regs,bins) = Sctl.stat prog in begin Array.iter (fun x -> Printf.printf "%Lx-%Lx %s\t%s\n" x.Sctl.r_addr (Int64.add x.Sctl.r_addr x.Sctl.r_len) (Sctl.format_rflags x.Sctl.r_flags) x.Sctl.r_file) regs; Array.iter (fun x -> Printf.printf "%Ld %012Lx %s %s\n" x.Sctl.b_nsid x.Sctl.b_base (match x.Sctl.b_isexe with true -> "exe" | false -> "nex") x.Sctl.b_path) bins; end; Sctl.cont prog; Sctl.detach prog; Sctl.close sctl; ;; stest ()