Add .gitignore file for git.
[virt-mem.git] / extract / codegen / code_generation.ml
index d451349..b465e4b 100644 (file)
@@ -531,12 +531,21 @@ let generate_followers names xs =
              match typ with
              | PP.FListHeadPointer _ ->
                  <:expr<
-                   (* For list head pointers, add the address of the base
+                   if debug then
+                     eprintf "%s_follower: %s: list_head pointing at a %s\n"
+                       $str:struct_name$ $str:name$ $str:dest_struct_name$;
+
+                   (* For list head pointers, add the address of the base
                     * of this virtual structure to the map, then adjust
                     * the pointer.
                     *)
                    let offset = data.$lid:struct_name^"_"^name^"_offset"$
                    and adj = data.$lid:struct_name^"_"^name^"_adjustment"$ in
+
+                   if debug then
+                     eprintf "%s_follower: %s: offset=%d adjustment=%d\n"
+                       $str:struct_name$ $str:name$ offset adj;
+
                    let offset = Int64.of_int offset
                    and adj = Int64.of_int adj in
 
@@ -555,17 +564,27 @@ let generate_followers names xs =
                     * adjustment applied.
                     *)
                    let dest_addr = Int64.sub dest_addr adj in
+
+                   if debug then
+                     eprintf "%s_follower: %s: dest_addr=%Lx\n"
+                       $str:struct_name$ $str:name$ dest_addr;
+
                    let map =
                      $lid:dest_struct_name^"_follower"$
-                       kernel_version load map dest_addr in
+                       debug kernel_version load map dest_addr in
                    map
                  >>
 
              | PP.FStructPointer _ ->
                  <:expr<
+                   if debug then
+                     eprintf "%s_follower: %s: is a struct pointer pointing to a %s; dest_addr=%Lx\n"
+                       $str:struct_name$ $str:name$
+                       $str:dest_struct_name$ dest_addr;
+
                    let map =
                      $lid:dest_struct_name^"_follower"$
-                       kernel_version load map dest_addr in
+                       debug kernel_version load map dest_addr in
                    map
                  >>
 
@@ -591,7 +610,9 @@ let generate_followers names xs =
       let struct_name_uc = String.capitalize struct_name in
 
       <:binding<
-       $lid:struct_name^"_follower"$ kernel_version load map addr =
+       $lid:struct_name^"_follower"$ debug kernel_version load map addr =
+         if debug then
+           eprintf "%s_follower: addr = %Lx\n" $str:struct_name$ addr;
           if addr <> 0L && not (AddrMap.mem addr map) then (
            let parser_ = $lid:"parser_of_"^struct_name$ kernel_version in
            let total_size = $lid:"size_of_"^struct_name$ kernel_version in
@@ -614,7 +635,7 @@ let generate_followers names xs =
     fun (struct_name, _) ->
       <:sig_item<
         val $lid:struct_name^"_follower"$ :
-         kernel_version -> load_fn -> addrmap -> Virt_mem_mmap.addr ->
+         bool -> kernel_version -> load_fn -> addrmap -> Virt_mem_mmap.addr ->
          addrmap
       >>
   ) xs in