Skip to content

Commit

Permalink
Merge pull request #10846 from voodoos/objinfo-optional-shape
Browse files Browse the repository at this point in the history
Shapes: Optionally print shape in ocamlobjinfo
  • Loading branch information
Octachron committed Jan 24, 2022
2 parents 0c8f366 + 7125d39 commit 488a28a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Changes
Expand Up @@ -252,6 +252,10 @@ OCaml 4.14.0
- #10527: Show "#help;; for help" at toplevel startup
(Wiktor Kuchta, review by David Allsopp and Florian Angeletti)

- #10846: add the `-shape` command-line option to ocamlobjinfo. When reading a
`cmt` file, shape information will only be shown if that option is used.
(Ulysse Gérard, review by Florian Angeletti)

### Debugging:

- #10517, #10594: when running ocamldebug on a program linked with the
Expand Down
7 changes: 6 additions & 1 deletion tools/objinfo.ml
Expand Up @@ -28,6 +28,7 @@ open Cmo_format
let no_approx = ref false
let no_code = ref false
let no_crc = ref false
let shape = ref false

module Magic_number = Misc.Magic_number

Expand Down Expand Up @@ -115,10 +116,12 @@ let print_cmt_infos cmt =
(match cmt.cmt_interface_digest with
| None -> ""
| Some crc -> string_of_crc crc);
printf "Implementation shape: ";
if !shape then begin
printf "Implementation shape: ";
(match cmt.cmt_impl_shape with
| None -> printf "(none)\n"
| Some shape -> Format.printf "\n%a" Shape.print shape)
end

let print_general_infos name crc defines cmi cmx =
printf "Name: %s\n" name;
Expand Down Expand Up @@ -387,6 +390,8 @@ let arg_list = [
" Do not print module approximation information";
"-no-code", Arg.Set no_code,
" Do not print code from exported flambda functions";
"-shape", Arg.Set shape,
" Print the shape of the module";
"-null-crc", Arg.Set no_crc, " Print a null CRC for imported interfaces";
"-args", Arg.Expand Arg.read_arg,
"<file> Read additional newline separated command line arguments \n\
Expand Down

0 comments on commit 488a28a

Please sign in to comment.