Stack trace - clang


I am new to LLVM and am trying to modify clang for some work. I tried to insert an instruction: prefetchnta $100 at the beginning of a function. I encountered a problem when I tried to debug it with gdb. There was an assertion failure and printed some information without stack trace. The process has been finished when it printed the information. I tried to set a breakpoint at the operator[] with:
break llvm::SmallVectorTemplateCommon<llvm::MCOperand>::operator[](unsigned int)
  The program did not stop there either. Here is what it printed. The question is: how can I print the stack trace when there is an assertion failure. Thanks tons.

clang: /export/home/zbin/llvm/llvm/include/llvm/ADT/SmallVector.h:163: const T& llvm::SmallVectorTemplateCommon<T>::operator[](unsigned int) const [with T = llvm::MCOperand]: Assertion `begin() + idx < end()' failed.
0 clang 0x094b90d8
Stack dump:
0. Program arguments: /export/home/zbin/llvm/llvm/Release+Asserts/bin/clang -cc1 -triple i386-pc-linux-gnu -S -disable-free -main-file-name helloworld.c -mrelocation-model static -mdisable-fp-elim -mconstructor-aliases -target-cpu pentium4 -resource-dir /export/home/zbin/llvm/llvm/Release+Asserts/lib/clang/2.8 -ferror-limit 19 -fmessage-length 95 -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/cc-x4r76v.s -x c helloworld.c
1. <eof> parser at end of file
2. Code generation
3. Running pass 'X86 AT&T-Style Assembly Printer' on function '@main'
clang: error: clang frontend command failed due to signal 6 (use -v to see invocation)

clang is built with gmake ENABLE_OPTIMIZED=1 .
Also I tried with the debug version of clang. It did not work either. I am really stumped on this bug. Thank you very much.


Hi Bin,

It sounds like you are running gdb on the driver (which spawns off the
actual compilation step). Try running Clang with '-###', and run gdb
using the first command line it prints out.

Also, please send Clang questions to

- Daniel