1995-10-09 06:37:11 -07:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Objective Caml *)
|
1995-10-09 06:37:11 -07:00
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Copyright 1996 Institut National de Recherche en Informatique et *)
|
1999-11-17 10:59:06 -08:00
|
|
|
(* en Automatique. All rights reserved. This file is distributed *)
|
|
|
|
(* under the terms of the Q Public License version 1.0. *)
|
1995-10-09 06:37:11 -07:00
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
(* $Id$ *)
|
|
|
|
|
|
|
|
(* Dump a compilation unit description *)
|
|
|
|
|
|
|
|
open Config
|
2006-07-05 05:09:18 -07:00
|
|
|
open Cmo_format
|
1995-10-09 06:37:11 -07:00
|
|
|
|
|
|
|
let print_digest d =
|
|
|
|
for i = 0 to String.length d - 1 do
|
|
|
|
Printf.printf "%02x" (Char.code d.[i])
|
|
|
|
done
|
|
|
|
|
1996-09-09 05:37:10 -07:00
|
|
|
let print_info cu =
|
1995-10-09 06:37:11 -07:00
|
|
|
print_string " Unit name: "; print_string cu.cu_name; print_newline();
|
|
|
|
print_string " Interfaces imported:"; print_newline();
|
|
|
|
List.iter
|
|
|
|
(fun (name, digest) ->
|
|
|
|
print_string "\t"; print_digest digest; print_string "\t";
|
|
|
|
print_string name; print_newline())
|
|
|
|
cu.cu_imports;
|
|
|
|
print_string " Uses unsafe features: ";
|
1995-11-05 09:32:12 -08:00
|
|
|
begin match cu.cu_primitives with
|
|
|
|
[] -> print_string "no"; print_newline()
|
|
|
|
| l -> print_string "YES"; print_newline();
|
|
|
|
print_string " Primitives declared in this module:";
|
|
|
|
print_newline();
|
|
|
|
List.iter
|
|
|
|
(fun name -> print_string "\t"; print_string name; print_newline())
|
|
|
|
l
|
|
|
|
end
|
1995-10-09 06:37:11 -07:00
|
|
|
|
2000-03-27 04:18:09 -08:00
|
|
|
let print_spaced_string s = print_char ' '; print_string s
|
|
|
|
|
|
|
|
let print_library_info lib =
|
|
|
|
print_string " Force custom: ";
|
|
|
|
print_string (if lib.lib_custom then "YES" else "no");
|
|
|
|
print_newline();
|
|
|
|
print_string " Extra C object files:";
|
|
|
|
List.iter print_spaced_string lib.lib_ccobjs; print_newline();
|
|
|
|
print_string " Extra C options:";
|
|
|
|
List.iter print_spaced_string lib.lib_ccopts; print_newline();
|
|
|
|
List.iter print_info lib.lib_units
|
|
|
|
|
1998-12-02 02:58:40 -08:00
|
|
|
let print_intf_info name sign comps crcs =
|
|
|
|
print_string " Module name: "; print_string name; print_newline();
|
|
|
|
print_string " Interfaces imported:"; print_newline();
|
|
|
|
List.iter
|
|
|
|
(fun (name, digest) ->
|
|
|
|
print_string "\t"; print_digest digest; print_string "\t";
|
|
|
|
print_string name; print_newline())
|
|
|
|
crcs
|
|
|
|
|
1996-09-09 05:37:10 -07:00
|
|
|
let dump_obj filename =
|
|
|
|
print_string "File "; print_string filename; print_newline();
|
|
|
|
let ic = open_in_bin filename in
|
|
|
|
let buffer = String.create (String.length cmo_magic_number) in
|
|
|
|
really_input ic buffer 0 (String.length cmo_magic_number);
|
|
|
|
if buffer = cmo_magic_number then begin
|
|
|
|
let cu_pos = input_binary_int ic in
|
|
|
|
seek_in ic cu_pos;
|
|
|
|
let cu = (input_value ic : compilation_unit) in
|
|
|
|
close_in ic;
|
|
|
|
print_info cu
|
|
|
|
end else
|
|
|
|
if buffer = cma_magic_number then begin
|
|
|
|
let toc_pos = input_binary_int ic in
|
|
|
|
seek_in ic toc_pos;
|
2000-03-27 04:18:09 -08:00
|
|
|
let toc = (input_value ic : library) in
|
1996-09-09 05:37:10 -07:00
|
|
|
close_in ic;
|
2000-03-27 04:18:09 -08:00
|
|
|
print_library_info toc
|
1998-12-02 02:58:40 -08:00
|
|
|
end else
|
|
|
|
if buffer = cmi_magic_number then begin
|
|
|
|
let (name, sign, comps) = input_value ic in
|
|
|
|
let crcs = input_value ic in
|
|
|
|
close_in ic;
|
|
|
|
print_intf_info name sign comps crcs
|
1996-09-09 05:37:10 -07:00
|
|
|
end else begin
|
|
|
|
prerr_endline "Not an object file"; exit 2
|
|
|
|
end
|
|
|
|
|
1995-10-09 06:37:11 -07:00
|
|
|
let main() =
|
|
|
|
for i = 1 to Array.length Sys.argv - 1 do
|
|
|
|
dump_obj Sys.argv.(i)
|
2005-06-22 05:45:55 -07:00
|
|
|
done;
|
|
|
|
exit 0
|
1995-10-09 06:37:11 -07:00
|
|
|
|
2005-06-22 05:45:55 -07:00
|
|
|
let _ = main ()
|