[LLVMdev] Question about abstract subprograms in debug info

Manman Ren mren at apple.com
Fri Mar 8 17:49:00 PST 2013


I am working on an issue where a subprogram created here is having abstract_origin pointing to nowhere.
DIE *DwarfDebug::updateSubprogramScopeDIE(CompileUnit *SPCU,
                                          const MDNode *SPNode) {
  DIE *SPDie = SPCU->getDIE(SPNode);

  assert(SPDie && "Unable to find subprogram DIE!");
  DISubprogram SP(SPNode);

  // If we're updating an abstract DIE, then we will be adding the children and
  // object pointer later on. But what we don't want to do is process the
  // concrete DIE twice.
  if (DIE *AbsSPDIE = AbstractSPDies.lookup(SPNode)) {
    // Pick up abstract subprogram DIE.
    SPDie = new DIE(dwarf::DW_TAG_subprogram);
    SPCU->addDIEEntry(SPDie, dwarf::DW_AT_abstract_origin,
                      dwarf::DW_FORM_ref4, AbsSPDIE);

The compile unit DIE where AbsSPDIE belongs to is different from the compile unit DIE SPCU->getCUDie().
So it is not legal to use a FORM_ref4 here.

Why do we create these subprogram DIEs here? They are added to SPCU, but not inserted via insertDIE, so they are not in the MDNodeToDieMap of the CU.

Another question is how to fix this if we need to create these subprograms.
Should we use FORM_ref_addr here? FORM_ref_addr is not supported yet, I am wondering whether that will break any debugger.
Another fix seems to be copying the attributes of the origin instead of using abstract_origin.


More information about the llvm-dev mailing list