Ejemplo n.º 1
0
TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestTypedefs)) {
    FileSpec fspec(m_types_test_exe.c_str(), false);
    ArchSpec aspec("i686-pc-windows");
    lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);

    SymbolVendor *plugin = module->GetSymbolVendor();
    SymbolFilePDB *symfile =
        static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
    const llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
    SymbolContext sc;
    llvm::DenseSet<SymbolFile *> searched_files;
    TypeMap results;

    const char *TypedefsToCheck[] = {"ClassTypedef", "NSClassTypedef"};
    for (auto Typedef : TypedefsToCheck) {
        TypeMap results;
        EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString(Typedef), nullptr, false,
                                         0, searched_files, results));
        EXPECT_EQ(1u, results.GetSize());
        lldb::TypeSP typedef_type = results.GetTypeAtIndex(0);
        EXPECT_EQ(ConstString(Typedef), typedef_type->GetName());
        CompilerType compiler_type = typedef_type->GetFullCompilerType();
        ClangASTContext *clang_type_system =
            llvm::dyn_cast_or_null<ClangASTContext>(compiler_type.GetTypeSystem());
        EXPECT_TRUE(
            clang_type_system->IsTypedefType(compiler_type.GetOpaqueQualType()));

        std::string sizeof_var = "sizeof_";
        sizeof_var.append(Typedef);
        EXPECT_EQ(GetGlobalConstantInteger(session, sizeof_var.c_str()),
                  typedef_type->GetByteSize());
    }
}
Ejemplo n.º 2
0
TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestEnumTypes)) {
    FileSpec fspec(m_types_test_exe.c_str(), false);
    ArchSpec aspec("i686-pc-windows");
    lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);

    SymbolVendor *plugin = module->GetSymbolVendor();
    SymbolFilePDB *symfile =
        static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
    const llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
    SymbolContext sc;
    llvm::DenseSet<SymbolFile *> searched_files;
    const char *EnumsToCheck[] = {"Enum", "ShortEnum"};
    for (auto Enum : EnumsToCheck) {
        TypeMap results;
        EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString(Enum), nullptr, false, 0,
                                         searched_files, results));
        EXPECT_EQ(1u, results.GetSize());
        lldb::TypeSP enum_type = results.GetTypeAtIndex(0);
        EXPECT_EQ(ConstString(Enum), enum_type->GetName());
        CompilerType compiler_type = enum_type->GetFullCompilerType();
        EXPECT_TRUE(ClangASTContext::IsEnumType(compiler_type.GetOpaqueQualType()));
        clang::EnumDecl *enum_decl = ClangASTContext::GetAsEnumDecl(compiler_type);
        EXPECT_NE(nullptr, enum_decl);
        EXPECT_EQ(2, std::distance(enum_decl->enumerator_begin(),
                                   enum_decl->enumerator_end()));

        std::string sizeof_var = "sizeof_";
        sizeof_var.append(Enum);
        EXPECT_EQ(GetGlobalConstantInteger(session, sizeof_var.c_str()),
                  enum_type->GetByteSize());
    }
}
Ejemplo n.º 3
0
TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestMaxMatches)) {
    FileSpec fspec(m_types_test_exe.c_str(), false);
    ArchSpec aspec("i686-pc-windows");
    lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);

    SymbolVendor *plugin = module->GetSymbolVendor();
    SymbolFilePDB *symfile =
        static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
    SymbolContext sc;
    llvm::DenseSet<SymbolFile *> searched_files;
    TypeMap results;
    uint32_t num_results = symfile->FindTypes(sc, ConstString(".*"), nullptr,
                           false, 0, searched_files, results);
    // Try to limit ourselves from 1 to 10 results, otherwise we could be doing
    // this thousands of times.
    // The idea is just to make sure that for a variety of values, the number of
    // limited results always
    // comes out to the number we are expecting.
    uint32_t iterations = std::min(num_results, 10u);
    for (uint32_t i = 1; i <= iterations; ++i) {
        uint32_t num_limited_results = symfile->FindTypes(
                                           sc, ConstString(".*"), nullptr, false, i, searched_files, results);
        EXPECT_EQ(i, num_limited_results);
        EXPECT_EQ(num_limited_results, results.GetSize());
    }
}
Ejemplo n.º 4
0
int main()
{
    TypeMap bin;
    fillBin("Trash.dat", bin); // Sorting happens
    TypeMap::iterator it;
    for (it = bin.begin(); it != bin.end(); it++)
        sumValue((*it).second);
} ///:~
Ejemplo n.º 5
0
Type* Protobuf::GetType(const Descriptor* descriptor) {
	TypeMap::iterator it = mTypeMap.find(descriptor);
	if (it != mTypeMap.end())
		return it->second;
	Type* result = mTypeMap[descriptor] = 
		new Type(this,
		factory.GetPrototype(descriptor)->New(),
		TypeTemplate->GetFunction()->NewInstance(),
		handles.size());
	handles.push_back(result);

    Handle<Array> types = handle_->GetInternalField(1).As<Array>();
    types->Set(types->Length(), result->handle_);
	return result;
}
Ejemplo n.º 6
0
TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestNullName)) {
    FileSpec fspec(m_types_test_exe.c_str(), false);
    ArchSpec aspec("i686-pc-windows");
    lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);

    SymbolVendor *plugin = module->GetSymbolVendor();
    SymbolFilePDB *symfile =
        static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
    SymbolContext sc;
    llvm::DenseSet<SymbolFile *> searched_files;
    TypeMap results;
    uint32_t num_results = symfile->FindTypes(sc, ConstString(), nullptr, false,
                           0, searched_files, results);
    EXPECT_EQ(0u, num_results);
    EXPECT_EQ(0u, results.GetSize());
}
Ejemplo n.º 7
0
	void bind( Y something, TypeInfoP interface){		
		if( found(get(interface)))
			throwOrBreak< M>();
		
		bindings.insert( std::pair< std::type_index, Y>
                    ( std::type_index(*interface), something));
	}
Ejemplo n.º 8
0
size_t
SymbolFile::FindTypes (const std::vector<CompilerContext> &context, bool append, TypeMap& types)
{
    if (!append)
        types.Clear();
    return 0;
}
Ejemplo n.º 9
0
uint32_t
SymbolFile::FindTypes (const SymbolContext& sc, const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, TypeMap& types)
{
    if (!append)
        types.Clear();
    return 0;
}
Ejemplo n.º 10
0
static
std::pair<typename ContainerTraits<TypeMap>::Iterator, typename ContainerTraits<TypeMap>::Iterator>
getOverlappingTypeInfos(TypeMap& tmap, size_t from, size_t len)
{
    typedef typename ContainerTraits<TypeMap>::Iterator Iterator;

    Iterator first = tmap.begin();
    Iterator last = tmap.end();
    Iterator ub = tmap.lower_bound(from + len);

    // the same for the beginning, but there we need the previous map entry
    Iterator lb = tmap.lower_bound(from);

    lb = adjustPosOnOverlap(first, lb, from);

    return std::make_pair(lb, ub);
}
Ejemplo n.º 11
0
uint32_t SymbolFile::FindTypes(
    const SymbolContext &sc, const ConstString &name,
    const CompilerDeclContext *parent_decl_ctx, bool append,
    uint32_t max_matches,
    llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
    TypeMap &types) {
  if (!append)
    types.Clear();
  return 0;
}
Ejemplo n.º 12
0
size_t SymbolVendor::FindTypes(const std::vector<CompilerContext> &context,
                               bool append, TypeMap &types) {
  ModuleSP module_sp(GetModule());
  if (module_sp) {
    std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
    if (m_sym_file_ap.get())
      return m_sym_file_ap->FindTypes(context, append, types);
  }
  if (!append)
    types.Clear();
  return 0;
}
Ejemplo n.º 13
0
TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestClassInNamespace)) {
    FileSpec fspec(m_types_test_exe.c_str(), false);
    ArchSpec aspec("i686-pc-windows");
    lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);

    SymbolVendor *plugin = module->GetSymbolVendor();
    SymbolFilePDB *symfile =
        static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
    const llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
    SymbolContext sc;
    llvm::DenseSet<SymbolFile *> searched_files;
    TypeMap results;
    EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString("NS::NSClass"), nullptr,
                                     false, 0, searched_files, results));
    EXPECT_EQ(1u, results.GetSize());
    lldb::TypeSP udt_type = results.GetTypeAtIndex(0);
    EXPECT_EQ(ConstString("NS::NSClass"), udt_type->GetName());
    CompilerType compiler_type = udt_type->GetForwardCompilerType();
    EXPECT_TRUE(ClangASTContext::IsClassType(compiler_type.GetOpaqueQualType()));
    EXPECT_EQ(GetGlobalConstantInteger(session, "sizeof_NSClass"),
              udt_type->GetByteSize());
}
Ejemplo n.º 14
0
TypeMap mapWithCommonTypes() {
	TypeMap m;

	m.emplace(typeid(short), MPI_SHORT);
	m.emplace(typeid(unsigned short), MPI_UNSIGNED_SHORT);
	m.emplace(typeid(int), MPI_INT);
	m.emplace(typeid(unsigned int), MPI_UNSIGNED);
	m.emplace(typeid(long long), MPI_LONG_LONG_INT);
	m.emplace(typeid(unsigned long long), MPI_UNSIGNED_LONG_LONG);

	return m;
}
Ejemplo n.º 15
0
size_t
SymbolVendor::FindTypes (const SymbolContext& sc, const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, TypeMap& types)
{
    ModuleSP module_sp(GetModule());
    if (module_sp)
    {
        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
        if (m_sym_file_ap.get())
            return m_sym_file_ap->FindTypes(sc, name, parent_decl_ctx, append, max_matches, types);
    }
    if (!append)
        types.Clear();
    return 0;
}
Ejemplo n.º 16
0
size_t
SymbolVendor::FindTypes (const std::vector<CompilerContext> &context, bool append, TypeMap& types)
{
    ModuleSP module_sp(GetModule());
    if (module_sp)
    {
        lldb_private::Mutex::Locker locker(module_sp->GetMutex());
        if (m_sym_file_ap.get())
            return m_sym_file_ap->FindTypes(context, append, types);
    }
    if (!append)
        types.Clear();
    return 0;
}
Ejemplo n.º 17
0
DataTypeFactory::TypeMap DataTypeFactory::typeMap()
{
    static TypeMap typeMap;
    if (typeMap.isEmpty()) {
        typeMap.insert(Type::Integer, "Integer");
        typeMap.insert(Type::Gauge32, "Gauge32");
        typeMap.insert(Type::Counter32, "Counter32");
        typeMap.insert(Type::OctetString, "String");
        typeMap.insert(Type::IpAddress, "IpAddress");
        typeMap.insert(Type::NullObject, "Unknown type");
    }
    return typeMap;
}
Ejemplo n.º 18
0
static bool has_task_or_graph_type(TypeMap<bool>& cache, const Type* type) {
    if (cache.emplace(type, false).second) {
        if (is_task_type(type) || is_graph_type(type))
            return cache[type] = true;
        bool contains = false;
        for (auto op : type->ops()) {
            if (has_task_or_graph_type(cache, op)) {
                contains = true;
                break;
            }
        }
        return cache[type] = contains;
    }

    return cache[type];
}
Ejemplo n.º 19
0
size_t SymbolVendor::FindTypes(
    const SymbolContext &sc, const ConstString &name,
    const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches,
    llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
    TypeMap &types) {
  ModuleSP module_sp(GetModule());
  if (module_sp) {
    std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
    if (m_sym_file_ap.get())
      return m_sym_file_ap->FindTypes(sc, name, parent_decl_ctx, append,
                                      max_matches, searched_symbol_files,
                                      types);
  }
  if (!append)
    types.Clear();
  return 0;
}
Ejemplo n.º 20
0
void
SymbolContext::SortTypeList(TypeMap &type_map, TypeList &type_list ) const
{
    Block * curr_block = block;
    bool isInlinedblock = false;
    if (curr_block != nullptr && curr_block->GetContainingInlinedBlock() != nullptr)
        isInlinedblock = true;

    while (curr_block != nullptr && !isInlinedblock)
    {
        TypeMoveMatchingBlock callbackBlock (curr_block, type_map, type_list);
        type_map.ForEach(callbackBlock);
        curr_block = curr_block->GetParent();
    }
    if(function != nullptr && type_map.GetSize() > 0)
    {
        TypeMoveMatchingFunction callbackFunction (function, type_map, type_list);
        type_map.ForEach(callbackFunction);
    }
    if(comp_unit != nullptr && type_map.GetSize() > 0)
    {
        TypeMoveMatchingCompileUnit callbackCompileUnit (comp_unit, type_map, type_list);
        type_map.ForEach(callbackCompileUnit);
    }
    if(module_sp && type_map.GetSize() > 0)
    {
        TypeMoveMatchingModule callbackModule (module_sp, type_map, type_list);
        type_map.ForEach(callbackModule);
    }
    if(type_map.GetSize() > 0)
    {
        TypeMaptoList callbackM2L (type_map, type_list);
        type_map.ForEach(callbackM2L);

    }
	return ;
}
Ejemplo n.º 21
0
	// forech-able necessary methods.
	typename TypeMap::iterator begin() { 
	
		return bindings.begin(); 
	}
Ejemplo n.º 22
0
	void remove( TypeInfoP interface){
		auto it = bindings.find( std::type_index(*interface) );
		if(it!=bindings.end()){
			bindings.erase( it);
		}
	}
Ejemplo n.º 23
0
	typename TypeMap::iterator get( TypeInfoP interface){
		return bindings.find( std::type_index(*interface));
	}
Ejemplo n.º 24
0
	Y getVal( std::type_index idx){
		return bindings.find( idx)->second;
	}
Ejemplo n.º 25
0
	typename TypeMap::iterator get( std::type_index & interface){
		return bindings.find( interface);
	}
Ejemplo n.º 26
0
	bool found(typename TypeMap::iterator it){
		return it != bindings.end();
	}
Ejemplo n.º 27
0
	/*! Get the number of elements in the data set.
	  \return number of elements */
	static size_t get_count() { return _valuemap.size(); }
Ejemplo n.º 28
0
    typename TypeMap::const_iterator begin() const {

		return bindings.begin(); 
	}
Ejemplo n.º 29
0
    typename TypeMap::iterator end() { 

		return bindings.end(); 
	}
Ejemplo n.º 30
0
    typename TypeMap::const_iterator end() const {  

		return bindings.end(); 
	}