3

I have setup a debugger with my Clang & LLVM projects. I want to make sure that it is working. So I want to put a breakpoint at a place where it will surely hit when I execute below command :

clang -S -emit-llvm foo.c

Please help me with the entrypoint function for these projects.

Thanks in advance.

Darshan Bhat
  • 245
  • 1
  • 11
  • 2
    https://github.com/llvm/llvm-project/blob/893ac53afc1ae3d433fee2835a1c5db00369d0c4/clang/tools/driver/driver.cpp#L351 – harry Sep 01 '21 at 09:35
  • 1
    Thanks harry, this exactly what I was looking for :) – Darshan Bhat Sep 01 '21 at 16:29
  • 1
    If you are trying to debug clang using a debugger, keep in mind that clang will fork child processes to handle each source file provided in command line arguments, so the main process may 'skip' main parsing part from debugger's view. – Qiu Chaofan Sep 02 '21 at 16:23

1 Answers1

3

Your debugging problems are probably arising from the fact that clang is only a driver, which prepares elaborate command line and invoke the actual compiler.

When debugging Clang, I use the following trick:

  • First append -v to your command line to see actual commands the driver running.
  • Use this output to start the debugging session.
arrowd
  • 33,231
  • 8
  • 79
  • 110