[LLVMdev] Question about program debugging after code duplication

Yun Zhang yunzhang at princeton.edu
Wed Nov 18 08:52:13 PST 2009


Hi,

I am not sure where I should submit the question to. But I think it is llvm related.

I ran into a problem when debugging my code. Here is the problem: 
my optimization (a pass in LLVM) takes bitcode file as input, duplicate part of the original code, put the duplicated code in a separate function, then run both of them. I took the steps:
1. use llvm-gcc to compile .c files to bitcode files .bc, using -g flag
2. use opt from llvm to duplicate part of the code
3. use llc, compile the output of opt to assembly file .s
4. use llvm-gcc to link and generate the final binary, using -g flag

When I tried to debug the generated binary using gdb, the debug information it contains is not sufficient enough to pinpoint where the problem is, so I switched to clang. I replaced all uses of llvm-gcc to clang. Then The final step aborts because clang finds several identical labels in the program. I examined the .s file, there is no identical labels in assembly(output of step 3). The duplicated labels, which caused errors, are like ".Ldebug_frame_endl" etc, inserted by clang. I suspect that it is because the original code was annotated with debug information, and after the code was duplicated, debug information is copied over as well, at the final step, the same label is generated for both. Is that right?

My *question* is: if that is a correct speculation, how do I solve this problem? Should I 
(and, can I) access and modify the debug information at the second step 
(opt of llvm)?  

I tried to use llvm-gcc for Step 1, and clang for Step 4. I am able to debug this way, but only at assembly level (.s files), which is not as convenient as debugging at bitcode level.


Thank you very much for any suggestion.

Thanks,
Yun




More information about the llvm-dev mailing list