Riyad Parvez
2015-May-13 02:59 UTC
[LLVMdev] Modifying debug information through llvm pass
Hi All,
I want to change 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?
Thanks
Riyad
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20150512/b5fd2783/attachment.html>
Adrian Prantl
2015-May-15 21:21 UTC
[LLVMdev] Modifying debug information through llvm pass
> On May 12, 2015, at 7:59 PM, Riyad Parvez <riyad.parvez at uwaterloo.ca> wrote: > > Hi All, > > I want to change 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);Your use of N looks sketchy here. The third argument of DebugLoc::get() is supposed to be the scope of the location, so you probably want Inst->getDebugLoc().getScope() there? -- adrian> Inst->getDebugLoc(); > 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? > > Thanks > Riyad > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Riyad Parvez
2015-May-20 01:01 UTC
[LLVMdev] Modifying debug information through llvm pass
On 05/15/2015 05:21 PM, Adrian Prantl wrote:>> On May 12, 2015, at 7:59 PM, Riyad Parvez <riyad.parvez at uwaterloo.ca> wrote: >> >> Hi All, >> >> I want to change 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); > Your use of N looks sketchy here. The third argument of DebugLoc::get() is supposed to be the scope of the location, so you probably want > Inst->getDebugLoc().getScope() > there?Thanks for pointing that out. It worked. Thanks Riyad> -- adrian > >> Inst->getDebugLoc(); >> 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? >> >> Thanks >> Riyad >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev