I want to modify debug information of an llvm instruction so that the modified debug info is subsequently passed to executable binary. So if I use "addr2line" utility on the binary, it will return my modified debug information.
I've tried to change by using the following code snippet:
MDNode *N = Inst->getMetadata("dbg");
DebugLoc Loc = DebugLoc::get(newLine, newCol, N);
Inst->setDebugLoc(Loc);
I read the DebugLoc back by using
const DebugLoc D = Inst->getDebugLoc();
unsigned Line = D.getLine();
outs() << Line <<"\n";
But I can't set the debug info correctly. How can I change the debug info correctly through llvm pass?