[LLVMdev] LexicalScope Debug Info - Line Number

Devang Patel dpatel at apple.com
Wed Jul 27 09:55:52 PDT 2011


On Jul 26, 2011, at 7:58 PM, ankur deshwal wrote:

> Hi,
> I need to find out the line no info for each lexical block in the code
> being compiled with llc. The docs mention metadata format for debug
> info for lexical block is
> !3 = metadata !{
>  i32,                                  ;; Tag = 11 + LLVMDebugVersion
> (DW_TAG_lexical_block)
>  metadata,                         ;; Reference to context descriptor
>  i32,                                  ;; Line number
>  i32                                   ;; Column number
> }
> So the line no. info is present as its 3rd member. I am trying to
> extract this line number either directly from the corresponding
> DbgScope variable passed as argument to
> constructScopeDIE function. OR from the ScopeDIE variable (DIE* type)
> after it is populated with the debug info in DIE format.

Metadata is used to encode lexical block at LLVM IR level. However, DbgScope is internal to DwarfWriter (which is part of code generator)  and it is lowered from metadata. DbgScope does not need line number information, it is focused on identify set of instructions for a lexical block.

> Please help me with the functions which I can use to extract this information.

At what point in compilation you want to extract line number information ? And what is the intended use ?

More information about the llvm-dev mailing list