1 (** Parser minimization. *)
2 (* Memory info command for virtual domains.
3 (C) Copyright 2008 Richard W.M. Jones, Red Hat Inc.
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.
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.
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.
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.
29 {3 Generated parsing functions}
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.
35 We can then generate a minimal set of parsing functions which
36 map the binary data from the kernel image into structures.
39 (** {2 Minimization of parsers} *)
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. *)
47 (** The type of a parser. *)
49 type pahash = (string, parser_) Hashtbl.t
50 (** Hash of the kernel version string to the parser. *)
52 val minimize_parsers :
54 (Pahole_parser.info * Pahole_parser.structure) list ->
56 (** [minimize_parsers struct_name kernels] returns a minimized
57 list of parsers and a hash table of kernel version to