package proc-smaps

  1. Overview
  2. Docs
Proc-smaps: An ocaml parser of /proc/[pid]/smaps

Install

Dune Dependency

Authors

Maintainers

Sources

proc-smaps-0.2.0.tar.bz2
md5=a1762a6b8d3799fdf1cba87edb969491
sha512=85fae795629ee0965f7e8ce48ed4e707a2d235337ef52cfabb50118046ab399de1ac0550a8b41fd9d4b274b5484af97c58854d1d0adcbb8fb07f3f89533090cf

Description

Published: 27 Jan 2023

README

Proc-smaps

An ocaml parser of '/proc/self/smaps' (See /proc/[pid]/smaps section in man proc for details).

Specification

proc-smaps parses mappings. A mapping is such as below.

00400000-0048a000 r-xp 00000000 fd:03 960637       /bin/bash
Size:                552 kB
KernelPageSize:        4 kB
  :
ProtectionKey:         0
VmFlags: rd ex mr mw me dw

A mapping corresponds to Smaps.t. Smaps.get_smaps <pid> returns Smaps.t list Result.t Lwt.t. When mapping : Smaps.t is derived from this mapping, mapping.pathname is "/bin/bash", mapping.perms is 0b10101 (each bits represent 'rwxsp') and Smaps.get_size_exn mapping "Size" is 552 : uint64.

Device and fields that does not include byte size such as ProtectionKey, VmFlags are not supported now.

Example

# let smaps = Smaps.get_self_smaps ()
    |> Lwt_main.run
    |> Result.get_ok;;
val smaps : Smaps.t list = ...
# (Stdint.Uint64.to_string @@ Smaps.sum_rss smaps) ^ " KB"
- : string = "19640 KB"
# Smaps.get_pathname (List.hd smaps);;
- : string = "[vdso]"
# List.map (fun x -> Stdint.Uint64.to_int (Smaps.get_size_exn x Smaps.Fields.pss)) smaps;;
- : int list = ...

Dependencies (4)

  1. stdint
  2. lwt >= "5.4.0"
  3. dune >= "2.9.0"
  4. ocaml >= "4.8.0"

Dev Dependencies (1)

  1. alcotest with-test

Used by

None

Conflicts (1)

  1. result < "1.5"
OCaml

Innovation. Community. Security.