Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shapes: Optionally print shape in ocamlobjinfo #10846

Merged
merged 2 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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