Update kerneldb.
[virt-mem.git] / extract / codegen / minimizer.mli
1 (** Parser minimization. *)
2 (* Memory info command for virtual domains.
3    (C) Copyright 2008 Richard W.M. Jones, Red Hat Inc.
4    http://libvirt.org/
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  *)
20
21 (**
22    {2 How it works}
23
24    {!Pahole_parser} has parsed in a limited set of structures from
25    each available kernel.  We now aim to take a holistic view of
26    a structure as it changed over time, though different kernel
27    versions and also on different architectures.
28
29    {3 Generated parsing functions}
30
31    A form of minimization is required to find kernel structures which
32    happen to be similar - ie. all the fields happen to be in the same
33    place, with the same wordsize and endianness.
34
35    We can then generate a minimal set of parsing functions which
36    map the binary data from the kernel image into structures.
37 *)
38
39 (** {2 Minimization of parsers} *)
40
41 type parser_ (* parser is a reserved word *) = {
42   pa_i : int;                           (** Unique number. *)
43   pa_name : string;                     (** Parser function name in output. *)
44   pa_endian : Bitstring.endian;         (** Default field endianness. *)
45   pa_structure : Pahole_parser.structure; (** Original structure. *)
46 }
47     (** The type of a parser. *)
48
49 type pahash = (string, parser_) Hashtbl.t
50     (** Hash of the kernel version string to the parser. *)
51
52 val minimize_parsers :
53   string ->
54   (Pahole_parser.info * Pahole_parser.structure) list ->
55   parser_ list * pahash
56     (** [minimize_parsers struct_name kernels] returns a minimized
57         list of parsers and a hash table of kernel version to
58         {!parser_}).
59     *)