From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA21730; Thu, 7 Aug 2003 15:24:39 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA12102 for ; Thu, 7 Aug 2003 15:24:38 +0200 (MET DST) Received: from ep09.kernel.pl (ep09.kernel.pl [212.87.11.162]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h77DORT17318 for ; Thu, 7 Aug 2003 15:24:28 +0200 (MET DST) Received: (qmail 8066 invoked by uid 566); 7 Aug 2003 13:24:11 -0000 Date: Thu, 7 Aug 2003 15:23:14 +0200 From: Michal Moskal To: Richard Jones Cc: caml-list@inria.fr Subject: Re: [Caml-list] Print dependencies of a module, and other useful functions Message-ID: <20030807132314.GA32161@roke.freak> Mail-Followup-To: Richard Jones , caml-list@inria.fr References: <20030807130419.GA5044@redhat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="s2ZSL+KKDSLx8OML" Content-Disposition: inline In-Reply-To: <20030807130419.GA5044@redhat.com> User-Agent: Mutt/1.4.1i X-PGP-Fingerprint: CF89 1B14 11BE 1CC9 2CA3 7497 5E32 69B4 BC71 B4C2 X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; michal:01 moskal:01 malekith:01 pld-linux:01 caml-list:01 dependencies:01 ocamldep:01 dynlink:01 cmx:01 crcs:01 digest:01 spaced:01 intf:01 comps:99 buffer:01 X-Attachments: name="ocaml-objinfo.patch" Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk --s2ZSL+KKDSLx8OML Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Aug 07, 2003 at 02:04:19PM +0100, Richard Jones wrote: > 'gcc -MM' / 'gcc -MMD' > Print dependencies of a module. Useful for me for building > robust Makefiles. ocamldep > 'nm' / 'nm -D' > List symbols exported by an OCaml bytecode "binary". Would > help me solve my ongoing Dynlink problems. > > 'objdump' > List other useful information from an OCaml bytecode "binary". Try looking at tools/objinfo.ml. I have a patch for it to support also *.cmx* files. You'll find it attached. -- : Michal Moskal :: http://www.kernel.pl/~malekith : GCS {C,UL}++++$ a? !tv : When in doubt, use brute force. -- Ken Thompson : {E-,w}-- {b++,e}>+++ h --s2ZSL+KKDSLx8OML Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ocaml-objinfo.patch" diff -ur ocaml-3.04/tools/objinfo.ml ocaml-3.04-/tools/objinfo.ml --- ocaml-3.04/tools/objinfo.ml Mon Mar 27 14:18:09 2000 +++ ocaml-3.04-/tools/objinfo.ml Wed May 8 11:30:02 2002 @@ -62,6 +62,29 @@ print_string name; print_newline()) crcs +let print_opt_info ui = + print_string " Unit name: "; print_string ui.Compilenv.ui_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()) + ui.Compilenv.ui_imports_cmi; + print_string " Infos imported:"; print_newline(); + List.iter + (fun (name, digest) -> + print_string "\t"; print_digest digest; print_string "\t"; + print_string name; print_newline()) + ui.Compilenv.ui_imports_cmx + +let print_opt_library_info lib = + print_string " Extra C object files:"; + List.iter print_spaced_string lib.Compilenv.lib_ccobjs; print_newline(); + print_string " Extra C options:"; + List.iter print_spaced_string lib.Compilenv.lib_ccopts; print_newline(); + List.iter print_opt_info (List.map fst lib.Compilenv.lib_units) + let dump_obj filename = print_string "File "; print_string filename; print_newline(); let ic = open_in_bin filename in @@ -86,6 +109,16 @@ let crcs = input_value ic in close_in ic; print_intf_info name sign comps crcs + end else + if buffer = cmx_magic_number then begin + let ui = (input_value ic : Compilenv.unit_infos) in + close_in ic; + print_opt_info ui + end else + if buffer = cmxa_magic_number then begin + let li = (input_value ic : Compilenv.library_infos) in + close_in ic; + print_opt_library_info li end else begin prerr_endline "Not an object file"; exit 2 end --s2ZSL+KKDSLx8OML-- ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners