Add absolute directory names to bytecode format for ocamldebug to use#14
Add absolute directory names to bytecode format for ocamldebug to use#14jwatzman wants to merge 1 commit intoocaml:trunkfrom
Conversation
|
I tried to review this patch but failed for two reasons:
|
Once again, thanks so much for taking the time to look at this!
I believe that they are in fact being used. This is the intent of my changes to https://gist.github.com/jwatzman/9162697 is the file I've been using to test these changes. Here's a transcript of my test; I moved the binary -- but not the source -- into a different directory to simulate this being a more complex project across several submodules. I also tested this change with an internal project at Facebook and it worked well there too; unfortunately that code not publicly available at this time so I can't give you steps to check this yourself.
I didn't add this to the commit message, but would be happy to do so. Here are his two concerns and my thoughts on them:
This is no longer the case; the debug events are unmodified in this version of the patch.
The specific concern here, about sharing in pos_fname, is no longer relevant since I don't change pos_fname anymore. The more general concern around increasing the size of the bytecode is potentially still valid. However, I don't think this is a big deal at all -- it only increases by the size of the path length of the //directory// names in a given compilation unit -- not the full source file name. I'm careful to use a Set in order to ensure that the directory names are deduplicated and written into the bytecode only once. This is basically the minimal amount of information you need in order to get the core idea of this patch to work at all -- you have to store directory information somewhere in order to find your original source files. I think the tradeoff of a tiny bit more space for this is absolutely worth it to avoid the contortions to come up with a list of Furthermore, those who really do care about this space efficiency can just turn off
As above, the
I'm not sure what you mean by this. Do you mean that a different system that just so happens to have the same directory layout but totally different files in those directories might make In any event, again I think the added ease of use of Or do I misunderstand and you're getting at something else? Again, thanks for your feedback, and looking forward to your response! |
I do agree with this sentiment for |
|
Thanks for your detailed reply. Given the new patch is much less invasive than the previous one, I mistakenly assumed that it was only part of the changes. I'll try to give it another look as soon as possible. |
|
No problem! This patch should stand alone (and replace the original version on Mantis), and is indeed much less invasive than that previous version -- thanks for the suggestion to include the information in the debug section, it works out a lot better IMO. |
|
I just had a quick look. |
|
I haven't had time to look at it again, sorry. But in any case, I probably won't be the one to make a decision regarding this patch, as I now little about the debugger. Any upstreaming decision would have to be made by someone knowledgeable, such as Alain Frisch or Xavier Clerc. |
|
Updated from jwatzman@f67ba3b to jwatzman@913d2e3 -- moved the new information to the end of the debug section as suggested, which I'm pretty sure means I don't need a format magic number bump or any of the code to skip over the data at the beginning of the section. (Not sure why I put it there to begin with, thanks for pointing out that oversight!) I will see if I can get Alain Frisch or Xavier Clerc to take a look at this, thanks for giving me the pointers. |
|
I only had a first/quick look at the patch. It seems correct, |
|
Thanks for taking a look! I had bumped the magic numbers in a previous version of this patch, but un-did it when I moved the new information to the end of the debug section, since it seems things are now backwards-compatible. (Old programs just won't know there is more to read in the debug section before they go off and seek to another section, but the information that currently exists will remain in the same place.) If that logic is incorrect I'm happy to re-bump the number :) Do I need to bump just the cmo version? I had previously bumped the exec, cmi, cmo, and cma magic numbers, though that was based on intuition ("just bump all the bytecode versions") and some looking back thru previous commits, not any real information. |
|
I have zero experience with the bytecode debugger, so I'll let someone else (xclerc?) decide. |
|
I just had a look at the code. Three things (only opinions/questions, none of them "blocking"):
The two questions are about the
|
Agreed, will fix.
I didn't delegate to I'll wait incorporate both of these changes with any additional changes that @xclerc suggests when he responds. |
|
I think the idea of appending rather than prepending is good. |
|
Okay, so I still need to:
Will wait to update patch on answer to question above. |
|
Since you change the file format of cmo files, it seems pretty clear that you need to change the magic number of cmo files. If you still have .cmo files around generated by an older version of the compiler and you try to link them with the new version, it will try to do an extra input_value, which will fail. Or did I missed something? |
|
Sorry for missing the magic number part. I second @alainfrisch opinion; |
|
Aha, I see. Yeah that makes sense. Will send an updated diff with all the suggested revisions in the next couple days. Thanks again for the reviews! |
|
Updated from jwatzman@913d2e3 to jwatzman@395b924 -- I believe I fixed all the issues requested above. Let me know if there's anything else that still needs to be done! Excited to get this committed :) |
|
Closing, since this has been merged to trunk (dd7bd5b). |
|
I had to temporarily revert the commit as it broke the backtrace testsuite. To reproduce the failure, you can do: I'm sorry for not noticing this earlier (code review is good but we should have caught the testsuite failure). I'm not sure where the error comes from; it may be a trivially fixable issue of bootstrap after the magic number change. |
|
Drat, I could have sworn I ran the testsuite myself anyways. Thanks for letting me know -- I'll take a look. |
|
I took a quick look at this and sadly it's not as simple as a magic number bump (or at least if it is, it was non-obvious where that needed to happen :)). The backtrace code seems to be trying to read a bad value out of somewhere in the bytecode. I will take a closer look at it in the next few days, but it does look like a legitimate bug in my patch somewhere. |
The need for a long list of -I directives makes interactively using ocamldebug a pain in the butt. Many folks have solved this with various `find` invocations or even Python wrappers, but those lead to other problems when it might include files you weren't expecting (or miss things you were). But all of this is really annoying since the tooling should be able to figure out itself, even heuristically, where your source files are -- gdb gets this right, why can't we? This patch implements one of the more important heuristics from gdb: you typically debug on the same machine you built on, so looking for the source files and built artifacts in the absolute paths where they were during compilation is a good first try. We write out absolute paths into a new structure at the beginning of the debug section and then automatically append those directories into the load path. This means mean that if you happen to be debugging on a machine where the original source and build artifacts are *not* available in their original absolute locations, things will work as before, using the standard load path mechanism. You can also explicitly use -I to prepend directories to the load path and override the defaults located by this new mechanism. I personally find this makes using ocamldebug much more pleasant :)
|
Updated from jwatzman@395b924 to jwatzman@cc5bc17 -- I needed to ignore the new information in a couple of places, notably The entire test suite now passes, except for |
|
Indeed. It also affect js_of_ocaml. thanks |
Stw plus safepoints
* Use effects and coeffects of primitives in middle_end Currently only used when builtin=true. * Remove the constraint on builtin=true Use effect and coeffect of Primitive in Semantics_of_primitives even for primitives that don't have builtin=true
Make integer conversions macros and update hyperfine result parsing script
import tutorials from ocaml.org and convert to mdx
Continuation of http://caml.inria.fr/mantis/view.php?id=6270
The need for a long list of -I directives makes interactively using
ocamldebug a pain in the butt. Many folks have solved this with various
findinvocations or even Python wrappers, but those lead to otherproblems when it might include files you weren't expecting (or miss
things you were). But all of this is really annoying since the tooling
should be able to figure out itself, even heuristically, where your
source files are -- gdb gets this right, why can't we?
This patch implements one of the more important heuristics from gdb: you
typically debug on the same machine you built on, so looking for the
source files and built artifacts in the absolute paths where they were
during compilation is a good first try. We write out absolute paths into
a new structure at the beginning of the debug section and then
automatically append those directories into the load path.
This means mean that if you happen to be debugging on a machine
where the original source and build artifacts are not available in
their original absolute locations, things will work as before, using the
standard load path mechanism. You can also explicitly use -I to prepend
directories to the load path and override the defaults located by this
new mechanism.
I personally find this makes using ocamldebug much more pleasant :)