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:

1 Like

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,


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 !!!

Hi, I know its been a while since last message. Were you ever able to setup debugger from CLION itself. I am able to debug using lldb using banach-space instruction (Thank you ) but cant use CLION to debug from I am trying to create out of tree pass.
Here is how I run it from lldb:
lldb – /opt -load-pass-plugin=/cmake-build-debug/ -passes=MyPass test.ll
once lldb is running I set the break point and run the code as shown by banach-space in previous post. It would be really nice to just use CLION to dubug on Ubuntu here . Thank you