banach-space / llvm-tutor

A collection of out-of-tree LLVM passes for teaching and learning
MIT License
2.96k stars 393 forks source link

Please add more detail about how to use gdb to debug pass #29

Open wuxiaoqiang12 opened 3 years ago

wuxiaoqiang12 commented 3 years ago

I follow your guide about how to debug using gdb on ubuntu. But my gdb cannot see the source file. I using following command:

clang -emit-llvm -S -O1 input_for_mba.c -o input_for_mba.ll
gdb --args opt -S -load-pass-plugin ../build/lib/libMBAAdd.so -passes=mba-add input_for_mba.ll
b ../lib/MBAAdd.cpp:MBAAdd::run

gdb said: No source file named ../lib/MBAAdd.cpp.

(gdb) info source No current source file.

Please help me. thanks a lot

banach-space commented 3 years ago

Hi @wuxiaoqiang12 , thank for creating this issue!

The instructions in REDME.md recommend this:

b MBAAdd.cpp:MBAAdd::run

Any particular reason to use this instead:

b ../lib/MBAAdd.cpp:MBAAdd::run

? Also, there is no MBAAdd.cpp in the lib sub directory. That's why gdb is failing.

science-enthusiast commented 1 year ago

It helps to type y (i.e., yes) as the answer to "Make breakpoint pending on future shared library load? (y or [n])" that follows "No source file named ...".