Collections.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef _Collections_h_
00032 #define _Collections_h_
00033
00034 #include "Type.h"
00035 #include "Variable.h"
00036 #include "Serialization.h"
00037
00038 namespace Dyninst {
00039
00040 namespace SymtabAPI {
00041
00042 class Module;
00043 class Symtab;
00044 class localVar;
00045 class DwarfWalker;
00046
00047
00048
00049
00050
00051
00052
00053 class localVarCollection : public AnnotationContainer<localVar *> {
00054
00055 std::vector<localVar *> localVars;
00056
00057 SYMTAB_EXPORT bool addItem_impl(localVar *);
00058 public:
00059 SYMTAB_EXPORT localVarCollection(){}
00060 SYMTAB_EXPORT ~localVarCollection();
00061
00062 SYMTAB_EXPORT void addLocalVar(localVar * var);
00063 SYMTAB_EXPORT localVar * findLocalVar(std::string &name);
00064 SYMTAB_EXPORT std::vector<localVar *> *getAllVars();
00065
00066 SYMTAB_EXPORT Serializable *ac_serialize_impl(SerializerBase *, const char * = "localVarCollection") THROW_SPEC (SerializerError);
00067 };
00068
00069
00070
00071
00072
00073
00074
00075 class typeCollection : public Serializable
00076 {
00077 friend class Symtab;
00078 friend class Object;
00079 friend class Module;
00080 friend class Type;
00081 friend class DwarfWalker;
00082
00083 dyn_hash_map<std::string, Type *> typesByName;
00084 dyn_hash_map<std::string, Type *> globalVarsByName;
00085 dyn_hash_map<int, Type *> typesByID;
00086
00087
00088
00089
00090
00091 static dyn_hash_map< void *, typeCollection * > fileToTypesMap;
00092
00093 static bool doDeferredLookups(typeCollection *);
00094
00095
00096 bool dwarfParsed_;
00097
00098 SYMTAB_EXPORT Serializable *serialize_impl(SerializerBase *, const char * = "typeCollection") THROW_SPEC (SerializerError);
00099 public:
00100 SYMTAB_EXPORT typeCollection();
00101 SYMTAB_EXPORT ~typeCollection();
00102 public:
00103 static void addDeferredLookup(int, dataClass, Type **);
00104
00105 SYMTAB_EXPORT static typeCollection *getModTypeCollection(Module *mod);
00106 #if 0
00107 SYMTAB_EXPORT static typeCollection *getGlobalTypeCollection();
00108 SYMTAB_EXPORT static void freeTypeCollection(typeCollection *tc);
00109 #endif
00110
00111
00112 SYMTAB_EXPORT bool dwarfParsed() { return dwarfParsed_; }
00113 SYMTAB_EXPORT void setDwarfParsed() { dwarfParsed_ = true; }
00114
00115 SYMTAB_EXPORT Type *findType(std::string name);
00116 SYMTAB_EXPORT Type *findType(const int ID);
00117 SYMTAB_EXPORT Type *findTypeLocal(std::string name);
00118 SYMTAB_EXPORT Type *findTypeLocal(const int ID);
00119 SYMTAB_EXPORT void addType(Type *type);
00120 SYMTAB_EXPORT void addGlobalVariable(std::string &name, Type *type);
00121
00122
00123
00124
00125
00126
00127 SYMTAB_EXPORT Type * findOrCreateType( const int ID );
00128 template<class T>
00129 SYMTAB_EXPORT T* addOrUpdateType(T* type);
00130
00131 SYMTAB_EXPORT Type *findVariableType(std::string &name);
00132
00133 SYMTAB_EXPORT std::vector<Type *> *getAllTypes();
00134 SYMTAB_EXPORT std::vector<std::pair<std::string, Type *> > *getAllGlobalVariables();
00135 SYMTAB_EXPORT void clearNumberedTypes();
00136 };
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 class SYMTAB_EXPORT builtInTypeCollection {
00149
00150 dyn_hash_map<std::string, Type *> builtInTypesByName;
00151 dyn_hash_map<int, Type *> builtInTypesByID;
00152 public:
00153
00154 builtInTypeCollection();
00155 ~builtInTypeCollection();
00156
00157 Type *findBuiltInType(std::string &name);
00158 Type *findBuiltInType(const int ID);
00159 void addBuiltInType(Type *type);
00160 std::vector<Type *> *getAllBuiltInTypes();
00161
00162 };
00163
00164 }
00165 }
00166
00167 #endif
00168
00169
00170