Variable.h

Go to the documentation of this file.
00001 /*
00002  * See the dyninst/COPYRIGHT file for copyright information.
00003  * 
00004  * We provide the Paradyn Tools (below described as "Paradyn")
00005  * on an AS IS basis, and do not warrant its validity or performance.
00006  * We reserve the right to update, modify, or discontinue this
00007  * software at any time.  We shall have no obligation to supply such
00008  * updates or modifications or any other form of support to you.
00009  * 
00010  * By your use of Paradyn, you understand and agree that we (or any
00011  * other person or entity with proprietary rights in Paradyn) are
00012  * under no obligation to provide either maintenance services,
00013  * update services, notices of latent defects, or correction of
00014  * defects for Paradyn.
00015  * 
00016  * This library is free software; you can redistribute it and/or
00017  * modify it under the terms of the GNU Lesser General Public
00018  * License as published by the Free Software Foundation; either
00019  * version 2.1 of the License, or (at your option) any later version.
00020  * 
00021  * This library is distributed in the hope that it will be useful,
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00024  * Lesser General Public License for more details.
00025  * 
00026  * You should have received a copy of the GNU Lesser General Public
00027  * License along with this library; if not, write to the Free Software
00028  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00029  */
00030 
00031 #if !defined(_Variable_h_)
00032 #define _Variable_h_
00033 
00034 #include "Annotatable.h"
00035 #include "Serialization.h"
00036 #include "Symtab.h"
00037 #include "Aggregate.h"
00038 #include "dyn_regs.h"
00039 #include "VariableLocation.h"
00040 
00041 //class Dyninst::SymtabAPI::Variable;
00042 SYMTAB_EXPORT std::ostream &operator<<(std::ostream &os, const Dyninst::SymtabAPI::Variable &);
00043 
00044 namespace Dyninst {
00045 namespace SymtabAPI {
00046 
00047 
00048 class Symbol;
00049 class Symtab;
00050 class Aggregate;
00051 class Function;
00052 
00053 class Variable : public Aggregate, public Serializable, public AnnotatableSparse {
00054     friend class Symtab;
00055     friend std::ostream &::operator<<(std::ostream &os, const Dyninst::SymtabAPI::Variable &);
00056 
00057     private:
00058    SYMTAB_EXPORT Variable(Symbol *sym);
00059    SYMTAB_EXPORT static Variable *createVariable(Symbol *sym);
00060    
00061  public:
00062    SYMTAB_EXPORT Variable();
00063     /* Symbol management */
00064     SYMTAB_EXPORT bool removeSymbol(Symbol *sym);      
00065 
00066    SYMTAB_EXPORT void setType(Type *type);
00067    SYMTAB_EXPORT Type *getType();
00068 
00069    SYMTAB_EXPORT Serializable *serialize_impl(SerializerBase *sb, 
00070            const char *tag = "Variable") THROW_SPEC (SerializerError);
00071    SYMTAB_EXPORT bool operator==(const Variable &v);
00072 
00073  private:
00074 
00075    Type *type_;
00076 };
00077 
00078 class localVar : public Serializable, public AnnotatableSparse
00079 {
00080     friend class typeCommon;
00081     friend class localVarCollection;
00082 
00083     std::string name_;
00084     Type *type_;
00085     std::string fileName_;
00086     int lineNum_;
00087         Function *func_;
00088     std::vector<VariableLocation> locs_;
00089         // We start with an abstract location that may include "the frame
00090         // pointer" as a register. Once a user requests the location list
00091         // we concretize it and set this flag.
00092         bool locsExpanded_;
00093         
00094     // scope_t scope;
00095 
00096         void expandLocation(const VariableLocation &var,
00097                             std::vector<VariableLocation> &ret);
00098 
00099     public:
00100     SYMTAB_EXPORT localVar() :
00101         type_(NULL), lineNum_(-1), func_(NULL), locsExpanded_(false) {}
00102     //  Internal use only
00103     localVar(std::string name,  Type *typ, std::string fileName, 
00104             int lineNum, Function *f, 
00105             std::vector<VariableLocation> *locs = NULL);
00106             
00107     // Copy constructor
00108     localVar(localVar &lvar);
00109     bool addLocation(VariableLocation &location);
00110     SYMTAB_EXPORT ~localVar();
00111     SYMTAB_EXPORT void fixupUnknown(Module *);
00112 
00113     public:
00114     //  end of functions for internal use only
00115     SYMTAB_EXPORT std::string &getName();
00116     SYMTAB_EXPORT Type *getType();
00117     SYMTAB_EXPORT bool setType(Type *newType);
00118     SYMTAB_EXPORT int  getLineNum();
00119     SYMTAB_EXPORT std::string &getFileName();
00120     SYMTAB_EXPORT std::vector<VariableLocation> &getLocationLists();
00121     SYMTAB_EXPORT bool operator==(const localVar &l);
00122     SYMTAB_EXPORT Serializable *serialize_impl(SerializerBase *, 
00123             const char * = "localVar") THROW_SPEC(SerializerError);
00124 };
00125 
00126 }
00127 }
00128 
00129 
00130 #endif
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 12 Jul 2013 for SymtabAPI by  doxygen 1.6.1