Change llvm IR debugging information

I want to change the debug information of the llvm instruction so that the changed debug information is subsequently passed to the binary executable. So if I use the "addr2line" utility in binary format, it will return my modified debugging information.

I tried to change using the following code snippet:

MDNode *N = Inst->getMetadata("dbg"); DebugLoc Loc = DebugLoc::get(newLine, newCol, N); Inst->setDebugLoc(Loc); 

I read DebugLoc using

 const DebugLoc D = Inst->getDebugLoc(); unsigned Line = D.getLine(); outs() << Line <<"\n"; 

But I can not set debug info correctly. How to change debug info correctly through llvm pass?

+6
source share

Source: https://habr.com/ru/post/987145/


All Articles