(** Parser minimization. *) (* Memory info command for virtual domains. (C) Copyright 2008 Richard W.M. Jones, Red Hat Inc. http://libvirt.org/ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *) (** {2 How it works} {!Pahole_parser} has parsed in a limited set of structures from each available kernel. We now aim to take a holistic view of a structure as it changed over time, though different kernel versions and also on different architectures. {3 Generated parsing functions} A form of minimization is required to find kernel structures which happen to be similar - ie. all the fields happen to be in the same place, with the same wordsize and endianness. We can then generate a minimal set of parsing functions which map the binary data from the kernel image into structures. *) (** {2 Minimization of parsers} *) type parser_ (* parser is a reserved word *) = { pa_i : int; (** Unique number. *) pa_name : string; (** Parser function name in output. *) pa_endian : Bitstring.endian; (** Default field endianness. *) pa_structure : Pahole_parser.structure; (** Original structure. *) } (** The type of a parser. *) type pahash = (string, parser_) Hashtbl.t (** Hash of the kernel version string to the parser. *) val minimize_parsers : string -> (Pahole_parser.info * Pahole_parser.structure) list -> parser_ list * pahash (** [minimize_parsers struct_name kernels] returns a minimized list of parsers and a hash table of kernel version to {!parser_}). *)