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.1.0.tar.bz2
md5=1688d45c2870958436373419a9619209
sha512=589ac389027be0d49298a05c21ba650a826b016e9f9d0a27debbd2bb73abfdf35a8d3a4abba562a474ac440164743cecd716eee84d946d473047125ca57883ec

Description

Published: 13 Oct 2021

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"
# List.hd smaps;;
- : Smaps.t =
{Smaps.address = (<abstr>, <abstr>); perms = 21; offset = <abstr>; inode = 0;
 pathname = "[vdso]"; size_fields = <abstr>}
# List.map (fun x -> Smaps.get_size_exn x Smaps.pss |> Stdint.Uint64.to_int) 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"