Exemple #1
0
/// addGlobalType - Add a new global type to the compile unit.
///
void CompileUnit::addGlobalType(DIType Ty) {
  DIDescriptor Context = Ty.getContext();
  if (Ty.isCompositeType() && !Ty.getName().empty() && !Ty.isForwardDecl() 
      && (Context.isCompileUnit() || Context.isFile() || Context.isNameSpace()))
    if (DIEEntry *Entry = getDIEEntry(Ty))
      GlobalTypes[Ty.getName()] = Entry->getEntry();
}
Exemple #2
0
void DIEItem::FormatDIType(wxTextOutputStream& out, DIType type) const {
  if (type.isCompositeType()) {
    DICompositeType diCompType(type);
    if (!type.getName().empty()) {
      out << toWxStr(type.getName());
    } else {
      out << _("?Implement unnamed composite");
      // TODO: Implement:
      // DW_TAG_array_type
      // DW_TAG_enumeration_type
      // DW_TAG_structure_type
      // DW_TAG_union_type
      // DW_TAG_vector_type
      // DW_TAG_subroutine_type
      // DW_TAG_inheritance
    }
  } else if (type.isDerivedType()) {
    DIDerivedType diDerivedType(type);
    DIType diBase = diDerivedType.getTypeDerivedFrom();
    switch (diDerivedType.getTag()) {
      case dwarf::DW_TAG_inheritance:
        FormatDIType(out, diBase);
        break;

      case dwarf::DW_TAG_pointer_type:
        FormatDIType(out, diBase);
        out << _("*");
        break;

      case dwarf::DW_TAG_array_type:
        FormatDIType(out, diBase);
        // TODO: Get the array size, use LLVM array notation.
        out << _("[]");
        break;

      case dwarf::DW_TAG_member:
        out << toWxStr(diDerivedType.getName());
        break;

      case dwarf::DW_TAG_reference_type:
      case dwarf::DW_TAG_const_type:
      case dwarf::DW_TAG_volatile_type:
      case dwarf::DW_TAG_restrict_type:
      case dwarf::DW_TAG_typedef:
        // TODO: Implement
        break;
    }
  } else if (type.isBasicType()) {
    DIBasicType diBasicType(type);
    const char * encodingName =
        dwarf::AttributeEncodingString(diBasicType.getEncoding());
    if (encodingName != NULL) {
      out << toWxStr(encodingName);
    }
  }
}
/// PopulateBasicTypeInfo- Populate TypeNo for basic type from Ty.
///
void PIC16DbgInfo::PopulateBasicTypeInfo (DIType Ty, unsigned short &TypeNo) {
  std::string Name = "";
  Ty.getName(Name);
  unsigned short BaseTy = GetTypeDebugNumber(Name);
  TypeNo = TypeNo << PIC16Dbg::S_BASIC;
  TypeNo = TypeNo | (0xffff & BaseTy);
}
static bool getLocationInfo(const Value *V, std::string &DisplayName,
                            std::string &Type, unsigned &LineNo,
                            std::string &File, std::string &Dir) {
  DICompileUnit Unit;
  DIType TypeD;

  if (GlobalVariable *GV = dyn_cast<GlobalVariable>(const_cast<Value*>(V))) {
    Value *DIGV = findDbgGlobalDeclare(GV);
    if (!DIGV) return false;
    DIGlobalVariable Var(cast<MDNode>(DIGV));

    StringRef D = Var.getDisplayName();
    if (!D.empty())
      DisplayName = D;
    LineNo = Var.getLineNumber();
    Unit = Var.getCompileUnit();
    TypeD = Var.getType();
  } else if (Function *F = dyn_cast<Function>(const_cast<Value*>(V))){
    Value *DIF = findDbgSubprogramDeclare(F);
    if (!DIF) return false;
    DISubprogram Var(cast<MDNode>(DIF));

    StringRef D = Var.getDisplayName();
    if (!D.empty())
      DisplayName = D;
    LineNo = Var.getLineNumber();
    Unit = Var.getCompileUnit();
    TypeD = Var.getType();
  } else {
    const DbgDeclareInst *DDI = findDbgDeclare(V);
    if (!DDI) return false;
    DIVariable Var(cast<MDNode>(DDI->getVariable()));

    StringRef D = Var.getName();
    if (!D.empty())
      DisplayName = D;
    LineNo = Var.getLineNumber();
    Unit = Var.getCompileUnit();
    TypeD = Var.getType();
  }

  StringRef T = TypeD.getName();
  if (!T.empty())
    Type = T;
  StringRef F = Unit.getFilename();
  if (!F.empty())
    File = F;
  StringRef D = Unit.getDirectory();
  if (!D.empty())
    Dir = D;
  return true;
}
Exemple #5
0
/// createPointerType - Create PointerType.
DIType DebugInfo::createPointerType(tree type) {

  DIType FromTy = getOrCreateType(TREE_TYPE(type));
  // type* and type&
  // FIXME: Should BLOCK_POINTER_TYP have its own DW_TAG?
  unsigned Tag = (TREE_CODE(type) == POINTER_TYPE ||
                  TREE_CODE(type) == BLOCK_POINTER_TYPE) ?
    DW_TAG_pointer_type :
    DW_TAG_reference_type;
  unsigned Flags = 0;
  if (type_is_block_byref_struct(type))
    Flags |= llvm::DIType::FlagBlockByrefStruct;

  // Check if this pointer type has a name.
  if (tree TyName = TYPE_NAME(type)) 
    if (TREE_CODE(TyName) == TYPE_DECL && !DECL_ORIGINAL_TYPE(TyName)) {
      expanded_location TypeNameLoc = GetNodeLocation(TyName);
      DIType Ty = 
        DebugFactory.CreateDerivedType(Tag, findRegion(DECL_CONTEXT(TyName)),
                                       GetNodeName(TyName), 
                                       getOrCreateFile(TypeNameLoc.file),
                                       TypeNameLoc.line,
                                       0 /*size*/,
                                       0 /*align*/,
                                       0 /*offset */, 
                                       0 /*flags*/, 
                                       FromTy);
      TypeCache[TyName] = WeakVH(Ty.getNode());
      return Ty;
    }
  
  StringRef PName = FromTy.getName();
  DIType PTy = 
    DebugFactory.CreateDerivedType(Tag, findRegion(TYPE_CONTEXT(type)),
                                   Tag == DW_TAG_pointer_type ? 
                                   StringRef() : PName,
                                   getOrCreateFile(main_input_filename),
                                   0 /*line no*/, 
                                   NodeSizeInBits(type),
                                   NodeAlignInBits(type),
                                   0 /*offset */, 
                                   Flags, 
                                   FromTy);
  return PTy;
}
Exemple #6
0
bool getLocationInfo(const Value *V, std::string &DisplayName,
                     std::string &Type, unsigned &LineNo, std::string &File,
                       std::string &Dir) {
    DICompileUnit Unit;
    DIType TypeD;

    if (GlobalVariable *GV = dyn_cast<GlobalVariable>(const_cast<Value*>(V))) {
      Value *DIGV = findDbgGlobalDeclare(GV);
      if (!DIGV) return false;
      DIGlobalVariable Var(cast<MDNode>(DIGV));

      if (const char *D = Var.getDisplayName())
        DisplayName = D;
      LineNo = Var.getLineNumber();
      Unit = Var.getCompileUnit();
      TypeD = Var.getType();
    } else {
      const DbgDeclareInst *DDI = findDbgDeclare(V);
      if (!DDI) return false;
      DIVariable Var(cast<MDNode>(DDI->getVariable()));

      if (const char *D = Var.getName())
        DisplayName = D;
      LineNo = Var.getLineNumber();
      Unit = Var.getCompileUnit();
      TypeD = Var.getType();
    }

    if (const char *T = TypeD.getName())
      Type = T;
    if (const char *F = Unit.getFilename())
      File = F;
    if (const char *D = Unit.getDirectory())
      Dir = D;
    return true;
  }