package magic-trace

  1. Overview
  2. Docs
Collects and displays high-resolution traces of what a process is doing

Install

Dune Dependency

Authors

Maintainers

Sources

v1.0.1.tar.gz
sha256=77b2e4b3bc769910656d0fdee4839250548aa49486fd3554f6c057f1d64abe99
sha512=1f111db6348673c22a110611182a92c8aa999668dc077c44bc4abcaa72ccb197899ff2577047888627b50fcc9890824de6c82b4fe9f06129190b8b487ec3f716

doc/src/magic-trace.magic_trace_lib/breakpoint.ml.html

Source file breakpoint.ml

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
open! Core
open! Import

type t

external create
  :  pid:Pid.t
  -> addr:int64
  -> single_hit:bool
  -> (t, int) result
  = "magic_breakpoint_create_stub"

(* Keep in sync with magic_breakpoint_next_stub *)
module Hit = struct
  type t =
    { timestamp : Time_ns.Span.t
    ; passed_timestamp : Time_ns.Span.t
    ; passed_val : int
    ; tid : Pid.t
    ; ip : Int64.Hex.t
    }
  [@@deriving sexp]
end

external get_fd : t -> int = "magic_breakpoint_fd_stub"
external destroy : t -> unit = "magic_breakpoint_destroy_stub"
external next_hit : t -> Hit.t option = "magic_breakpoint_next_stub"

let breakpoint_fd pid ~addr ~single_hit =
  match create ~pid ~addr ~single_hit with
  | Ok t -> Ok t
  | Error errno -> Errno.to_error errno
;;

let fd t = get_fd t |> Core_unix.File_descr.of_int |> Core_unix.dup
OCaml

Innovation. Community. Security.