Debug mapping is sometimes inconsistent with installed locations
Nobody has claimed this yet.
- Dominant language
- OCaml
- Stars
- 1.9k
- Forks
- 500
- Avg merge
- 15h 21m
- Merged PRs (30d)
- 277
Description
Expected Behavior
Consider a simple project with one library and a single package, mypackage.
Here is the source layout:
- dune-project
- lib/
- dune
- lib1.ml
Here is an excerpt from the dune-project file:
(lang dune 3.7)
(name mypackage)
(package
(name mypackage))
And here is the "lib/dune" file:
(library
(name lib1)
(public_name mypackage.lib1)
(modes byte)
)
I did a dune install --prefix _opamroot and here is an excerpt of the layout it produced:
_opamroot/
_opamroot/lib
_opamroot/lib/mypackage
_opamroot/lib/mypackage/lib1
_opamroot/lib/mypackage/lib1/lib1.ml
_opamroot/lib/mypackage/lib1/lib1.cma
Now, when the debugger is debugging a program that used this library, we would want the debug information from the library to be:
/workpace_root/mypackage/lib1
so that after the debugger does a mapping from /workspace_root to opamroot/lib, that the directory will become
opamroot/lib/mypackage/lib1
which is where the source code and '.cma' file are located.
Actual Behavior
The following debug directories were produced in the 'lib1.cma':
- /workspace_root
- /workspace_root/lib
- /workspace_root/lib/.lib1.objs/byte
The problem is that the debug information is missing information about which package contains the library. When building a module that is part of a package that will be potentially installed, the mapping should include the package name, and also be as if the library location was at the root of the package. So the BUILD_PATH_PREFIX_MAP in this case should be:
BUILD_PATH_PREFIX_MAP="/workspace_root/mypackage=$cwd/lib"
Reproduction
I will open a PR soon, but I think the above describes the issue adequately. Also, I plan to work on a fix for this Dune problem, and am also working on a Dune enhancement to start up ocamldebug with a BUILD_PATH_PREFIX_MAP to maps from /workspace_root to the actual source locations.
Specifications
- Version of
dune: 3.7.0 - Version of
ocaml: 5.0.0 - Operating system: Ubuntu 22.04
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the example from dune-project and lib/dune with dune install --prefix _opamroot, then inspect the debug directories recorded in lib1.cma and the BUILD_PATH_PREFIX_MAP behavior. Compare the current paths with the expected /workspace_root/mypackage/lib1 mapping; done means installed package and library locations resolve consistently for the debugger.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ocaml
- Domain
- build-system, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100