hackwaly / ocamlearlybird

OCaml debug adapter
MIT License
208 stars 23 forks source link

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

Closed Mng12345 closed 6 months ago

Mng12345 commented 6 months ago

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: (*****************************
hackwaly commented 6 months ago

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

Mng12345 commented 6 months ago

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.

hackwaly commented 6 months ago

You could set source_dirs in launch.json to specify additional search dirs. See https://github.com/hackwaly/ocamlearlybird/blob/63f0a3fbc2fc0af388f984da1d447eefa708c39b/src/adapter/debug_protocol_ex.ml#L46

Sadly, looks like it hasn't implemented.

Mng12345 commented 6 months ago

Yes, this still not fix my problem.

Mng12345 commented 6 months ago

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 DuneexeCli, did this changes will break the module resolving? I am not very familar with ocamlearlybird code. image

hackwaly commented 6 months ago

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.

Mng12345 commented 6 months ago

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
hackwaly commented 6 months ago

It seems your (map_workspace_root false) not takes effect.

Mng12345 commented 6 months ago

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