-
Notifications
You must be signed in to change notification settings - Fork 19
Debugging automated test run failures
Sometimes you need to debug clang failures that only occur during automated test runs or when running a script. The failure may not be reproducible from the command line. For example, this failure only occurred when the compiler ran under the lit testing harness. There was a subtle dependency on an environment variable and lit was removing the environment variable.
On Windows, typically you would attach a debugger to a program that has crashed or use __debug_break()
to ring the doorbell for the debugger (the OS will report that the program has failed and ask if you want to attach a debugger). These techniques do not work for clang because clang catches all uncaught exceptions and shuts the process down gracefully. This is the right thing for normal users of the compiler, but can interfere with debugging internal compiler errors, especially ones that are hard to reproduce.
On Windows, to allow these techniques to work, you need to turn off the signal handler that catches all uncaught exceptions. Go to the first line of main()
in clang\tools\driver\driver.cpp
and comment it out:
// llvm::sys::PrintStackTraceOnErrorSignal(argv_[0]);