2 * Copyright (c) 1996-2007 Barton P. Miller
4 * We provide the Paradyn Parallel Performance Tools (below
5 * described as "Paradyn") on an AS IS basis, and do not warrant its
6 * validity or performance. We reserve the right to update, modify,
7 * or discontinue this software at any time. We shall have no
8 * obligation to supply such updates or modifications or any other
9 * form of support to you.
11 * By your use of Paradyn, you understand and agree that we (or any
12 * other person or entity with proprietary rights in Paradyn) are
13 * under no obligation to provide either maintenance services,
14 * update services, notices of latent defects, or correction of
15 * defects for Paradyn.
17 * This library is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU Lesser General Public
19 * License as published by the Free Software Foundation; either
20 * version 2.1 of the License, or (at your option) any later version.
22 * This library is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 * Lesser General Public License for more details.
27 * You should have received a copy of the GNU Lesser General Public
28 * License along with this library; if not, write to the Free Software
29 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
32 #ifndef _Collections_h_
33 #define _Collections_h_
46 * This class contains a collection of local variables.
47 * Each function will have one of these objects associated with it.
48 * This object will store all the local variables within this function.
49 * Note: This class is unaware of scope.
51 class SYMTAB_EXPORT localVarCollection : public Serializable, public AnnotatableSparse {
53 dyn_hash_map<std::string, localVar *> localVariablesByName;
54 vector<localVar *> localVars;
57 localVarCollection(){}
58 ~localVarCollection();
60 void addLocalVar(localVar * var);
61 localVar * findLocalVar(std::string &name);
62 vector<localVar *> *getAllVars();
64 void serialize(SerializerBase *, const char * = "localVarCollection");
70 * Due to DWARF weirdness, this can be shared between multiple BPatch_modules.
71 * So we reference-count to make life easier.
73 class SYMTAB_EXPORT typeCollection : public Serializable, public AnnotatableSparse {
77 friend class SymtabTranslatorBase;
78 friend class SymtabTranslatorBin;
80 dyn_hash_map<std::string, Type *> typesByName;
81 dyn_hash_map<std::string, Type *> globalVarsByName;
82 dyn_hash_map<int, Type *> typesByID;
90 /* Cache type collections on a per-image basis. (Since
91 BPatch_functions are solitons, we don't have to cache them.) */
92 static dyn_hash_map< std::string, typeCollection * > fileToTypesMap;
98 void serialize(SerializerBase *, const char * = "typeCollection");
99 static typeCollection *getGlobalTypeCollection();
100 static typeCollection *getModTypeCollection(Module *mod);
101 static void freeTypeCollection(typeCollection *tc);
104 bool dwarfParsed() { return dwarfParsed_; }
105 void setDwarfParsed() { dwarfParsed_ = true; }
107 Type *findType(std::string name);
108 Type *findType(const int ID);
109 Type *findTypeLocal(std::string name);
110 Type *findTypeLocal(const int ID);
111 void addType(Type *type);
112 void addGlobalVariable(std::string &name, Type *type);
114 /* Some debug formats allow forward references. Rather than
115 fill in forward in a second pass, generate placeholder
116 types, and fill them in as we go. Because we require
117 One True Pointer for each type (in parseStab.C), when
118 updating a type, return that One True Pointer. */
119 Type * findOrCreateType( const int ID );
121 T* addOrUpdateType(T* type);
123 Type *findVariableType(std::string &name);
125 std::vector<Type *> *getAllTypes();
126 std::vector<std::pair<std::string, Type *> > *getAllGlobalVariables();
127 void clearNumberedTypes();
131 * This class defines the collection for the built-in Types
132 * gnu ( and AIX??) use negative numbers to define other types
133 * in terms of these built-in types.
134 * This collection is global and built in the BPatch_image constructor.
135 * This means that only one collection of built-in types is made
136 * per image. jdd 4/21/99
140 class SYMTAB_EXPORT builtInTypeCollection {
142 dyn_hash_map<std::string, Type *> builtInTypesByName;
143 dyn_hash_map<int, Type *> builtInTypesByID;
146 builtInTypeCollection();
147 ~builtInTypeCollection();
149 Type *findBuiltInType(std::string &name);
150 Type *findBuiltInType(const int ID);
151 void addBuiltInType(Type *type);
152 std::vector<Type *> *getAllBuiltInTypes();
156 }// namespace SymtabAPI
157 }// namespace Dyninst
159 #endif /* _Collections_h_ */