debugging clang driver backtrace

Hello cfe-dev!

I am taking a stab at clang bug id 14085.

I put the offending source in tmp.cc and started off with “gdb clang++” and then “(gdb) run tmp.cc”. This produces an “UNREACHABLE executed at …” with a really helpful backtrace.

When I break at main() and step through the driver code, a posix_spawn() is eventually executed, and I am not sure how to step through that. So, I figured it may be better to debug clang with the extensive command line arguments that are generated (this is dumped into a .sh file and recommended you attach it when submitting bug report).

So I “gdb clang” and “(gdb) run -cc1 -triple x86_64-unknown-linux-gnu … tons of options … tmp.cc” and break at cc1_main(). When I continue, it hits the same “UNREACHABLE executed at …”, but the backtrace is not printed.

Can someone explain why this is? Is the backtrace dumped somewhere that the driver pid can read and that is why I see it in the first debugging scenario?

Any other recommendations for someone getting started with debugging clang? Or, how to debug through the posix_spawn() in the driver?

Thanks!
Brian

Running gdb on the "clang -cc1" command is probably the easiest. You
can use gdb's "bt" to print a stack trace once you get to the assert.