Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not debug with dynamic linking #16

Closed
huangered opened this issue Jul 1, 2016 · 26 comments
Closed

Can not debug with dynamic linking #16

huangered opened this issue Jul 1, 2016 · 26 comments
Labels
Milestone

Comments

@huangered
Copy link

when i start to debug, it print the error, can you help?

Fatal error: cannot load shared library dllbin_prot_stubs
Reason: dlopen(dllbin_prot_stubs.so, 138): image not found

my environment is macos10.11.5

@hackwaly
Copy link
Owner

hackwaly commented Jul 3, 2016

I'm not an OCaml expert. Did you config your opam correctly? I guess bin_prot package is missed in your env. Try opam install bin_prot.

@huangered
Copy link
Author

thanks for you reply, find some clues ocaml/opam#47 close thie ticket

@qdwang
Copy link

qdwang commented Aug 25, 2016

same problem here, @huangered how did you fix this?

@huangered
Copy link
Author

huangered commented Aug 25, 2016

@qdwang not fix yet, but i plan to remove vscode-beta version and install new to have a try.
do you also use osx?

@qdwang
Copy link

qdwang commented Aug 25, 2016

@huangered neither Ubuntu and OSX can work the debug function and I'm using the vscode stable version.

@hackwaly bin_prot has been installed, and ocamldebug works well in terminal. I think may be that vscode debug env cannot access the env variable CAML_LD_LIBRARY_PATH.

@hackwaly hackwaly reopened this Aug 25, 2016
@hackwaly
Copy link
Owner

@qdwang Did you check that if simple helloworld program works (like the gif in README does)?

@qdwang
Copy link

qdwang commented Aug 25, 2016

@hackwaly not working. still the same error msg.

@hackwaly
Copy link
Owner

Can you try to use ocamldebug manually debug the bytecode?

ocamlc -g main.ml
ocamldebug a.out
goto 0
run

@qdwang
Copy link

qdwang commented Aug 25, 2016

@hackwaly Like what I said before, ocamldebug works just fine.

@hackwaly
Copy link
Owner

hackwaly commented Aug 25, 2016

Well, I have no idea now.

I think may be that vscode debug env cannot access the env variable CAML_LD_LIBRARY_PATH.

I think you are right. But why I didn't encounter. I'm also macOS, and Ubuntu doesn't have separated env issues like macOS.

I suspect you didn't config opam correctly. Could you check that env variables in result of opam config env are in your env?

@qdwang
Copy link

qdwang commented Aug 25, 2016

Since the cmd eval opam config env`` lies in ~/.profile and `~/.bashrc`, there is no doubt `ocamldebug` works in terminal.

But I don't know how to check if vscode uses a different shell or it just won't use the .profile and .bashrc config.

@hackwaly
Copy link
Owner

No, it use nodejs child_process.spawn to run ocamldebug. You can do a simple test to check if a process spawned by child_process.spawn can find the CAML_LD_LIBRARY_PATH variable.

@hackwaly
Copy link
Owner

hackwaly commented Aug 25, 2016

(* env.ml *)
print_endline (Sys.getenv "CAML_LD_LIBRARY_PATH")
// test.js
var cp = require('child_process');
var p = cp.spawn('./env');
p.stdout.pipe(process.stdout);
node test.js

@qdwang
Copy link

qdwang commented Aug 25, 2016

I've tried spawn the ocamldebug in node.js file, and it works(under my terminal).
So the problem may be the vscode, because I didn't run vscode from my terminal?
I don't know if this will cause the problem.

@hackwaly
Copy link
Owner

hackwaly commented Aug 25, 2016

You can open devtools (command "Developer: Toggle Developer Tools") of vscode to check the process.env. CAML_LD_LIBRARY_PATH variable.

@qdwang
Copy link

qdwang commented Aug 29, 2016

process.env.CAML_LD_LIBRARY_PATH
"/home/qdwang/.opam/4.03.0/lib/stublibs"

This seems totally right... That's weird...

@hackwaly
Copy link
Owner

So the root problem is not CAML_LD_LIBRARY_PATH. Maybe you can debug vscode-ocaml extension to find some clues.

See how to debug: #5 (comment)

@qdwang
Copy link

qdwang commented Aug 29, 2016

I've cloned code, how can I build the ts file to js file?

@hackwaly
Copy link
Owner

npm install then press F5

@qdwang
Copy link

qdwang commented Aug 29, 2016

Why can not I use console.log to print in Debug Console?

@hackwaly
Copy link
Owner

You don't need console.log, just write the expression you like to display. Or use the watch window.
https://code.visualstudio.com/docs/extensions/debugging-extensions

@qdwang
Copy link

qdwang commented Aug 29, 2016

I've figured out that debugging with the output file of ocamlc -g main.ml works.

But not corebuild -tag debug main.byte which uses ocamlbuild and ocamlfind.

The corebuild output file can be debugged by ocamldebug in terminal.

@hackwaly
Copy link
Owner

I use ocamlbuild without this issue. ocamlbuild -use-ocamlfind main.d.byte

@qdwang
Copy link

qdwang commented Aug 29, 2016

corebuild is just like this

#!/bin/sh

ocamlbuild \
    -use-ocamlfind \
    -pkg core \
    -tag "ppx(ppx-jane -as-ppx)" \
    -tag thread \
    -tag debug \
    -tag bin_annot \
    -tag short_paths \
    -cflags "-w A-4-33-40-41-42-43-34-44" \
    -cflags -strict-sequence \
    $@

you can test with it and then fix the issue...

@hackwaly
Copy link
Owner

This should be fixed in new version just published.

@qdwang
Copy link

qdwang commented Aug 29, 2016

Thanks~ It's fixed.

@hackwaly hackwaly added this to the 0.5.x milestone Aug 29, 2016
@hackwaly hackwaly added the bug label Aug 29, 2016
@hackwaly hackwaly changed the title can not debug Can not debug with dynamic linking Aug 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants