From: Richard W.M. Jones <"Richard W.M. Jones "> Date: Wed, 6 Aug 2008 17:02:51 +0000 (+0100) Subject: Code generation of parsing functions now working. X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=727fe72a983a94decbd6e99d8c7c85c34f0171da;p=virt-mem.git Code generation of parsing functions now working. --- diff --git a/extract/codegen/Makefile.in b/extract/codegen/Makefile.in index 85b2619..558c574 100644 --- a/extract/codegen/Makefile.in +++ b/extract/codegen/Makefile.in @@ -23,7 +23,8 @@ INSTALL = @INSTALL@ MKDIR_P = @MKDIR_P@ bindir = @bindir@ -OCAMLCPACKAGES = -package extlib,pcre,unix,camlp4,bitstring.syntax -syntax bitstring.syntax +#OCAMLCPACKAGES = -package extlib,pcre,unix,camlp4,bitstring.syntax -syntax bitstring.syntax +OCAMLCPACKAGES = -package extlib,pcre,unix,camlp4,bitstring -pp camlp4of OCAMLCFLAGS = @OCAMLCFLAGS@ OCAMLCLIBS = -linkpkg camlp4lib.cma diff --git a/extract/codegen/kerneldb_to_parser.ml b/extract/codegen/kerneldb_to_parser.ml index e7b4142..2bddb90 100644 --- a/extract/codegen/kerneldb_to_parser.ml +++ b/extract/codegen/kerneldb_to_parser.ml @@ -32,7 +32,7 @@ let what = [ "task_struct", ( "struct task_struct {", "};", true, [ "state"; "prio"; "normal_prio"; "static_prio"; - "tasks'prev"; "tasks'next"; "comm"] + "tasks'prev"; "tasks'next"; "mm"; "active_mm"; "comm"] ); (* "mm_struct", ( @@ -46,7 +46,7 @@ let what = [ ); ] -let debug = true +let debug = false open Camlp4.PreCast open Syntax @@ -515,9 +515,13 @@ Example (from toplevel of virt-mem source tree): let fields = List.map ( function | (name, `Int) -> - <:ctyp< $lid:name$ : int >> + <:ctyp< $lid:name$ : int64 >> + | (name, `Ptr "list_head") -> + <:ctyp< $lid:name$ : + [ `$lid:struct_name$ ] Virt_mem_mmap.typed_addr >> | (name, `Ptr struct_name) -> - <:ctyp< $lid:name$ : [`$lid:struct_name$] int64 >> + <:ctyp< $lid:name$ : + [ `$lid:struct_name$ ] Virt_mem_mmap.typed_addr >> | (name, `Str _) -> <:ctyp< $lid:name$ : string >> ) field_types in @@ -533,11 +537,13 @@ Example (from toplevel of virt-mem source tree): struct_type, struct_sig in (* The shared parser functions. + * * We could include bitmatch statements directly in here, but * what happens is that the macros get expanded here, resulting - * in unreadable generated code. So instead just do a textual - * substitution later by post-processing the generated files. - * Not type-safe, but we can't have everything. + * in (even more) unreadable generated code. So instead just + * do a textual substitution later by post-processing the + * generated files. Not type-safe, but we can't have + * everything. *) let parser_stmts, parser_subs = let parser_stmts = List.map ( @@ -545,7 +551,7 @@ Example (from toplevel of virt-mem source tree): let fnname = sprintf "parser_%d" i in <:str_item< let $lid:fnname$ bits = $str:fnname$ - >> + >> ) parsers in let parser_stmts = @@ -558,12 +564,50 @@ Example (from toplevel of virt-mem source tree): let parser_subs = List.map ( fun (i, (endian, fields)) -> let fnname = sprintf "parser_%d" i in - let patterns = "" and assignments = "" in (* XXX *) + let endian = + match endian with + | Bitstring.LittleEndian -> "littleendian" + | Bitstring.BigEndian -> "bigendian" + | _ -> assert false in + let patterns = + (* Fields must be sorted by offset, otherwise bitmatch + * will complain. + *) + let cmp (_, (_, o1, _)) (_, (_, o2, _)) = compare o1 o2 in + let fields = List.sort ~cmp fields in + String.concat ";\n " ( + List.map ( + function + | (field_name, (`Int, offset, size)) + | (field_name, (`Ptr _, offset, size)) -> + (* 'zero+' is a hack to force the type to int64. *) + sprintf "%s : zero+%d : offset(%d), %s" + field_name (size*8) (offset*8) endian + | (field_name, (`Str width, offset, size)) -> + sprintf "%s : %d : offset(%d), string" + field_name (width*8) (offset*8) + ) fields + ) in + let assignments = + String.concat ";\n " ( + List.map ( + function + | (field_name, (`Ptr "list_head", offset, size)) -> + sprintf "%s = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub %s %dL) : [ `%s ] Virt_mem_mmap.typed_addr)" field_name field_name offset struct_name + | (field_name, (`Ptr struct_name, offset, size)) -> + sprintf "%s = (Virt_mem_mmap.unsafe_typed_addr_of_addr %s : [ `%s ] Virt_mem_mmap.typed_addr)" field_name field_name struct_name + | (field_name, _) -> + sprintf "%s = %s" field_name field_name + ) fields + ) in + let sub = - sprintf "bitmatch bits with - | { %s } -> { %s } - | { _ } -> raise (ParseError (%S, %S, \"failed to match kernel structure\"))" + sprintf "\ + bitmatch bits with + | { %s } -> { %s } + | { _ } -> raise (ParseError (%S, %S, \"failed to match kernel structure\"))" patterns assignments struct_name fnname in + fnname, sub ) parsers in @@ -589,7 +633,8 @@ Example (from toplevel of virt-mem source tree): (* Code (.ml file). *) let code = <:str_item< let warning = "This code is automatically generated from the kernel database by kerneldb-to-parser program. Any edits you make will be lost." - exception ParseError of string ;; + let zero = 0 + exception ParseError of string * string * string;; $struct_type$ $parser_stmts$ $version_map$ @@ -599,33 +644,74 @@ Example (from toplevel of virt-mem source tree): let size version = let _, size = StringMap.find version map in size - let get version bits = + let of_bits version bits = let parsefn, _ = StringMap.find version map in parsefn bits + let get version mem addr = + let parsefn, size = StringMap.find version map in + let addr = Virt_mem_mmap.unsafe_addr_of_typed_addr addr in + let bytes = Virt_mem_mmap.get_bytes mem addr size in + let bits = Bitstring.bitstring_of_string bytes in + parsefn bits >> in (* Interface (.mli file). *) let interface = <:sig_item< - exception ParseError of string ;; + exception ParseError of string * string * string;; $struct_sig$ type kernel_version = string val known : kernel_version -> bool val size : kernel_version -> int - val get : kernel_version -> Bitstring.bitstring -> t + val of_bits : kernel_version -> Bitstring.bitstring -> t + val get : kernel_version -> + ('a, 'b, [`HasMapping]) Virt_mem_mmap.t -> + [ `$lid:struct_name$ ] Virt_mem_mmap.typed_addr -> + t >> in - (struct_name, code, interface) + (struct_name, code, interface, parser_subs) ) files in (* Finally generate the output files. *) + let re_subst = Pcre.regexp "^(.*)\"(parser_\\d+)\"(.*)$" in + List.iter ( - fun (struct_name, code, interface) -> + fun (struct_name, code, interface, parser_subs) -> + (* Interface (.mli file). *) + let output_file = outputdir // "kernel_" ^ struct_name ^ ".mli" in + printf "Writing %s interface to %s ...\n%!" struct_name output_file; + Printers.OCaml.print_interf ~output_file interface; + + (* Implementation (.ml file). *) let output_file = outputdir // "kernel_" ^ struct_name ^ ".ml" in printf "Writing %s implementation to %s ...\n%!" struct_name output_file; - Printers.OCaml.print_implem ~output_file code; - let output_file = outputdir // "kernel_" ^ struct_name ^ ".mli" in - printf "Writing %s interface to %s ...\n%!" struct_name output_file; - Printers.OCaml.print_interf ~output_file interface + let new_output_file = output_file ^ ".new" in + Printers.OCaml.print_implem ~output_file:new_output_file code; + + (* Substitute the parser bodies in the output file. *) + let ichan = open_in new_output_file in + let ochan = open_out output_file in + + let rec loop () = + let line = input_line ichan in + let line = + if Pcre.pmatch ~rex:re_subst line then ( + let subs = Pcre.exec ~rex:re_subst line in + let start = Pcre.get_substring subs 1 in + let template = Pcre.get_substring subs 2 in + let rest = Pcre.get_substring subs 3 in + let sub = List.assoc template parser_subs in + start ^ sub ^ rest + ) else line in + output_string ochan line; output_char ochan '\n'; + loop () + in + (try loop () with End_of_file -> ()); + + close_out ochan; + close_in ichan; + + Unix.unlink new_output_file ) files diff --git a/lib/.depend b/lib/.depend index 230aebf..51d8e06 100644 --- a/lib/.depend +++ b/lib/.depend @@ -1,13 +1,15 @@ +kernel_net_device.cmi: virt_mem_mmap.cmi +kernel_task_struct.cmi: virt_mem_mmap.cmi virt_mem_kallsyms.cmi: virt_mem_types.cmi virt_mem_ksyms.cmi: virt_mem_types.cmi virt_mem.cmi: virt_mem_types.cmi virt_mem_mmap.cmi: virt_mem_utils.cmo virt_mem_types.cmi: virt_mem_utils.cmo virt_mem_mmap.cmi virt_mem_utsname.cmi: virt_mem_types.cmi -kernel_net_device.cmo: kernel_net_device.cmi -kernel_net_device.cmx: kernel_net_device.cmi -kernel_task_struct.cmo: kernel_task_struct.cmi -kernel_task_struct.cmx: kernel_task_struct.cmi +kernel_net_device.cmo: virt_mem_mmap.cmi kernel_net_device.cmi +kernel_net_device.cmx: virt_mem_mmap.cmx kernel_net_device.cmi +kernel_task_struct.cmo: virt_mem_mmap.cmi kernel_task_struct.cmi +kernel_task_struct.cmx: virt_mem_mmap.cmx kernel_task_struct.cmi test_mmap.cmo: virt_mem_mmap.cmi test_mmap.cmx: virt_mem_mmap.cmx virt_mem_capture.cmo: virt_mem_types.cmi virt_mem_gettext.cmo virt_mem.cmi diff --git a/lib/Makefile.in b/lib/Makefile.in index f59845f..6f94163 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -52,6 +52,8 @@ OBJS = virt_mem_gettext.cmo \ virt_mem_utils.cmo \ virt_mem_mmap_c.o \ virt_mem_mmap.cmo \ + kernel_task_struct.cmo \ + kernel_net_device.cmo \ virt_mem_types.cmo \ virt_mem_ksyms.cmo \ virt_mem_kallsyms.cmo \ diff --git a/lib/kernel_net_device.ml b/lib/kernel_net_device.ml index 47e8253..7d258f9 100644 --- a/lib/kernel_net_device.ml +++ b/lib/kernel_net_device.ml @@ -1,24 +1,93 @@ let warning = "This code is automatically generated from the kernel database by kerneldb-to-parser program. Any edits you make will be lost.";; -exception ParseError of string;; +let zero = 0;; +exception ParseError of string * string * string;; type t = { dev_addr : string; name : string };; -let parser_1 bits = "parser_1";; -let parser_2 bits = "parser_2";; -let parser_3 bits = "parser_3";; -let parser_4 bits = "parser_4";; -let parser_5 bits = "parser_5";; -let parser_6 bits = "parser_6";; -let parser_7 bits = "parser_7";; -let parser_8 bits = "parser_8";; -let parser_9 bits = "parser_9";; -let parser_10 bits = "parser_10";; -let parser_11 bits = "parser_11";; -let parser_12 bits = "parser_12";; -let parser_13 bits = "parser_13";; -let parser_14 bits = "parser_14";; -let parser_15 bits = "parser_15";; -let parser_16 bits = "parser_16";; -let parser_17 bits = "parser_17";; +let parser_1 bits = bitmatch bits with + | { name : 128 : offset(0), string; + dev_addr : 256 : offset(2240), string } -> { name = name; + dev_addr = dev_addr } + | { _ } -> raise (ParseError ("net_device", "parser_1", "failed to match kernel structure"));; +let parser_2 bits = bitmatch bits with + | { name : 128 : offset(0), string; + dev_addr : 256 : offset(2496), string } -> { name = name; + dev_addr = dev_addr } + | { _ } -> raise (ParseError ("net_device", "parser_2", "failed to match kernel structure"));; +let parser_3 bits = bitmatch bits with + | { name : 128 : offset(0), string; + dev_addr : 256 : offset(2688), string } -> { name = name; + dev_addr = dev_addr } + | { _ } -> raise (ParseError ("net_device", "parser_3", "failed to match kernel structure"));; +let parser_4 bits = bitmatch bits with + | { name : 128 : offset(0), string; + dev_addr : 256 : offset(4416), string } -> { name = name; + dev_addr = dev_addr } + | { _ } -> raise (ParseError ("net_device", "parser_4", "failed to match kernel structure"));; +let parser_5 bits = bitmatch bits with + | { name : 128 : offset(0), string; + dev_addr : 256 : offset(3392), string } -> { name = name; + dev_addr = dev_addr } + | { _ } -> raise (ParseError ("net_device", "parser_5", "failed to match kernel structure"));; +let parser_6 bits = bitmatch bits with + | { name : 128 : offset(0), string; + dev_addr : 256 : offset(4416), string } -> { name = name; + dev_addr = dev_addr } + | { _ } -> raise (ParseError ("net_device", "parser_6", "failed to match kernel structure"));; +let parser_7 bits = bitmatch bits with + | { name : 128 : offset(0), string; + dev_addr : 256 : offset(3264), string } -> { name = name; + dev_addr = dev_addr } + | { _ } -> raise (ParseError ("net_device", "parser_7", "failed to match kernel structure"));; +let parser_8 bits = bitmatch bits with + | { name : 128 : offset(0), string; + dev_addr : 256 : offset(4288), string } -> { name = name; + dev_addr = dev_addr } + | { _ } -> raise (ParseError ("net_device", "parser_8", "failed to match kernel structure"));; +let parser_9 bits = bitmatch bits with + | { name : 128 : offset(0), string; + dev_addr : 256 : offset(1728), string } -> { name = name; + dev_addr = dev_addr } + | { _ } -> raise (ParseError ("net_device", "parser_9", "failed to match kernel structure"));; +let parser_10 bits = bitmatch bits with + | { name : 128 : offset(0), string; + dev_addr : 256 : offset(1728), string } -> { name = name; + dev_addr = dev_addr } + | { _ } -> raise (ParseError ("net_device", "parser_10", "failed to match kernel structure"));; +let parser_11 bits = bitmatch bits with + | { name : 128 : offset(0), string; + dev_addr : 256 : offset(2528), string } -> { name = name; + dev_addr = dev_addr } + | { _ } -> raise (ParseError ("net_device", "parser_11", "failed to match kernel structure"));; +let parser_12 bits = bitmatch bits with + | { name : 128 : offset(0), string; + dev_addr : 256 : offset(3392), string } -> { name = name; + dev_addr = dev_addr } + | { _ } -> raise (ParseError ("net_device", "parser_12", "failed to match kernel structure"));; +let parser_13 bits = bitmatch bits with + | { name : 128 : offset(0), string; + dev_addr : 256 : offset(2528), string } -> { name = name; + dev_addr = dev_addr } + | { _ } -> raise (ParseError ("net_device", "parser_13", "failed to match kernel structure"));; +let parser_14 bits = bitmatch bits with + | { name : 128 : offset(0), string; + dev_addr : 256 : offset(4288), string } -> { name = name; + dev_addr = dev_addr } + | { _ } -> raise (ParseError ("net_device", "parser_14", "failed to match kernel structure"));; +let parser_15 bits = bitmatch bits with + | { name : 128 : offset(0), string; + dev_addr : 256 : offset(1696), string } -> { name = name; + dev_addr = dev_addr } + | { _ } -> raise (ParseError ("net_device", "parser_15", "failed to match kernel structure"));; +let parser_16 bits = bitmatch bits with + | { name : 128 : offset(0), string; + dev_addr : 256 : offset(2624), string } -> { name = name; + dev_addr = dev_addr } + | { _ } -> raise (ParseError ("net_device", "parser_16", "failed to match kernel structure"));; +let parser_17 bits = bitmatch bits with + | { name : 128 : offset(0), string; + dev_addr : 256 : offset(1696), string } -> { name = name; + dev_addr = dev_addr } + | { _ } -> raise (ParseError ("net_device", "parser_17", "failed to match kernel structure"));; module StringMap = Map.Make(String);; let map = StringMap.empty;; let v = (parser_1, 1284);; @@ -27,6 +96,8 @@ let v = (parser_2, 1092);; let map = StringMap.add "2.6.22-0.23.rc7.git6.fc8.ppc" v map;; let v = (parser_1, 1284);; let map = StringMap.add "2.6.21-1.3128.fc7.i686" v map;; +let v = (parser_1, 1284);; +let map = StringMap.add "2.6.21-1.3132.fc7.i686" v map;; let v = (parser_2, 1092);; let map = StringMap.add "2.6.21-1.3236.fc8.ppc" v map;; let v = (parser_1, 1116);; @@ -47,12 +118,16 @@ let v = (parser_6, 2044);; let map = StringMap.add "2.6.22-0.23.rc7.git6.fc8.ppc64" v map;; let v = (parser_7, 1408);; let map = StringMap.add "2.6.21-1.3236.fc8.i686" v map;; +let v = (parser_5, 1924);; +let map = StringMap.add "2.6.21-1.3132.fc7.ppc64" v map;; let v = (parser_1, 1116);; let map = StringMap.add "2.6.21-1.3228.fc7.i686" v map;; let v = (parser_8, 2288);; let map = StringMap.add "2.6.24-9.fc9.x86_64" v map;; let v = (parser_6, 2044);; let map = StringMap.add "2.6.22-0.23.rc7.git6.fc8.ppc64" v map;; +let v = (parser_5, 1924);; +let map = StringMap.add "2.6.21-1.3132.fc7.ppc64" v map;; let v = (parser_1, 912);; let map = StringMap.add "2.6.18-1.2798.fc6.i586" v map;; let v = (parser_9, 1020);; @@ -214,5 +289,10 @@ let map = StringMap.add "2.6.21-1.3209.fc8.ppc64" v map;; type kernel_version = string;; let known version = StringMap.mem version map;; let size version = let (_, size) = StringMap.find version map in size;; -let get version bits = +let of_bits version bits = let (parsefn, _) = StringMap.find version map in parsefn bits;; +let get version mem addr = + let (parsefn, size) = StringMap.find version map in + let addr = Virt_mem_mmap.unsafe_addr_of_typed_addr addr in + let bytes = Virt_mem_mmap.get_bytes mem addr size in + let bits = Bitstring.bitstring_of_string bytes in parsefn bits;; diff --git a/lib/kernel_net_device.mli b/lib/kernel_net_device.mli index ea72dc9..646b835 100644 --- a/lib/kernel_net_device.mli +++ b/lib/kernel_net_device.mli @@ -1,6 +1,10 @@ -exception ParseError of string;; +exception ParseError of string * string * string;; type t = { dev_addr : string; name : string };; type kernel_version = string;; val known : kernel_version -> bool;; val size : kernel_version -> int;; -val get : kernel_version -> Bitstring.bitstring -> t;; +val of_bits : kernel_version -> Bitstring.bitstring -> t;; +val get : + kernel_version -> + ('a, 'b, [ | `HasMapping ]) Virt_mem_mmap.t -> + [ | `net_device ] Virt_mem_mmap.typed_addr -> t;; diff --git a/lib/kernel_task_struct.ml b/lib/kernel_task_struct.ml index e87a928..aac64ab 100644 --- a/lib/kernel_task_struct.ml +++ b/lib/kernel_task_struct.ml @@ -1,33 +1,432 @@ let warning = "This code is automatically generated from the kernel database by kerneldb-to-parser program. Any edits you make will be lost.";; -exception ParseError of string;; +let zero = 0;; +exception ParseError of string * string * string;; type t = - { comm : string; normal_prio : int; prio : int; state : int; - static_prio : int; tasks'next : [ | `list_head ] int64; - tasks'prev : [ | `list_head ] int64 + { active_mm : [ | `mm_struct ] Virt_mem_mmap.typed_addr; comm : string; + mm : [ | `mm_struct ] Virt_mem_mmap.typed_addr; normal_prio : int64; + prio : int64; state : int64; static_prio : int64; + tasks'next : [ | `task_struct ] Virt_mem_mmap.typed_addr; + tasks'prev : [ | `task_struct ] Virt_mem_mmap.typed_addr };; -let parser_1 bits = "parser_1";; -let parser_2 bits = "parser_2";; -let parser_3 bits = "parser_3";; -let parser_4 bits = "parser_4";; -let parser_5 bits = "parser_5";; -let parser_6 bits = "parser_6";; -let parser_7 bits = "parser_7";; -let parser_8 bits = "parser_8";; -let parser_9 bits = "parser_9";; -let parser_10 bits = "parser_10";; -let parser_11 bits = "parser_11";; -let parser_12 bits = "parser_12";; -let parser_13 bits = "parser_13";; -let parser_14 bits = "parser_14";; -let parser_15 bits = "parser_15";; -let parser_16 bits = "parser_16";; -let parser_17 bits = "parser_17";; -let parser_18 bits = "parser_18";; -let parser_19 bits = "parser_19";; -let parser_20 bits = "parser_20";; -let parser_21 bits = "parser_21";; -let parser_22 bits = "parser_22";; +let parser_1 bits = bitmatch bits with + | { state : zero+32 : offset(0), littleendian; + prio : zero+32 : offset(192), littleendian; + static_prio : zero+32 : offset(224), littleendian; + normal_prio : zero+32 : offset(256), littleendian; + tasks'next : zero+32 : offset(992), littleendian; + tasks'prev : zero+32 : offset(1024), littleendian; + mm : zero+32 : offset(1056), littleendian; + active_mm : zero+32 : offset(1088), littleendian; + comm : 128 : offset(3232), string } -> { state = state; + prio = prio; + static_prio = static_prio; + normal_prio = normal_prio; + tasks'next = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'next 124L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + tasks'prev = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'prev 128L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + active_mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr active_mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + comm = comm } + | { _ } -> raise (ParseError ("task_struct", "parser_1", "failed to match kernel structure"));; +let parser_2 bits = bitmatch bits with + | { state : zero+32 : offset(0), bigendian; + prio : zero+32 : offset(160), bigendian; + static_prio : zero+32 : offset(192), bigendian; + normal_prio : zero+32 : offset(224), bigendian; + tasks'next : zero+32 : offset(2176), bigendian; + tasks'prev : zero+32 : offset(2208), bigendian; + mm : zero+32 : offset(2240), bigendian; + active_mm : zero+32 : offset(2272), bigendian; + comm : 128 : offset(4416), string } -> { state = state; + prio = prio; + static_prio = static_prio; + normal_prio = normal_prio; + tasks'next = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'next 272L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + tasks'prev = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'prev 276L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + active_mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr active_mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + comm = comm } + | { _ } -> raise (ParseError ("task_struct", "parser_2", "failed to match kernel structure"));; +let parser_3 bits = bitmatch bits with + | { state : zero+32 : offset(0), bigendian; + prio : zero+32 : offset(192), bigendian; + static_prio : zero+32 : offset(224), bigendian; + normal_prio : zero+32 : offset(256), bigendian; + tasks'next : zero+32 : offset(2304), bigendian; + tasks'prev : zero+32 : offset(2336), bigendian; + mm : zero+32 : offset(2496), bigendian; + active_mm : zero+32 : offset(2528), bigendian; + comm : 128 : offset(4736), string } -> { state = state; + prio = prio; + static_prio = static_prio; + normal_prio = normal_prio; + tasks'next = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'next 288L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + tasks'prev = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'prev 292L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + active_mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr active_mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + comm = comm } + | { _ } -> raise (ParseError ("task_struct", "parser_3", "failed to match kernel structure"));; +let parser_4 bits = bitmatch bits with + | { state : zero+64 : offset(0), littleendian; + prio : zero+32 : offset(320), littleendian; + static_prio : zero+32 : offset(352), littleendian; + normal_prio : zero+32 : offset(384), littleendian; + tasks'next : zero+64 : offset(1536), littleendian; + tasks'prev : zero+64 : offset(1600), littleendian; + mm : zero+64 : offset(1664), littleendian; + active_mm : zero+64 : offset(1728), littleendian; + comm : 128 : offset(5376), string } -> { state = state; + prio = prio; + static_prio = static_prio; + normal_prio = normal_prio; + tasks'next = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'next 192L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + tasks'prev = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'prev 200L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + active_mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr active_mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + comm = comm } + | { _ } -> raise (ParseError ("task_struct", "parser_4", "failed to match kernel structure"));; +let parser_5 bits = bitmatch bits with + | { state : zero+64 : offset(0), littleendian; + prio : zero+32 : offset(256), littleendian; + static_prio : zero+32 : offset(288), littleendian; + normal_prio : zero+32 : offset(320), littleendian; + tasks'next : zero+64 : offset(2816), littleendian; + tasks'prev : zero+64 : offset(2880), littleendian; + mm : zero+64 : offset(3200), littleendian; + active_mm : zero+64 : offset(3264), littleendian; + comm : 128 : offset(6912), string } -> { state = state; + prio = prio; + static_prio = static_prio; + normal_prio = normal_prio; + tasks'next = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'next 352L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + tasks'prev = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'prev 360L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + active_mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr active_mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + comm = comm } + | { _ } -> raise (ParseError ("task_struct", "parser_5", "failed to match kernel structure"));; +let parser_6 bits = bitmatch bits with + | { state : zero+64 : offset(0), bigendian; + prio : zero+32 : offset(320), bigendian; + static_prio : zero+32 : offset(352), bigendian; + normal_prio : zero+32 : offset(384), bigendian; + tasks'next : zero+64 : offset(1600), bigendian; + tasks'prev : zero+64 : offset(1664), bigendian; + mm : zero+64 : offset(1728), bigendian; + active_mm : zero+64 : offset(1792), bigendian; + comm : 128 : offset(5440), string } -> { state = state; + prio = prio; + static_prio = static_prio; + normal_prio = normal_prio; + tasks'next = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'next 200L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + tasks'prev = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'prev 208L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + active_mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr active_mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + comm = comm } + | { _ } -> raise (ParseError ("task_struct", "parser_6", "failed to match kernel structure"));; +let parser_7 bits = bitmatch bits with + | { state : zero+64 : offset(0), littleendian; + prio : zero+32 : offset(320), littleendian; + static_prio : zero+32 : offset(352), littleendian; + normal_prio : zero+32 : offset(384), littleendian; + tasks'next : zero+64 : offset(1536), littleendian; + tasks'prev : zero+64 : offset(1600), littleendian; + mm : zero+64 : offset(1664), littleendian; + active_mm : zero+64 : offset(1728), littleendian; + comm : 128 : offset(5440), string } -> { state = state; + prio = prio; + static_prio = static_prio; + normal_prio = normal_prio; + tasks'next = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'next 192L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + tasks'prev = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'prev 200L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + active_mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr active_mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + comm = comm } + | { _ } -> raise (ParseError ("task_struct", "parser_7", "failed to match kernel structure"));; +let parser_8 bits = bitmatch bits with + | { state : zero+64 : offset(0), littleendian; + prio : zero+32 : offset(224), littleendian; + static_prio : zero+32 : offset(256), littleendian; + normal_prio : zero+32 : offset(288), littleendian; + tasks'next : zero+64 : offset(2816), littleendian; + tasks'prev : zero+64 : offset(2880), littleendian; + mm : zero+64 : offset(2944), littleendian; + active_mm : zero+64 : offset(3008), littleendian; + comm : 128 : offset(6592), string } -> { state = state; + prio = prio; + static_prio = static_prio; + normal_prio = normal_prio; + tasks'next = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'next 352L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + tasks'prev = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'prev 360L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + active_mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr active_mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + comm = comm } + | { _ } -> raise (ParseError ("task_struct", "parser_8", "failed to match kernel structure"));; +let parser_9 bits = bitmatch bits with + | { state : zero+64 : offset(0), bigendian; + prio : zero+32 : offset(224), bigendian; + static_prio : zero+32 : offset(256), bigendian; + normal_prio : zero+32 : offset(288), bigendian; + tasks'next : zero+64 : offset(2880), bigendian; + tasks'prev : zero+64 : offset(2944), bigendian; + mm : zero+64 : offset(3008), bigendian; + active_mm : zero+64 : offset(3072), bigendian; + comm : 128 : offset(6592), string } -> { state = state; + prio = prio; + static_prio = static_prio; + normal_prio = normal_prio; + tasks'next = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'next 360L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + tasks'prev = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'prev 368L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + active_mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr active_mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + comm = comm } + | { _ } -> raise (ParseError ("task_struct", "parser_9", "failed to match kernel structure"));; +let parser_10 bits = bitmatch bits with + | { state : zero+32 : offset(0), littleendian; + prio : zero+32 : offset(192), littleendian; + static_prio : zero+32 : offset(224), littleendian; + normal_prio : zero+32 : offset(256), littleendian; + tasks'next : zero+32 : offset(2208), littleendian; + tasks'prev : zero+32 : offset(2240), littleendian; + mm : zero+32 : offset(2400), littleendian; + active_mm : zero+32 : offset(2432), littleendian; + comm : 128 : offset(4608), string } -> { state = state; + prio = prio; + static_prio = static_prio; + normal_prio = normal_prio; + tasks'next = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'next 276L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + tasks'prev = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'prev 280L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + active_mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr active_mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + comm = comm } + | { _ } -> raise (ParseError ("task_struct", "parser_10", "failed to match kernel structure"));; +let parser_11 bits = bitmatch bits with + | { state : zero+64 : offset(0), littleendian; + prio : zero+32 : offset(224), littleendian; + static_prio : zero+32 : offset(256), littleendian; + normal_prio : zero+32 : offset(288), littleendian; + tasks'next : zero+64 : offset(3648), littleendian; + tasks'prev : zero+64 : offset(3712), littleendian; + mm : zero+64 : offset(3776), littleendian; + active_mm : zero+64 : offset(3840), littleendian; + comm : 128 : offset(7816), string } -> { state = state; + prio = prio; + static_prio = static_prio; + normal_prio = normal_prio; + tasks'next = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'next 456L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + tasks'prev = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'prev 464L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + active_mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr active_mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + comm = comm } + | { _ } -> raise (ParseError ("task_struct", "parser_11", "failed to match kernel structure"));; +let parser_12 bits = bitmatch bits with + | { state : zero+32 : offset(0), bigendian; + prio : zero+32 : offset(192), bigendian; + static_prio : zero+32 : offset(224), bigendian; + normal_prio : zero+32 : offset(256), bigendian; + tasks'next : zero+32 : offset(1024), bigendian; + tasks'prev : zero+32 : offset(1056), bigendian; + mm : zero+32 : offset(1088), bigendian; + active_mm : zero+32 : offset(1120), bigendian; + comm : 128 : offset(3264), string } -> { state = state; + prio = prio; + static_prio = static_prio; + normal_prio = normal_prio; + tasks'next = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'next 128L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + tasks'prev = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'prev 132L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + active_mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr active_mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + comm = comm } + | { _ } -> raise (ParseError ("task_struct", "parser_12", "failed to match kernel structure"));; +let parser_13 bits = bitmatch bits with + | { state : zero+64 : offset(0), littleendian; + prio : zero+32 : offset(224), littleendian; + static_prio : zero+32 : offset(256), littleendian; + normal_prio : zero+32 : offset(288), littleendian; + tasks'next : zero+64 : offset(3840), littleendian; + tasks'prev : zero+64 : offset(3904), littleendian; + mm : zero+64 : offset(3968), littleendian; + active_mm : zero+64 : offset(4032), littleendian; + comm : 128 : offset(8392), string } -> { state = state; + prio = prio; + static_prio = static_prio; + normal_prio = normal_prio; + tasks'next = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'next 480L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + tasks'prev = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'prev 488L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + active_mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr active_mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + comm = comm } + | { _ } -> raise (ParseError ("task_struct", "parser_13", "failed to match kernel structure"));; +let parser_14 bits = bitmatch bits with + | { state : zero+32 : offset(0), littleendian; + prio : zero+32 : offset(160), littleendian; + static_prio : zero+32 : offset(192), littleendian; + normal_prio : zero+32 : offset(224), littleendian; + tasks'next : zero+32 : offset(3008), littleendian; + tasks'prev : zero+32 : offset(3040), littleendian; + mm : zero+32 : offset(3072), littleendian; + active_mm : zero+32 : offset(3104), littleendian; + comm : 128 : offset(5416), string } -> { state = state; + prio = prio; + static_prio = static_prio; + normal_prio = normal_prio; + tasks'next = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'next 376L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + tasks'prev = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'prev 380L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + active_mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr active_mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + comm = comm } + | { _ } -> raise (ParseError ("task_struct", "parser_14", "failed to match kernel structure"));; +let parser_15 bits = bitmatch bits with + | { state : zero+32 : offset(0), littleendian; + prio : zero+32 : offset(160), littleendian; + static_prio : zero+32 : offset(192), littleendian; + normal_prio : zero+32 : offset(224), littleendian; + tasks'next : zero+32 : offset(2144), littleendian; + tasks'prev : zero+32 : offset(2176), littleendian; + mm : zero+32 : offset(2208), littleendian; + active_mm : zero+32 : offset(2240), littleendian; + comm : 128 : offset(4384), string } -> { state = state; + prio = prio; + static_prio = static_prio; + normal_prio = normal_prio; + tasks'next = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'next 268L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + tasks'prev = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'prev 272L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + active_mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr active_mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + comm = comm } + | { _ } -> raise (ParseError ("task_struct", "parser_15", "failed to match kernel structure"));; +let parser_16 bits = bitmatch bits with + | { state : zero+64 : offset(0), bigendian; + prio : zero+32 : offset(256), bigendian; + static_prio : zero+32 : offset(288), bigendian; + normal_prio : zero+32 : offset(320), bigendian; + tasks'next : zero+64 : offset(2880), bigendian; + tasks'prev : zero+64 : offset(2944), bigendian; + mm : zero+64 : offset(3264), bigendian; + active_mm : zero+64 : offset(3328), bigendian; + comm : 128 : offset(6912), string } -> { state = state; + prio = prio; + static_prio = static_prio; + normal_prio = normal_prio; + tasks'next = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'next 360L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + tasks'prev = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'prev 368L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + active_mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr active_mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + comm = comm } + | { _ } -> raise (ParseError ("task_struct", "parser_16", "failed to match kernel structure"));; +let parser_17 bits = bitmatch bits with + | { state : zero+32 : offset(0), bigendian; + prio : zero+32 : offset(160), bigendian; + static_prio : zero+32 : offset(192), bigendian; + normal_prio : zero+32 : offset(224), bigendian; + tasks'next : zero+32 : offset(3136), bigendian; + tasks'prev : zero+32 : offset(3168), bigendian; + mm : zero+32 : offset(3200), bigendian; + active_mm : zero+32 : offset(3232), bigendian; + comm : 128 : offset(5576), string } -> { state = state; + prio = prio; + static_prio = static_prio; + normal_prio = normal_prio; + tasks'next = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'next 392L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + tasks'prev = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'prev 396L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + active_mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr active_mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + comm = comm } + | { _ } -> raise (ParseError ("task_struct", "parser_17", "failed to match kernel structure"));; +let parser_18 bits = bitmatch bits with + | { state : zero+64 : offset(0), bigendian; + prio : zero+32 : offset(224), bigendian; + static_prio : zero+32 : offset(256), bigendian; + normal_prio : zero+32 : offset(288), bigendian; + tasks'next : zero+64 : offset(3648), bigendian; + tasks'prev : zero+64 : offset(3712), bigendian; + mm : zero+64 : offset(3776), bigendian; + active_mm : zero+64 : offset(3840), bigendian; + comm : 128 : offset(7752), string } -> { state = state; + prio = prio; + static_prio = static_prio; + normal_prio = normal_prio; + tasks'next = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'next 456L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + tasks'prev = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'prev 464L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + active_mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr active_mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + comm = comm } + | { _ } -> raise (ParseError ("task_struct", "parser_18", "failed to match kernel structure"));; +let parser_19 bits = bitmatch bits with + | { state : zero+64 : offset(0), littleendian; + prio : zero+32 : offset(320), littleendian; + static_prio : zero+32 : offset(352), littleendian; + normal_prio : zero+32 : offset(384), littleendian; + tasks'next : zero+64 : offset(1728), littleendian; + tasks'prev : zero+64 : offset(1792), littleendian; + mm : zero+64 : offset(1856), littleendian; + active_mm : zero+64 : offset(1920), littleendian; + comm : 128 : offset(5568), string } -> { state = state; + prio = prio; + static_prio = static_prio; + normal_prio = normal_prio; + tasks'next = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'next 216L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + tasks'prev = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'prev 224L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + active_mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr active_mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + comm = comm } + | { _ } -> raise (ParseError ("task_struct", "parser_19", "failed to match kernel structure"));; +let parser_20 bits = bitmatch bits with + | { state : zero+32 : offset(0), littleendian; + prio : zero+32 : offset(160), littleendian; + static_prio : zero+32 : offset(192), littleendian; + normal_prio : zero+32 : offset(224), littleendian; + tasks'next : zero+32 : offset(3232), littleendian; + tasks'prev : zero+32 : offset(3264), littleendian; + mm : zero+32 : offset(3296), littleendian; + active_mm : zero+32 : offset(3328), littleendian; + comm : 128 : offset(5928), string } -> { state = state; + prio = prio; + static_prio = static_prio; + normal_prio = normal_prio; + tasks'next = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'next 404L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + tasks'prev = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'prev 408L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + active_mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr active_mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + comm = comm } + | { _ } -> raise (ParseError ("task_struct", "parser_20", "failed to match kernel structure"));; +let parser_21 bits = bitmatch bits with + | { state : zero+64 : offset(0), littleendian; + prio : zero+32 : offset(256), littleendian; + static_prio : zero+32 : offset(288), littleendian; + normal_prio : zero+32 : offset(320), littleendian; + tasks'next : zero+64 : offset(1408), littleendian; + tasks'prev : zero+64 : offset(1472), littleendian; + mm : zero+64 : offset(1536), littleendian; + active_mm : zero+64 : offset(1600), littleendian; + comm : 128 : offset(5184), string } -> { state = state; + prio = prio; + static_prio = static_prio; + normal_prio = normal_prio; + tasks'next = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'next 176L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + tasks'prev = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'prev 184L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + active_mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr active_mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + comm = comm } + | { _ } -> raise (ParseError ("task_struct", "parser_21", "failed to match kernel structure"));; +let parser_22 bits = bitmatch bits with + | { state : zero+64 : offset(0), bigendian; + prio : zero+32 : offset(256), bigendian; + static_prio : zero+32 : offset(288), bigendian; + normal_prio : zero+32 : offset(320), bigendian; + tasks'next : zero+64 : offset(1472), bigendian; + tasks'prev : zero+64 : offset(1536), bigendian; + mm : zero+64 : offset(1600), bigendian; + active_mm : zero+64 : offset(1664), bigendian; + comm : 128 : offset(5184), string } -> { state = state; + prio = prio; + static_prio = static_prio; + normal_prio = normal_prio; + tasks'next = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'next 184L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + tasks'prev = (Virt_mem_mmap.unsafe_typed_addr_of_addr (Int64.sub tasks'prev 192L) : [ `task_struct ] Virt_mem_mmap.typed_addr); + mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + active_mm = (Virt_mem_mmap.unsafe_typed_addr_of_addr active_mm : [ `mm_struct ] Virt_mem_mmap.typed_addr); + comm = comm } + | { _ } -> raise (ParseError ("task_struct", "parser_22", "failed to match kernel structure"));; module StringMap = Map.Make(String);; let map = StringMap.empty;; let v = (parser_1, 2704);; @@ -36,6 +435,8 @@ let v = (parser_2, 1756);; let map = StringMap.add "2.6.22-0.23.rc7.git6.fc8.ppc" v map;; let v = (parser_1, 2704);; let map = StringMap.add "2.6.21-1.3128.fc7.i686" v map;; +let v = (parser_1, 2704);; +let map = StringMap.add "2.6.21-1.3132.fc7.i686" v map;; let v = (parser_3, 1780);; let map = StringMap.add "2.6.21-1.3236.fc8.ppc" v map;; let v = (parser_1, 1376);; @@ -56,12 +457,16 @@ let v = (parser_9, 2292);; let map = StringMap.add "2.6.22-0.23.rc7.git6.fc8.ppc64" v map;; let v = (parser_10, 2880);; let map = StringMap.add "2.6.21-1.3236.fc8.i686" v map;; +let v = (parser_6, 2132);; +let map = StringMap.add "2.6.21-1.3132.fc7.ppc64" v map;; let v = (parser_1, 1376);; let map = StringMap.add "2.6.21-1.3228.fc7.i686" v map;; let v = (parser_11, 4684);; let map = StringMap.add "2.6.24-9.fc9.x86_64" v map;; let v = (parser_9, 2292);; let map = StringMap.add "2.6.22-0.23.rc7.git6.fc8.ppc64" v map;; +let v = (parser_6, 2132);; +let map = StringMap.add "2.6.21-1.3132.fc7.ppc64" v map;; let v = (parser_1, 1384);; let map = StringMap.add "2.6.18-1.2798.fc6.i586" v map;; let v = (parser_12, 1620);; @@ -223,5 +628,10 @@ let map = StringMap.add "2.6.21-1.3209.fc8.ppc64" v map;; type kernel_version = string;; let known version = StringMap.mem version map;; let size version = let (_, size) = StringMap.find version map in size;; -let get version bits = +let of_bits version bits = let (parsefn, _) = StringMap.find version map in parsefn bits;; +let get version mem addr = + let (parsefn, size) = StringMap.find version map in + let addr = Virt_mem_mmap.unsafe_addr_of_typed_addr addr in + let bytes = Virt_mem_mmap.get_bytes mem addr size in + let bits = Bitstring.bitstring_of_string bytes in parsefn bits;; diff --git a/lib/kernel_task_struct.mli b/lib/kernel_task_struct.mli index e600878..2247c6f 100644 --- a/lib/kernel_task_struct.mli +++ b/lib/kernel_task_struct.mli @@ -1,10 +1,16 @@ -exception ParseError of string;; +exception ParseError of string * string * string;; type t = - { comm : string; normal_prio : int; prio : int; state : int; - static_prio : int; tasks'next : [ | `list_head ] int64; - tasks'prev : [ | `list_head ] int64 + { active_mm : [ | `mm_struct ] Virt_mem_mmap.typed_addr; comm : string; + mm : [ | `mm_struct ] Virt_mem_mmap.typed_addr; normal_prio : int64; + prio : int64; state : int64; static_prio : int64; + tasks'next : [ | `task_struct ] Virt_mem_mmap.typed_addr; + tasks'prev : [ | `task_struct ] Virt_mem_mmap.typed_addr };; type kernel_version = string;; val known : kernel_version -> bool;; val size : kernel_version -> int;; -val get : kernel_version -> Bitstring.bitstring -> t;; +val of_bits : kernel_version -> Bitstring.bitstring -> t;; +val get : + kernel_version -> + ('a, 'b, [ | `HasMapping ]) Virt_mem_mmap.t -> + [ | `task_struct ] Virt_mem_mmap.typed_addr -> t;;