-
Notifications
You must be signed in to change notification settings - Fork 470
Debug mapping is sometimes inconsistent with installed locations #7413
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