Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are the debug symbols lost in the LLVM compile/link process?

Tags:

debugging

llvm

I wrote an LLVM transformation that basically replaces mallocs by kind of guarded mallocs and some other stuff.

I'm using clang (or llvm-gcc) for compiling a c file to get a bitcode file (using the -emit-llvm option) which contains debug information. These also contain method names, line numbers and so on.

Afterwards I'm using opt to instrument this bitcode file. The result is an instrumented bitcode file, still containing all relevant debug infos.

In a third and last step, since we need some runtime libs, we link the bitcode against some other bitcode files using llvm-gcc to get a final binary.

This binary I cannot debug since it doesn't contain any debug information although all linked bitcode files did contain them. The only thing gdb can tell me is in which function we are but no line numbers and so on...

I would be grateful for any hints.

like image 851
Kevin Streit Avatar asked Feb 28 '10 16:02

Kevin Streit


1 Answers

As I understood you are running optimizations (opt tool optimizes the code and debug information also). So may be the missing part which you want to see when debugging is a result of optimized debug information ?

P.S. I would add this in the comment, but unfortunately I don't have 50 reputations which are needed to add a comment.

like image 133
Arsen Avatar answered Nov 11 '22 14:11

Arsen