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

ocamlrun: make debugging executable magic number issues easier #1793

Closed

Conversation

Projects
None yet
5 participants
@shindere
Copy link
Contributor

commented May 22, 2018

First, this PR provides a more precise error message in the case where the
magic number of an executable bytecode file differs from the one
expected by the runtime.
Instead of the "bad bytecode" message, bothe the expected and encountered
magic nubmers are reported.

Second, two command-line options are added to ocamlrun:

  • -m: print the magic number of the executable given as argument and exit

  • -M: print the magic number expected by this version of the runtime

These changes turn out to be useful when debugging the compiler's
bootstrap process.

Finally, this PR relies on #1787 which should hence be merged first.

@shindere shindere force-pushed the shindere:improve-exe-magic-number-handling branch from c326118 to c2d3c17 May 22, 2018

@@ -63,6 +63,11 @@ in the "OCAMLRUNPARAM" environment variable (see below).
Search the directory \var{dir} for dynamically-loaded libraries,
in addition to the standard search path (see
section~\ref{s-ocamlrun-dllpath}).
\item["-m"]
Print the magic number of the byte-code executable given as argument

This comment has been minimized.

Copy link
@xclerc

xclerc May 22, 2018

Contributor

This file seems to use "bytecode" rather than "byte-code".

@shindere shindere force-pushed the shindere:improve-exe-magic-number-handling branch from c2d3c17 to 7000f67 May 22, 2018

@shindere

This comment has been minimized.

Copy link
Contributor Author

commented May 22, 2018

@xavierleroy

This comment has been minimized.

Copy link
Contributor

commented May 23, 2018

Now that #1787 is merged, it would help review if you'd rebase this GPR.

@shindere shindere force-pushed the shindere:improve-exe-magic-number-handling branch from 7000f67 to 062ce06 May 23, 2018

@shindere

This comment has been minimized.

Copy link
Contributor Author

commented May 23, 2018

@gasche

This comment has been minimized.

Copy link
Member

commented May 23, 2018

Note: this is related to #463, but completely orthogonal as far as I can tell, as that PR wasn't touching the C code at all.

@shindere shindere force-pushed the shindere:improve-exe-magic-number-handling branch from 062ce06 to 393d017 May 24, 2018

shindere added some commits May 15, 2018

runtime: improve error reporting when given an exe with a wrong magic…
… number

The error message includes both the expected and the encountered
magic numbers.
Add the -m and -M command-line options to ocamlrun
- -m shows the magic number of the bytecode executable given as argument

- -M shows the magic number this runtime expects

@shindere shindere force-pushed the shindere:improve-exe-magic-number-handling branch from 393d017 to 2e7ec17 May 25, 2018

@damiendoligez
Copy link
Member

left a comment

Approved modulo a small change to the printf line.

@shindere shindere closed this May 25, 2018

@shindere shindere deleted the shindere:improve-exe-magic-number-handling branch May 25, 2018

@shindere

This comment has been minimized.

Copy link
Contributor Author

commented May 25, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.