Cling: Possibility debug cling scripts using Visual studio

I have compiled clang & cling with few bugfixes using Visual studio 2017, and tried that basic printf Hello world works on cling.

However - next step what I wanted to make is to be able to debug c++ scripts on Visual studio.

Question 1: How to pass arguments to clang from cling command line, I have tried to use

D:\deleteme\cling\build\RelWithDebInfo\bin>cling -cc1 /LDd test.cpp

error: unknown argument: ‘-cc1’

Question 2: Generally C++ compiled as a code is being compiled as static library, and I doubt that you can attach to it with

Visual studio - we need probably .dll + .pdb to be loaded dynamically (shared object / dynamic library).

And this leads to Question 3: Can .pdb’s be produced by clang ?

.pdb as file format probably exists in Visual studio, but I’m not sure if clang is capable of producing Visual studio compatible .pdb file format. I saw some options to switch to CL.exe (Visual studio compiler), I guess it could be one alternative as well.

Question 1: there’s no magic “passing args t clang”; cling needs to know what argument that is, because things work differently for cling and clang - e.g. because cling is using llvm’s JIT while clang is not.

I don’t know the answer to your questions 2 and 3 - these are really questions for llvm’s (Orc)JIT. Maybe you could ask at the llvm mailing list? The question is whether MSVC has an interface for JITed code, to tell the debugger about these new symbols. This was added to gdb (and AFAIK re-used by lldb) - but I don’t know about MSVC.

Said that - I never got around to enabling the debugger interface for cling either, not even for gdb :frowning. A contribution here would be super welcome!

Cheers, Axel.

I guess there could be plenty of different ways to attach to debugger - debugger itself could attach to c++ script on fly - but that would require some interoperability between script host and debugger. I would propose to start from something that should work already - c++ code is compiled to .dll + .pdb, and .dll gets executed. Is it possible with current cling, which options I can use to compile to dll ?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.