Aggregate.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 /************************************************************************
00032  * $Id: Symbol.h,v 1.20 2008/11/03 15:19:24 jaw Exp $
00033 
00034 ************************************************************************/
00035 
00036 // Present a common superclass for all Symbol aggregates. 
00037 // We never create an Aggregate directly, but only via a child class.
00038 
00039 #if !defined(_Aggregate_h_)
00040 #define _Aggregate_h_
00041 
00042 #include <iostream>
00043 #include "Annotatable.h"
00044 
00045 SYMTAB_EXPORT std::ostream &operator<<(std::ostream &os, const Dyninst::SymtabAPI::Aggregate &);
00046 
00047 namespace Dyninst{
00048 namespace SymtabAPI{
00049 
00050 class Symbol;
00051 class Module;
00052 class Symtab; 
00053 class Region; 
00054 class Aggregate; 
00055 struct SymbolCompareByAddr;
00056 
00057 class Aggregate /*: public AnnotatableSparse  */
00058 {
00059     friend class Symtab;
00060     friend struct SymbolCompareByAddr;
00061     friend std::ostream &::operator<<(std::ostream &os, const Dyninst::SymtabAPI::Aggregate &);
00062 
00063  protected:
00064       SYMTAB_EXPORT Aggregate();
00065       SYMTAB_EXPORT Aggregate(Symbol *sym);
00066 
00067    public:
00068       
00069       virtual ~Aggregate() {};
00070 
00071       SYMTAB_EXPORT Offset   getOffset() const;
00072       SYMTAB_EXPORT unsigned getSize() const;
00073       SYMTAB_EXPORT Module * getModule() const { return module_; }
00074       SYMTAB_EXPORT Region * getRegion() const;
00075 
00076       /***** Symbol Collection Management *****/
00077       SYMTAB_EXPORT bool addSymbol(Symbol *sym);
00078       SYMTAB_EXPORT virtual bool removeSymbol(Symbol *sym) = 0;
00079       SYMTAB_EXPORT bool getSymbols(std::vector<Symbol *>&syms) const;
00080       SYMTAB_EXPORT Symbol * getFirstSymbol() const;
00081 
00082       /***** Symbol naming *****/
00083       SYMTAB_EXPORT const std::vector<std::string> &getAllMangledNames();
00084       SYMTAB_EXPORT const std::vector<std::string> &getAllPrettyNames();
00085       SYMTAB_EXPORT const std::vector<std::string> &getAllTypedNames();
00086 
00087       /***** Aggregate updating *****/
00088       SYMTAB_EXPORT virtual bool addMangledName(std::string name, bool isPrimary);
00089       SYMTAB_EXPORT virtual bool addPrettyName(std::string name, bool isPrimary);
00090       SYMTAB_EXPORT virtual bool addTypedName(std::string name, bool isPrimary);
00091 
00092       SYMTAB_EXPORT bool setModule(Module *mod);
00093       SYMTAB_EXPORT bool setSize(unsigned size);
00094       SYMTAB_EXPORT bool setOffset(unsigned offset);
00095       
00096       bool operator==(const Aggregate &a);
00097 
00098 
00099    protected:
00100 
00101       bool addMangledNameInt(std::string name, bool isPrimary);
00102       bool addPrettyNameInt(std::string name, bool isPrimary);
00103       bool addTypedNameInt(std::string name, bool isPrimary);
00104 
00105       SYMTAB_EXPORT bool removeSymbolInt(Symbol *sym);
00106       SYMTAB_EXPORT virtual bool changeSymbolOffset(Symbol *sym);
00107 
00108       // Offset comes from a symbol
00109       // Module we keep here so we can have the correct "primary"
00110       // (AKA 'not DEFAULT_MODULE') module
00111       Module *module_;
00112 
00113       std::vector<Symbol *> symbols_;
00114       Symbol *firstSymbol;  // cached for speed
00115       Offset offset_;       // cached for speed
00116 
00117       std::vector<std::string> mangledNames_;
00118       std::vector<std::string> prettyNames_;
00119       std::vector<std::string> typedNames_;
00120 
00121       void restore_type_by_id(SerializerBase *, Type *&, unsigned) THROW_SPEC (SerializerError);
00122       void restore_module_by_name(SerializerBase *, std::string &) THROW_SPEC (SerializerError);
00123       //void rebuild_symbol_vector(SerializerBase *, std::vector<Offset> *) THROW_SPEC (SerializerError);
00124       void rebuild_symbol_vector(SerializerBase *, std::vector<Address> &) THROW_SPEC (SerializerError);
00125       SYMTAB_EXPORT void serialize_aggregate(SerializerBase *, const char * = "Aggregate") THROW_SPEC (SerializerError);
00126 };
00127 
00128 }
00129 }
00130 
00131 #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