Skip to content

Debugging Backend Crashes with bugpoint

Jeff Bush edited this page Apr 2, 2017 · 2 revisions

If the compiler crashes with a debug build, it will print something like the following at the end of the trace:

********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-5.0: note: diagnostic msg: /var/folders/z8/b6sltzt52zz9qgncb8g7vych0000gn/T/meteor-contest-noverilator-b6cb02.c
clang-5.0: note: diagnostic msg: /var/folders/z8/b6sltzt52zz9qgncb8g7vych0000gn/T/meteor-contest-noverilator-b6cb02.sh
clang-5.0: note: diagnostic msg: Crash backtrace is located in
clang-5.0: note: diagnostic msg: /Users/jeffbush/Library/Logs/DiagnosticReports/clang-5.0_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang-5.0: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
clang-5.0: note: diagnostic msg: 

********************

We want to use the pre-processed source file for debugging, this is "/var/folders/z8/b6sltzt52zz9qgncb8g7vych0000gn/T/meteor-contest-noverilator-b6cb02.c" from above.

Generate intermediate code:

clang -S -emit-llvm -o fail.ll -O3 /var/folders/z8/b6sltzt52zz9qgncb8g7vych0000gn/T/meteor-contest-noverilator-b6cb02.c

Run bugpoint to reduce the failure to a minimal test case (-llc-safe avoids trying to execute the program on the host as a native executable)

bugpoint -llc-safe fail.ll

This will create a file: bugpoint-reduced-simplified.bc. Convert to a readable text file bugpoint-reduced-simplified.ll:

llvm-dis bugpoint-reduced-simplified.bc 

To see debugging output:

llc -debug bugpoint-reduced-simplified.ll