Alexandru Ionut Diaconescu
2013-Feb-27 10:35 UTC
[LLVMdev] llvm get globals definition line number
Hello,
I followed the
http://stackoverflow.com/questions/13852180/how-to-get-variable-definition-line-number-etc-using-dbg-metadatain
order to get the line number definition for local variables (allocas),
which works fine. But I need the same for globals. So I tried to hack the
`findDbgGlobalDeclare()` method from
http://llvm.org/docs/doxygen/html/DbgInfoPrinter_8cpp_source.html#l00062 .
However, I have no `llvm.dbg.gv` in my bytecode, so there is no dbg info to
extract. I compile my target code using `clang++ -O0 -g -emit-llvm Test.cpp
-c -o Test.bc` . Some samples from my bytecode:
@r = global i32 3, align 4
%4 = load i32* @r, align 4, !dbg !942
...
%a = alloca i32, align 4
%1 = load i32* %a, align 4, !dbg !939
Thank you !
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20130227/e38ee8c9/attachment.html>
Alexandru Ionut Diaconescu
2013-Feb-27 10:53 UTC
[LLVMdev] llvm get globals definition line number
However, I do have:
!924 = metadata !{i32 786484, i32 0, null, metadata !"r", metadata
!"r", metadata !"", metadata !841, i32 19, metadata !56, i32
0, i32 1, i32*
@r} ; [ DW_TAG_variable ] [r] [line 19] [def]
with on which `!0` is indirectly dependent and there is `!llvm.dbg.cu !{!0}` .
On Wed, Feb 27, 2013 at 11:35 AM, Alexandru Ionut Diaconescu <
alexandruionutdiaconescu at gmail.com> wrote:
> Hello,
>
> I followed the
>
http://stackoverflow.com/questions/13852180/how-to-get-variable-definition-line-number-etc-using-dbg-metadatain
order to get the line number definition for local variables (allocas),
> which works fine. But I need the same for globals. So I tried to hack the
> `findDbgGlobalDeclare()` method from
> http://llvm.org/docs/doxygen/html/DbgInfoPrinter_8cpp_source.html#l00062.
However, I have no `llvm.dbg.gv` in my bytecode, so there is no dbg info
> to extract. I compile my target code using `clang++ -O0 -g -emit-llvm
> Test.cpp -c -o Test.bc` . Some samples from my bytecode:
>
> @r = global i32 3, align 4
> %4 = load i32* @r, align 4, !dbg !942
> ...
> %a = alloca i32, align 4
> %1 = load i32* %a, align 4, !dbg !939
>
> Thank you !
--
Best regards,
Alexandru Ionut Diaconescu
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20130227/e9be5724/attachment.html>
On Wed, Feb 27, 2013 at 2:53 AM, Alexandru Ionut Diaconescu <alexandruionutdiaconescu at gmail.com> wrote:> However, I do have: > > !924 = metadata !{i32 786484, i32 0, null, metadata !"r", metadata !"r", > metadata !"", metadata !841, i32 19, metadata !56, i32 0, i32 1, i32* @r} ; > [ DW_TAG_variable ] [r] [line 19] [def] > > with on which `!0` is indirectly dependent and there is `!llvm.dbg.cu > !{!0}` .Right, the modern debug info metadata format stores the list of globals in the last (optional) field of the compile_unit description http://llvm.org/docs/SourceLevelDebugging.html#compile-unit-descriptors> > > > On Wed, Feb 27, 2013 at 11:35 AM, Alexandru Ionut Diaconescu > <alexandruionutdiaconescu at gmail.com> wrote: >> >> Hello, >> >> I followed the >> http://stackoverflow.com/questions/13852180/how-to-get-variable-definition-line-number-etc-using-dbg-metadata >> in order to get the line number definition for local variables (allocas), >> which works fine. But I need the same for globals. So I tried to hack the >> `findDbgGlobalDeclare()` method from >> http://llvm.org/docs/doxygen/html/DbgInfoPrinter_8cpp_source.html#l00062 . >> However, I have no `llvm.dbg.gv` in my bytecode, so there is no dbg info to >> extract. I compile my target code using `clang++ -O0 -g -emit-llvm Test.cpp >> -c -o Test.bc` . Some samples from my bytecode: >> >> @r = global i32 3, align 4 >> %4 = load i32* @r, align 4, !dbg !942 >> ... >> %a = alloca i32, align 4 >> %1 = load i32* %a, align 4, !dbg !939 >> >> Thank you ! > > > > > -- > Best regards, > Alexandru Ionut Diaconescu > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >