How to debug Clang code

Hi,
I am a student and new to Clang. I want to know the development tools that you use.
what I exactly wanted to know is, how do you debug the code.

I am trying to debug Clang using Eclipse. I have put a break point in clang/lib/lex/preprocessor.cpp at the preprocessor’s constructor.

  1. I have set a “test.c” file as an argument in the debug configurations.
  2. Went to Run-> Debug As-> Local C/C++ Application.
  3. It asked “Choose local application to debug”. I chose “clang” and clicked OK.
  4. It started building the code. build completed.
  5. Stopped at main() in the debug window. (No source available for main())
  6. After some step overs, it says “terminated: gdb Debugger (Exited. Exit code=255)”

I am not taken to the clang code (preprocessor code). can someone please tell me how to debug the clang code.? I want to see the code flow in clang. and how clang is constructing the AST.

Best Regards,Srikanth Vaindam

Make sure your argument is "-cc1 test.c" as that will invoke the
frontend, without it clang acts as a compiler driver and invokes
another instance of clang.

That, and make sure you are using a debug build of clang (with debug symbols).

If you want to now what the -cc1 command line should be, you can launch clang with the -### argument, It will print the corresponding -cc1 invocation and exit.