LLVM Discussion Forums

How to debug a pass on Linux IDE, like Clion

Sometimes, I feel wrting passes likes write web pages with javascript, you need to be familiar with the API. But I found it’s hard to remember all APIs of objects for a newbee. Is there any IDE support llvm pass debug on linux ? How you guys debug ? Please share with me, thks :stuck_out_tongue:

I use LLDB and CGDB and both work great. The actual steps will depend on whether you are debugging in-tree passes or out-of-tree passes. For out-of-tree passes I wrote quick guidelines here.

AFAIK, as long as you know how to build LLVM in your favourite IDE, you should be able to debug there are as well. In the past I used QT Creator and it worked really well. You can take a look at this blog - it demonstrates how to set-up Visual Studio for debugging out-of-tree passes.

Hope this helps,
Andrzej

Thank you, actually my out-of-tree pass framework is base on your work, and I use clion to generate pass successfully, but when I debug, the program won’t stop at the breakpoint …

There’s 2 things that you could try:

  • are you able to set a breakpoint using LLDB or GDB on the command line (personally I recommend CGDB instead of GDB)?
  • make sure that CLion uses either GDB or LLDB - if it works on the command line then it should also work in the IDE too.

Sadly I don’t have access to CLion to test this myself :frowning:

PS Don’t forget to build as DEBUG :wink:

You really know me !!! Since I just write a minimal cmake, I forgot to set BUILD_TYPE to debug ! Thank you !!!