当前位置: 首页>>代码示例>>C++>>正文


C++ DIArray::getElement方法代码示例

本文整理汇总了C++中DIArray::getElement方法的典型用法代码示例。如果您正苦于以下问题:C++ DIArray::getElement方法的具体用法?C++ DIArray::getElement怎么用?C++ DIArray::getElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DIArray的用法示例。


在下文中一共展示了DIArray::getElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: processModule

/// processModule - Process entire module and collect debug info.
void DebugInfoFinder::processModule(const Module &M) {
  if (NamedMDNode *CU_Nodes = M.getNamedMetadata("llvm.dbg.cu")) {
    for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
      DICompileUnit CU(CU_Nodes->getOperand(i));
      addCompileUnit(CU);
      DIArray GVs = CU.getGlobalVariables();
      for (unsigned i = 0, e = GVs.getNumElements(); i != e; ++i) {
        DIGlobalVariable DIG(GVs.getElement(i));
        if (addGlobalVariable(DIG))
          processType(DIG.getType());
      }
      DIArray SPs = CU.getSubprograms();
      for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i)
        processSubprogram(DISubprogram(SPs.getElement(i)));
      DIArray EnumTypes = CU.getEnumTypes();
      for (unsigned i = 0, e = EnumTypes.getNumElements(); i != e; ++i)
        processType(DIType(EnumTypes.getElement(i)));
      DIArray RetainedTypes = CU.getRetainedTypes();
      for (unsigned i = 0, e = RetainedTypes.getNumElements(); i != e; ++i)
        processType(DIType(RetainedTypes.getElement(i)));
      // FIXME: We really shouldn't be bailing out after visiting just one CU
      return;
    }
  }
}
开发者ID:sethfowler,项目名称:llvm,代码行数:26,代码来源:DebugInfo.cpp

示例2: addMember

void DICompositeType::addMember(DIDescriptor D) {
  SmallVector<llvm::Value *, 16> M;
  DIArray OrigM = getTypeArray();
  unsigned Elements = OrigM.getNumElements();
  if (Elements == 1 && !OrigM.getElement(0))
    Elements = 0;
  M.reserve(Elements + 1);
  for (unsigned i = 0; i != Elements; ++i)
    M.push_back(OrigM.getElement(i));
  M.push_back(D);
  setTypeArray(DIArray(MDNode::get(DbgNode->getContext(), M)));
}
开发者ID:biometrics,项目名称:llvm,代码行数:12,代码来源:DebugInfo.cpp

示例3: constructArrayTypeDIE

/// constructArrayTypeDIE - Construct array type DIE from DICompositeType.
void CompileUnit::constructArrayTypeDIE(DIE &Buffer,
                                        DICompositeType *CTy) {
  Buffer.setTag(dwarf::DW_TAG_array_type);
  if (CTy->getTag() == dwarf::DW_TAG_vector_type)
    addUInt(&Buffer, dwarf::DW_AT_GNU_vector, dwarf::DW_FORM_flag, 1);

  // Emit derived type.
  addType(&Buffer, CTy->getTypeDerivedFrom());
  DIArray Elements = CTy->getTypeArray();

  // Get an anonymous type for index type.
  DIE *IdxTy = getIndexTyDie();
  if (!IdxTy) {
    // Construct an anonymous type for index type.
    IdxTy = new DIE(dwarf::DW_TAG_base_type);
    addUInt(IdxTy, dwarf::DW_AT_byte_size, 0, sizeof(int32_t));
    addUInt(IdxTy, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
            dwarf::DW_ATE_signed);
    addDie(IdxTy);
    setIndexTyDie(IdxTy);
  }

  // Add subranges to array type.
  for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
    DIDescriptor Element = Elements.getElement(i);
    if (Element.getTag() == dwarf::DW_TAG_subrange_type)
      constructSubrangeDIE(Buffer, DISubrange(Element), IdxTy);
  }
}
开发者ID:,项目名称:,代码行数:30,代码来源:

示例4: addType

void DebugDatabase::addType(MDNode *type) {
    DIType diType(type);

    string query;

    query = "INSERT INTO VariableType ";
    query +=
        "(designId, dw_tag, name, size, alignment, offset, derivedTypeId) ";
    query += "VALUES (" + std::to_string(designId);
    query += "," + std::to_string(diType.getTag());
    query += "," + addQuotesToStr(diType.getName().str());
    query += "," + std::to_string(diType.getSizeInBits());
    query += "," + std::to_string(diType.getAlignInBits());
    query += "," + std::to_string(diType.getOffsetInBits());

    if (diType.isBasicType()) {
        query += ",NULL";
    } else if (diType.isDerivedType()) {
        DIDerivedType typeDerived(type);
        MDNode *derivedMD = typeDerived.getTypeDerivedFrom().resolve(typeMap);
        if (derivedMD)
            query += "," + std::to_string(getTypeId(derivedMD));
        else
            query += ",NULL";
    } else {
        assert(false);
    }
    query += ");";

    runQuery(query);

    int typeId = mysql_insert_id(connection);
    typeToIds[&(*type)] = typeId;

    if (diType.isCompositeType()) {
        DICompositeType typeComposite(type);

        DIArray members = typeComposite.getTypeArray();
        for (unsigned int i = 0; i < members.getNumElements(); ++i) {
            DIDescriptor s = members.getElement(i);
            query = "INSERT INTO VariableTypeMember ";
            query +=
                "(ownerVariableTypeId, idx, variableTypeId, subrangeCount) ";
            query += "VALUES (" + std::to_string(typeId);
            query += "," + std::to_string(i);
            if (s.isSubrange()) {
                DISubrange subRange = (DISubrange)s;
                assert(subRange.getLo() == 0);
                query += ",NULL";
                query += "," + std::to_string(subRange.getCount());
            } else if (s.isType()) {
                MDNode *mdNode = &*s;
                query += "," + std::to_string(getTypeId(mdNode));
                query += ",NULL";
            }
            query += ");";
            runQuery(query);
        }
    }
}
开发者ID:eddiehung,项目名称:dox-legup,代码行数:60,代码来源:DebugDatabase.cpp

示例5: finalize

/// finalize - Construct any deferred debug info descriptors.
void DIBuilder::finalize() {
  DIArray Enums = getOrCreateArray(AllEnumTypes);
  DIType(TempEnumTypes).replaceAllUsesWith(Enums);

  DIArray RetainTypes = getOrCreateArray(AllRetainTypes);
  DIType(TempRetainTypes).replaceAllUsesWith(RetainTypes);

  DIArray SPs = getOrCreateArray(AllSubprograms);
  DIType(TempSubprograms).replaceAllUsesWith(SPs);
  for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i) {
    DISubprogram SP(SPs.getElement(i));
    SmallVector<Value *, 4> Variables;
    if (NamedMDNode *NMD = getFnSpecificMDNode(M, SP)) {
      for (unsigned ii = 0, ee = NMD->getNumOperands(); ii != ee; ++ii)
        Variables.push_back(NMD->getOperand(ii));
      NMD->eraseFromParent();
    }
    if (MDNode *Temp = SP.getVariablesNodes()) {
      DIArray AV = getOrCreateArray(Variables);
      DIType(Temp).replaceAllUsesWith(AV);
    }
  }

  DIArray GVs = getOrCreateArray(AllGVs);
  DIType(TempGVs).replaceAllUsesWith(GVs);
}
开发者ID:ebraheemk,项目名称:llvm-picoblaze,代码行数:27,代码来源:DIBuilder.cpp

示例6: CreateChildren

void DIEItem::CreateChildren(wxTreeCtrl *tree, const wxTreeItemId& id) {
  DIDescriptor diDesc(node_);
  if (diDesc.isCompileUnit()) {
    CreateCompileUnitChildren(tree, id);
  } else if (diDesc.isSubprogram()) {
    CreateSubprogramChildren(tree, id);
  } else if (diDesc.isGlobalVariable()) {
    DIGlobalVariable diVar(node_);
    CreateChild(tree, id, new DIEItem(module_, diVar.getType()));
  } else if (diDesc.isCompositeType()) {
    DICompositeType diCompType(node_);
    DIArray typeArray = diCompType.getTypeArray();
    unsigned ct = typeArray.getNumElements();
    for (unsigned i = 0; i < ct; ++i) {
      CreateChild(tree, id, new DIEItem(module_, typeArray.getElement(i)));
    }
  } else if (diDesc.isDerivedType()) {
    DIDerivedType diDerivedType(node_);
    CreateChild(tree, id,
        new DIEItem(module_, diDerivedType.getTypeDerivedFrom()));
  } else if (diDesc.isVariable()) {
    DIVariable diVar(node_);
    CreateChild(tree, id, new DIEItem(module_, diVar.getType()));
  }
}
开发者ID:lht,项目名称:llbrowse,代码行数:25,代码来源:TreeView.cpp

示例7: processType

void DebugInfoFinder::processType(DIType DT) {
  if (!addType(DT))
    return;
  processScope(DT.getContext().resolve(TypeIdentifierMap));
  if (DT.isCompositeType()) {
    DICompositeType DCT(DT);
    processType(DCT.getTypeDerivedFrom().resolve(TypeIdentifierMap));
    if (DT.isSubroutineType()) {
      DITypeArray DTA = DISubroutineType(DT).getTypeArray();
      for (unsigned i = 0, e = DTA.getNumElements(); i != e; ++i)
        processType(DTA.getElement(i).resolve(TypeIdentifierMap));
      return;
    }
    DIArray DA = DCT.getElements();
    for (unsigned i = 0, e = DA.getNumElements(); i != e; ++i) {
      DIDescriptor D = DA.getElement(i);
      if (D.isType())
        processType(DIType(D));
      else if (D.isSubprogram())
        processSubprogram(DISubprogram(D));
    }
  } else if (DT.isDerivedType()) {
    DIDerivedType DDT(DT);
    processType(DDT.getTypeDerivedFrom().resolve(TypeIdentifierMap));
  }
}
开发者ID:cschreiner,项目名称:llvm,代码行数:26,代码来源:DebugInfo.cpp

示例8: emitGCNO

void GCOVProfiler::emitGCNO() {
  NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu");
  if (!CU_Nodes) return;

  for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
    // Each compile unit gets its own .gcno file. This means that whether we run
    // this pass over the original .o's as they're produced, or run it after
    // LTO, we'll generate the same .gcno files.

    DICompileUnit CU(CU_Nodes->getOperand(i));
    std::string ErrorInfo;
    raw_fd_ostream out(mangleName(CU, "gcno").c_str(), ErrorInfo,
                       raw_fd_ostream::F_Binary);
    if (!Use402Format)
      out.write("oncg*404MVLL", 12);
    else
      out.write("oncg*204MVLL", 12);

    DIArray SPs = CU.getSubprograms();
    for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i) {
      DISubprogram SP(SPs.getElement(i));
      if (!SP.Verify()) continue;

      Function *F = SP.getFunction();
      if (!F) continue;
      GCOVFunction Func(SP, &out, Use402Format, UseExtraChecksum);

      for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
        GCOVBlock &Block = Func.getBlock(BB);
        TerminatorInst *TI = BB->getTerminator();
        if (int successors = TI->getNumSuccessors()) {
          for (int i = 0; i != successors; ++i) {
            Block.addEdge(Func.getBlock(TI->getSuccessor(i)));
          }
        } else if (isa<ReturnInst>(TI)) {
          Block.addEdge(Func.getReturnBlock());
        }

        uint32_t Line = 0;
        for (BasicBlock::iterator I = BB->begin(), IE = BB->end();
             I != IE; ++I) {
          const DebugLoc &Loc = I->getDebugLoc();
          if (Loc.isUnknown()) continue;
          if (Line == Loc.getLine()) continue;
          Line = Loc.getLine();
          if (SP != getDISubprogram(Loc.getScope(*Ctx))) continue;

          GCOVLines &Lines = Block.getFile(SP.getFilename());
          Lines.addLine(Loc.getLine());
        }
      }
      Func.writeOut();
    }
    out.write("\0\0\0\0\0\0\0\0", 8);  // EOF
    out.close();
  }
}
开发者ID:chandlerc,项目名称:llvm-hacking,代码行数:57,代码来源:GCOVProfiling.cpp

示例9: processModule

/// processModule - Process entire module and collect debug info.
void DebugInfoFinder::processModule(const Module &M) {
  if (NamedMDNode *CU_Nodes = M.getNamedMetadata("llvm.dbg.cu")) {
    TypeIdentifierMap = generateDITypeIdentifierMap(CU_Nodes);
    for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
      DICompileUnit CU(CU_Nodes->getOperand(i));
      addCompileUnit(CU);
      DIArray GVs = CU.getGlobalVariables();
      for (unsigned i = 0, e = GVs.getNumElements(); i != e; ++i) {
        DIGlobalVariable DIG(GVs.getElement(i));
        if (addGlobalVariable(DIG)) {
          processScope(DIG.getContext());
          processType(DIG.getType());
        }
      }
      DIArray SPs = CU.getSubprograms();
      for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i)
        processSubprogram(DISubprogram(SPs.getElement(i)));
      DIArray EnumTypes = CU.getEnumTypes();
      for (unsigned i = 0, e = EnumTypes.getNumElements(); i != e; ++i)
        processType(DIType(EnumTypes.getElement(i)));
      DIArray RetainedTypes = CU.getRetainedTypes();
      for (unsigned i = 0, e = RetainedTypes.getNumElements(); i != e; ++i)
        processType(DIType(RetainedTypes.getElement(i)));
      DIArray Imports = CU.getImportedEntities();
      for (unsigned i = 0, e = Imports.getNumElements(); i != e; ++i) {
        DIImportedEntity Import = DIImportedEntity(
                                    Imports.getElement(i));
        DIDescriptor Entity = Import.getEntity();
        if (Entity.isType())
          processType(DIType(Entity));
        else if (Entity.isSubprogram())
          processSubprogram(DISubprogram(Entity));
        else if (Entity.isNameSpace())
          processScope(DINameSpace(Entity).getContext());
      }
      // FIXME: We really shouldn't be bailing out after visiting just one CU
      return;
    }
  }
}
开发者ID:,项目名称:,代码行数:41,代码来源:

示例10: processModule

void DebugInfoFinder::processModule(const Module &M) {
  InitializeTypeMap(M);
  if (NamedMDNode *CU_Nodes = M.getNamedMetadata("llvm.dbg.cu")) {
    for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
      DICompileUnit CU(CU_Nodes->getOperand(i));
      addCompileUnit(CU);
      DIArray GVs = CU.getGlobalVariables();
      for (unsigned i = 0, e = GVs.getNumElements(); i != e; ++i) {
        DIGlobalVariable DIG(GVs.getElement(i));
        if (addGlobalVariable(DIG)) {
          processScope(DIG.getContext());
          processType(DIG.getType().resolve(TypeIdentifierMap));
        }
      }
      DIArray SPs = CU.getSubprograms();
      for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i)
        processSubprogram(DISubprogram(SPs.getElement(i)));
      DIArray EnumTypes = CU.getEnumTypes();
      for (unsigned i = 0, e = EnumTypes.getNumElements(); i != e; ++i)
        processType(DIType(EnumTypes.getElement(i)));
      DIArray RetainedTypes = CU.getRetainedTypes();
      for (unsigned i = 0, e = RetainedTypes.getNumElements(); i != e; ++i)
        processType(DIType(RetainedTypes.getElement(i)));
      DIArray Imports = CU.getImportedEntities();
      for (unsigned i = 0, e = Imports.getNumElements(); i != e; ++i) {
        DIImportedEntity Import = DIImportedEntity(Imports.getElement(i));
        if (!Import)
          continue;
        DIDescriptor Entity = Import.getEntity().resolve(TypeIdentifierMap);
        if (Entity.isType())
          processType(DIType(Entity));
        else if (Entity.isSubprogram())
          processSubprogram(DISubprogram(Entity));
        else if (Entity.isNameSpace())
          processScope(DINameSpace(Entity).getContext());
      }
    }
  }
}
开发者ID:chapuni,项目名称:llvm,代码行数:39,代码来源:DebugInfo.cpp

示例11: addTemplateParams

/// addTemplateParams - Add template parameters in buffer.
void CompileUnit::addTemplateParams(DIE &Buffer, DIArray TParams) {
  // Add template parameters.
  for (unsigned i = 0, e = TParams.getNumElements(); i != e; ++i) {
    DIDescriptor Element = TParams.getElement(i);
    if (Element.isTemplateTypeParameter())
      Buffer.addChild(getOrCreateTemplateTypeParameterDIE(
                        DITemplateTypeParameter(Element)));
    else if (Element.isTemplateValueParameter())
      Buffer.addChild(getOrCreateTemplateValueParameterDIE(
                        DITemplateValueParameter(Element)));
  }

}
开发者ID:,项目名称:,代码行数:14,代码来源:

示例12: processSubprograms

void Matcher::processSubprograms(DICompileUnit &DICU)
{
  if (DICU.getRunTimeVersion() > LLVMDebugVersion10) {
    DIArray SPs = DICU.getSubprograms();
    for (unsigned i = 0, e = SPs.getNumElements(); i != e; i++) {
      DISubprogram DISP(SPs.getElement(i));
      DISPCopy Copy(DISP);
      if (Copy.name.empty() || Copy.filename.empty() || Copy.linenumber == 0)
        continue;
      Copy.lastline = ScopeInfoFinder::getLastLine(Copy.function);
      MySPs.push_back(Copy);
    }
  }
}
开发者ID:sdasgup3,项目名称:llvm-slicer,代码行数:14,代码来源:Matcher.cpp

示例13: addPubTypes

/// addPubTypes - Add type for pubtypes section.
void CompileUnit::addPubTypes(DISubprogram SP) {
  DICompositeType SPTy = SP.getType();
  unsigned SPTag = SPTy.getTag();
  if (SPTag != dwarf::DW_TAG_subroutine_type)
    return;

  DIArray Args = SPTy.getTypeArray();
  for (unsigned i = 0, e = Args.getNumElements(); i != e; ++i) {
    DIType ATy(Args.getElement(i));
    if (!ATy.Verify())
      continue;
    addGlobalType(ATy);
  }
}
开发者ID:,项目名称:,代码行数:15,代码来源:

示例14: CU

DITypeIdentifierMap
llvm::generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes) {
  DITypeIdentifierMap Map;
  for (unsigned CUi = 0, CUe = CU_Nodes->getNumOperands(); CUi != CUe; ++CUi) {
    DICompileUnit CU(CU_Nodes->getOperand(CUi));
    DIArray Retain = CU.getRetainedTypes();
    for (unsigned Ti = 0, Te = Retain.getNumElements(); Ti != Te; ++Ti) {
      if (!Retain.getElement(Ti).isCompositeType())
        continue;
      DICompositeType Ty(Retain.getElement(Ti));
      if (MDString *TypeId = Ty.getIdentifier()) {
        // Definition has priority over declaration.
        // Try to insert (TypeId, Ty) to Map.
        std::pair<DITypeIdentifierMap::iterator, bool> P =
            Map.insert(std::make_pair(TypeId, Ty));
        // If TypeId already exists in Map and this is a definition, replace
        // whatever we had (declaration or definition) with the definition.
        if (!P.second && !Ty.isForwardDecl())
          P.first->second = Ty;
      }
    }
  }
  return Map;
}
开发者ID:cschreiner,项目名称:llvm,代码行数:24,代码来源:DebugInfo.cpp

示例15: processSubprogram

void DebugInfoFinder::processSubprogram(DISubprogram SP) {
  if (!addSubprogram(SP))
    return;
  processScope(SP.getContext().resolve(TypeIdentifierMap));
  processType(SP.getType());
  DIArray TParams = SP.getTemplateParams();
  for (unsigned I = 0, E = TParams.getNumElements(); I != E; ++I) {
    DIDescriptor Element = TParams.getElement(I);
    if (Element.isTemplateTypeParameter()) {
      DITemplateTypeParameter TType(Element);
      processType(TType.getType().resolve(TypeIdentifierMap));
    } else if (Element.isTemplateValueParameter()) {
      DITemplateValueParameter TVal(Element);
      processType(TVal.getType().resolve(TypeIdentifierMap));
    }
  }
}
开发者ID:RichardsonAlex,项目名称:llvm,代码行数:17,代码来源:DebugInfo.cpp


注:本文中的DIArray::getElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。