Revised Virt_mem_mmap handling overlapping mappings efficiently.
[virt-mem.git] / lib / virt_mem.mli
1 (* Memory info for virtual domains.
2    (C) Copyright 2008 Richard W.M. Jones, Red Hat Inc.
3    http://libvirt.org/
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  *)
19
20 type ksym = string
21   (** A kernel symbol name. *)
22
23 type image =
24     int option
25     * string
26     * Virt_mem_utils.architecture
27     * ([`Wordsize], [`Endian], [`HasMapping]) Virt_mem_mmap.t
28   (** A memory image from a domain. *)
29
30 type image_with_ksyms =
31     int option
32     * string
33     * Virt_mem_utils.architecture
34     * ([`Wordsize], [`Endian], [`HasMapping]) Virt_mem_mmap.t
35     * (ksym -> Virt_mem_mmap.addr)
36   (** An image after it has been processed to find kernel symbols.
37
38       The tuple fields are:
39       - domain ID (if known)
40       - name, usually the domain name
41       - architecture (eg. I386)
42       - kernel memory map (wordsize & endianness already determined)
43       - a function to look up kernel symbols.  It raises [Not_found]
44         if a kernel symbol could not be found or if the kernel symbol
45         table could not be found at all.
46   *)
47
48 val register :
49   ?external_cmd:bool ->
50   ?extra_args:(Arg.key * Arg.spec * Arg.doc) list ->
51   ?argcheck:(bool -> unit) ->
52   ?beforeksyms:(bool -> image list -> unit) ->
53   ?run:(bool -> image_with_ksyms list -> unit) ->
54   string -> string -> Arg.usage_msg ->
55   unit
56   (** Tools register themselves with this call.
57
58       The anonymous parameters are:
59       - tool name (eg. "uname")
60       - short summary
61       - full usage message
62
63       The optional callback functions are:
64       - [?argcheck] called after arguments have been fully parsed
65       so that the program can do any additional checks needed (eg.
66       on [extra_args]),
67       - [?beforeksyms] called after images are loaded and before
68       kernel symbols are analyzed,
69       - [?run] called after kernel symbols have been analyzed
70       (almost all tools supply this callback function).
71
72       Pass [~external_cmd:false] if this tool doesn't have an
73       external 'virt-tool' link.
74
75       Pass [~extra_args:...] if this tool needs extra command
76       line options.
77   *)
78
79 val main : unit -> unit
80   (** Entry point for the combined virt-mem executable. *)