caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Print dependencies of a module, and other useful functions
@ 2003-08-07 13:04 Richard Jones
  2003-08-07 13:23 ` Michal Moskal
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Jones @ 2003-08-07 13:04 UTC (permalink / raw)
  To: caml-list


Are there any equivalents to the following functions / programs for
OCaml?

'gcc -MM' / 'gcc -MMD'
	Print dependencies of a module. Useful for me for building
	robust Makefiles.

'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".

Also in the debugger, how can I get OCaml to display the parameters
being passed to a function in the stack trace. At the moment I just
see things like:

#0  Pc : 453960  ZAssocs char 2550
#1  Pc : 452492  ZAssocs char 5608
#2  Pc : 14044  List char 1961
#3  Pc : 476772  Model char 24895
#4  Pc : 476772  Model char 24895
#5  Pc : 476772  Model char 24895
#6  Pc : 476800  Model char 24880
#7  Pc : 513364  Simulator char 4635
#8  Pc : 565728  Main char 14244
#9  Pc : 446708  Lib char 711
#10  Pc : 565972  Main char 14494

which is not very useful. It would be nice to show args too.

Rich.

-- 
Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj
Merjis Ltd. http://www.merjis.com/ - all your business data are belong to you.
'There is a joke about American engineers and French engineers. The
American team brings a prototype to the French team. The French team's
response is: "Well, it works fine in practice; but how will it hold up
in theory?"'

-------------------
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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Print dependencies of a module, and other useful functions
  2003-08-07 13:04 [Caml-list] Print dependencies of a module, and other useful functions Richard Jones
@ 2003-08-07 13:23 ` Michal Moskal
  2003-08-15 13:21   ` Stefano Zacchiroli
  0 siblings, 1 reply; 6+ messages in thread
From: Michal Moskal @ 2003-08-07 13:23 UTC (permalink / raw)
  To: Richard Jones; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 653 bytes --]

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

[-- Attachment #2: ocaml-objinfo.patch --]
[-- Type: text/plain, Size: 1826 bytes --]

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Print dependencies of a module, and other useful functions
  2003-08-07 13:23 ` Michal Moskal
@ 2003-08-15 13:21   ` Stefano Zacchiroli
  2003-08-15 13:36     ` Michal Moskal
  2003-08-15 13:42     ` Richard Jones
  0 siblings, 2 replies; 6+ messages in thread
From: Stefano Zacchiroli @ 2003-08-15 13:21 UTC (permalink / raw)
  To: caml-list; +Cc: Richard Jones

On Thu, Aug 07, 2003 at 03:23:14PM +0200, Michal Moskal wrote:
> Try looking at tools/objinfo.ml. I have a patch for it to support also
> *.cmx* files. You'll find it attached.

Have you proposed this patch upstream?

I'm using objinfo to check for consistencies over a set of ocaml
"objects" and I find really tedious the lack of *.cmx* support ...

Cheers.

-- 
Stefano Zacchiroli  --  Master in Computer Science @ Uni. Bologna, Italy
zack@{cs.unibo.it,debian.org,bononia.it}  -  http://www.bononia.it/zack/
"  I know you believe you understood what you think I said, but I am not
sure you realize that what you heard is not what I meant!  " -- G.Romney

-------------------
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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Print dependencies of a module, and other useful functions
  2003-08-15 13:21   ` Stefano Zacchiroli
@ 2003-08-15 13:36     ` Michal Moskal
  2003-08-18 11:06       ` Sven Luther
  2003-08-15 13:42     ` Richard Jones
  1 sibling, 1 reply; 6+ messages in thread
From: Michal Moskal @ 2003-08-15 13:36 UTC (permalink / raw)
  To: caml-list

On Fri, Aug 15, 2003 at 03:21:59PM +0200, Stefano Zacchiroli wrote:
> On Thu, Aug 07, 2003 at 03:23:14PM +0200, Michal Moskal wrote:
> > Try looking at tools/objinfo.ml. I have a patch for it to support also
> > *.cmx* files. You'll find it attached.
> 
> Have you proposed this patch upstream?
> 
> I'm using objinfo to check for consistencies over a set of ocaml
> "objects" and I find really tedious the lack of *.cmx* support ...

I'm not sure about architectures that lack native compiler (I don't have
access for any for that matter). That's why I didn't propse it.

-- 
: 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

-------------------
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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Print dependencies of a module, and other useful functions
  2003-08-15 13:21   ` Stefano Zacchiroli
  2003-08-15 13:36     ` Michal Moskal
@ 2003-08-15 13:42     ` Richard Jones
  1 sibling, 0 replies; 6+ messages in thread
From: Richard Jones @ 2003-08-15 13:42 UTC (permalink / raw)
  To: caml-list

On Fri, Aug 15, 2003 at 03:21:59PM +0200, Stefano Zacchiroli wrote:
> On Thu, Aug 07, 2003 at 03:23:14PM +0200, Michal Moskal wrote:
> > Try looking at tools/objinfo.ml. I have a patch for it to support also
> > *.cmx* files. You'll find it attached.
> 
> Have you proposed this patch upstream?
> 
> I'm using objinfo to check for consistencies over a set of ocaml
> "objects" and I find really tedious the lack of *.cmx* support ...

Agreed, it's really useful. It'd be even better if it could
deconstruct the various types of compiled binaries that
ocamlc/ocamlopt can produce.

Rich.

-- 
Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj
Merjis Ltd. http://www.merjis.com/ - all your business data are belong to you.
 All new technology is irrelevant until it is taken up by the public.

-------------------
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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Print dependencies of a module, and other useful functions
  2003-08-15 13:36     ` Michal Moskal
@ 2003-08-18 11:06       ` Sven Luther
  0 siblings, 0 replies; 6+ messages in thread
From: Sven Luther @ 2003-08-18 11:06 UTC (permalink / raw)
  To: caml-list

On Fri, Aug 15, 2003 at 03:36:24PM +0200, Michal Moskal wrote:
> On Fri, Aug 15, 2003 at 03:21:59PM +0200, Stefano Zacchiroli wrote:
> > On Thu, Aug 07, 2003 at 03:23:14PM +0200, Michal Moskal wrote:
> > > Try looking at tools/objinfo.ml. I have a patch for it to support also
> > > *.cmx* files. You'll find it attached.
> > 
> > Have you proposed this patch upstream?
> > 
> > I'm using objinfo to check for consistencies over a set of ocaml
> > "objects" and I find really tedious the lack of *.cmx* support ...
> 
> I'm not sure about architectures that lack native compiler (I don't have
> access for any for that matter). That's why I didn't propse it.

Let us test it in the debian package. We have 11 supported
architectures, Only 6 of them being supported by the native compiler.
And Stefano has access to all of them (except possibly mips and mipsel i
think).

Friendly,

Sven Luther
> 
> -- 
> : 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
> 
> -------------------
> 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

-------------------
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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-08-18  9:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-07 13:04 [Caml-list] Print dependencies of a module, and other useful functions Richard Jones
2003-08-07 13:23 ` Michal Moskal
2003-08-15 13:21   ` Stefano Zacchiroli
2003-08-15 13:36     ` Michal Moskal
2003-08-18 11:06       ` Sven Luther
2003-08-15 13:42     ` Richard Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).