[LLVMdev] DW_TAG_lexical_block structure in debug information

Eli Bendersky eliben at gmail.com
Mon Mar 7 04:16:47 PST 2011


Hello,

The documentation for debug information
(http://llvm.org/docs/SourceLevelDebugging.html) says the structure of
block descriptors metadata is:

!3 = metadata !{
  i32,     ;; Tag = 11 + LLVMDebugVersion (DW_TAG_lexical_block)
  metadata,;; Reference to context descriptor
  i32,     ;; Line number
  i32      ;; Column number
}

However, looking at the generated metadata, there are 2 extra fields
not documented here. From the source code it appears to be a link to
the function holding the block, and a unique integer ID:

DILexicalBlock DIBuilder::createLexicalBlock(DIDescriptor Scope, DIFile File,
                                             unsigned Line, unsigned Col) {
  // Defeat MDNode uniqing for lexical blocks by using unique id.
  static unsigned int unique_id = 0;
  Value *Elts[] = {
    GetTagConstant(VMContext, dwarf::DW_TAG_lexical_block),
    Scope,
    ConstantInt::get(Type::getInt32Ty(VMContext), Line),
    ConstantInt::get(Type::getInt32Ty(VMContext), Col),
    File,
    ConstantInt::get(Type::getInt32Ty(VMContext), unique_id++)
  };
  return DILexicalBlock(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts)));
}

Is this an error in the documentation?

Thanks in advance,
Eli



More information about the llvm-dev mailing list