hackwaly / ocamlearlybird

OCaml debug adapter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Modules in byte code executable file build by dune are not found when adding fragment in Controller.root function.

Mng12345 opened this issue · comments

commented

I have noticed that we can not set breakpoints in vscode for dune build bc executable file, and i build a custom earlybird with printting some logs in the console, the logs show that some modules are not found when adding fragment.
image
Below are some parts of the console log.

resolve module source for: Printast is not found.
resolve module source for: Dune__exe__CompletionFrontEnd is not found.
resolve module source for: Parse is not found.
resolve module source for: Res_driver is not found.
resolve module source for: Res_driver_ml_parser is not found.
resolve module source for: Res_ast_debugger is not found.
resolve module: 
source path: /home/ming/.opam/4.14.0/lib/ocaml/camlinternalFormat.ml
content: (*****************************

resolve module source for: Dune__exe__Files is not found.
resolve module source for: Reanalyze__DeadModules is not found.
resolve module source for: Dune__exe__ProcessCmt is not found.
resolve module source for: Ext_pervasives is not found.
resolve module source for: Dune__exe__ResolvePath is not found.
resolve module source for: Res_outcome_printer is not found.
resolve module: 
source path: /home/ming/.opam/4.14.0/lib/ocaml/list.ml
content: (*****************************

resolve module source for: Unix is not found.
resolve module source for: Asttypes is not found.
resolve module: 
source path: /home/ming/.opam/4.14.0/lib/ocaml/camlinternalAtomic.ml
content: (*****************************

resolve module source for: Res_printer is not found.
resolve module source for: Dune__exe__SignatureHelp is not found.
resolve module: 
source path: /home/ming/.opam/4.14.0/lib/ocaml/marshal.ml
content: (*****************************
commented

Have you noticed https://github.com/hackwaly/ocamlearlybird?tab=readme-ov-file#breakpoints-not-hit-with-lang-dune-30-and-above

Thanks for the reply, i have already changed my dune version to 3.7 and set (map_workspace_root false), the breakpoints are still unrerified.

You could set source_dirs in launch.json to specify additional search dirs. See

source_dirs : string list; [@default []]

Sadly, looks like it hasn't implemented.

commented

Yes, this still not fix my problem.

commented

And i noticed that the module name has been changed in the debuginfo of bc executable file. Eg, the source file is Cli.ml, but it changed to Dune__exe__Cli, did this changes will break the module resolving? I am not very familar with ocamlearlybird code.
image

I think it won't. You can log the search_dirs and dig into search_dirs to see what's inside. Maybe this will give us some clues.

commented

I logged the search dirs, the log shows it searches in path /workspace_root, i don't know what the path /workspace_root mean, it does not existed in my wsl2 ubuntu system.

search dir: /workspace_root/vendor/ext
search dir: /workspace_root/vendor/ext/.ext.objs/byte
search dir: /workspace_root/vendor/json
search dir: /workspace_root/vendor/json/.jsonlib.objs/byte
search dir: /workspace_root/vendor/ml
search dir: /workspace_root/vendor/ml/.ml.objs/byte
search dir: /workspace_root/vendor/res_syntax
search dir: /workspace_root/vendor/res_syntax/.syntax.objs/byte
module: Std_exit file: /home/ming/.opam/4.14.0/lib/ocaml
module: Std_exit file: /home/ming/.opam/4.14.0/.opam-switch/build/ocaml-base-compiler.4.14.0/stdlib
module: Dune__exe__Cli file: /workspace_root
module: Dune__exe__Cli file: /workspace_root/src
module: Dune__exe__Cli file: /workspace_root/src/.Cli.eobjs/byte
module: Dune__exe__Commands file: /workspace_root
module: Dune__exe__Commands file: /workspace_root/src
module: Dune__exe__Commands file: /workspace_root/src/.Cli.eobjs/byte
module: Dune__exe__SignatureHelp file: /workspace_root
module: Dune__exe__SignatureHelp file: /workspace_root/src
module: Dune__exe__SignatureHelp file: /workspace_root/src/.Cli.eobjs/byte
module: Dune__exe__SemanticTokens file: /workspace_root
module: Dune__exe__SemanticTokens file: /workspace_root/src
module: Dune__exe__SemanticTokens file: /workspace_root/src/.Cli.eobjs/byte
module: Dune__exe__Hover file: /workspace_root
module: Dune__exe__Hover file: /workspace_root/src
module: Dune__exe__Hover file: /workspace_root/src/.Cli.eobjs/byte
module: Dune__exe__Markdown file: /workspace_root
module: Dune__exe__Markdown file: /workspace_root/src
module: Dune__exe__Markdown file: /workspace_root/src/.Cli.eobjs/byte
module: Dune__exe__Hint file: /workspace_root
module: Dune__exe__Hint file: /workspace_root/src
module: Dune__exe__Hint file: /workspace_root/src/.Cli.eobjs/byte
module: Dune__exe__DumpAst file: /workspace_root
module: Dune__exe__DumpAst file: /workspace_root/src
module: Dune__exe__DumpAst file: /workspace_root/src/.Cli.eobjs/byte
module: Dune__exe__DocumentSymbol file: /workspace_root
module: Dune__exe__DocumentSymbol file: /workspace_root/src
module: Dune__exe__DocumentSymbol file: /workspace_root/src/.Cli.eobjs/byte
module: Dune__exe__Diagnostics file: /workspace_root
module: Dune__exe__Diagnostics file: /workspace_root/src
module: Dune__exe__Diagnostics file: /workspace_root/src/.Cli.eobjs/byte
module: Dune__exe__DceCommand file: /workspace_root
module: Dune__exe__DceCommand file: /workspace_root/src

It seems your (map_workspace_root false) not takes effect.

commented

Ohh! sorry, it's my fault, i forgot to change map_workspace_root true to false!! It works now, thank you!
image