Open jiseongg opened 3 years ago
You need to build infer in bytecode mode first. make byte
will do that for you.
@jvillard
Should I do that from Infer root directory again? It seems that running make byte
in the project root directory also builds the facebook-clang-plugins
again, even though I had built Infer completely before with ./build-infer.sh
. It will take really long time. Thus, I stopped it and did it again in infer/src
directory to check if it works.
After running make BUILD_MODE=dev-noerror -C infer/src byte
, infer.bc.exe
is generated and infer
binary is updated. However, "not a bytecode file" message still remains and I cannot debug it with ocamldebug.
You're right, make byte
doesn't produce something that ocamldebug
can consume anymore, I think since 786a72574fc6943c5635f3cb1a7abb417013c9b5 so that way of debugging infer is not available anymore.
I think so, too. Is that normal situation for OCaml project or only for Infer? Since I'm newbie in such large project written in OCaml, I'm just curious.
Then the only way to debug Infer is to use Logging
module to print internal data, right?
@jiseongg Have you found any other good debugging methods? and Can you recommend any debugging methods that you have used in your projects?
From. Seoul, Korea too :)
Currently, make byte
is building infer with the byte_complete
mode.
byte_complete for building a bytecode executable as a native self-contained executable, i.e., an executable that doesn’t require the ocamlrun program to run and doesn’t require the C stubs to be installed as shared object files.
https://dune.readthedocs.io/en/stable/dune-files.html#linking-modes
And it does not seem to work well with ocamldebug.
https://github.com/ocaml/ocaml/issues/9344
Therefore, to run ocamldebug, we need to build it as the byte
mode and run it with proper libarary paths, e.g.
.bc.exe
to .bc
in infer/src/Makefile
byte_complete
to byte
in infer/src/dune.in
~/infer/infer/src$ make byte
~/infer/infer/src$ CAML_LD_LIBRARY_PATH=../_build/default/src/c_stubs:$CAML_LD_LIBRARY_PATH ocamldebug ../bin/infer.bc --version
OCaml Debugger version 4.14.0
(ocd) goto 0
Loading program... done.
Time: 0
Beginning of program.
(ocd) run
Infer version v1.1.0-ed404b4acb
Copyright 2009 - present Facebook. All Rights Reserved.
Time: 11399552
Program exit.
Then the only way to debug Infer is to use Logging module to print internal data, right?
Yes. But, for me, Logging
has worked well for developing/debugging Infer in most of the cases so far.
@skcho Thank you for your response! It has been a great help in using/debugging Infer!
@MarsMan13,
At the time, I failed to figure out the solution about using ocamldebug
, and I forgot about this issue.
Hope @skcho 's answer helped. :)
Anyway, I used Logging.debug_dev
function, which could print anything I wanted to html files.
(I had read this from CONTRIBUTING.md)
@jiseongg Thank you for your response!!!! Yes! @skcho 's solution is very useful for me!! Thank you!!
I have a question about how to debug Infer line-by-line. According to #536, that debugging environment doesn't seem to be prepared. However, I'm confused because the section Debugging OCaml Code in CONTRIBUTING.md assumes someone may use
ocamldebug
. Following is the situation I've faced, which implies what I want to do, including some information of my environment.ocamldebug <PATH_TO_BIN>/infer analyze --pulse-only
ocamldebug
(ocd) goto 0 Loading program... /home/vagrant/github/facebook/infer/examples/c_hello/../../infer/bin/infer is not a bytecode file. (ocd)