コード例 #1
0
ファイル: DebugDatabase.cpp プロジェクト: eddiehung/dox-legup
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);
        }
    }
}
コード例 #2
0
/// PopulateArrayTypeInfo - Populate TypeNo, Aux[] for array from Ty.
void PIC16DbgInfo::PopulateArrayTypeInfo (DIType Ty, unsigned short &TypeNo,
                                          bool &HasAux, int Aux[],
                                          std::string &TagName) {

  DICompositeType CTy = DICompositeType(Ty.getGV());
  DIArray Elements = CTy.getTypeArray();
  unsigned short size = 1;
  unsigned short Dimension[4]={0,0,0,0};
  for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
    DIDescriptor Element = Elements.getElement(i);
    if (Element.getTag() == dwarf::DW_TAG_subrange_type) {
      TypeNo = TypeNo << PIC16Dbg::S_DERIVED;
      TypeNo = TypeNo | PIC16Dbg::DT_ARY;
      DISubrange SubRange = DISubrange(Element.getGV());
      Dimension[i] = SubRange.getHi() - SubRange.getLo() + 1;
      // Each dimension is represented by 2 bytes starting at byte 9.
      Aux[8+i*2+0] = Dimension[i];
      Aux[8+i*2+1] = Dimension[i] >> 8;
      size = size * Dimension[i];
    }
  }
コード例 #3
0
/// constructSubrangeDIE - Construct subrange DIE from DISubrange.
void CompileUnit::constructSubrangeDIE(DIE &Buffer, DISubrange SR, DIE *IndexTy){
  DIE *DW_Subrange = new DIE(dwarf::DW_TAG_subrange_type);
  addDIEEntry(DW_Subrange, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IndexTy);
  int64_t L = SR.getLo();
  int64_t H = SR.getHi();

  // The L value defines the lower bounds which is typically zero for C/C++. The
  // H value is the upper bounds.  Values are 64 bit.  H - L + 1 is the size
  // of the array. If L > H then do not emit DW_AT_lower_bound and 
  // DW_AT_upper_bound attributes. If L is zero and H is also zero then the
  // array has one element and in such case do not emit lower bound.

  if (L > H) {
    Buffer.addChild(DW_Subrange);
    return;
  }
  if (L)
    addSInt(DW_Subrange, dwarf::DW_AT_lower_bound, 0, L);
  addSInt(DW_Subrange, dwarf::DW_AT_upper_bound, 0, H);
  Buffer.addChild(DW_Subrange);
}