SymtabReader.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 SYMTAB_READER_H_
00032 #define SYMTAB_READER_H_
00033 
00034 #include "SymReader.h"
00035 #include <string>
00036 #include <vector>
00037 //Some components (StackwalkerAPI, ProcControlAPI) use a SymReader (defined in dyn_util/h)
00038 // to read symbols rather than a straight dependency on SymtabAPI.  A component can
00039 // either define its own SymReader (as ProcControlAPI does) or it can use SymtabAPI as
00040 // its symbol reader.  These SymtabReader and SymtabReaderFactory implement the SymReader
00041 // interface with a SymtabAPI implementation.
00042 
00043 namespace Dyninst {
00044 namespace SymtabAPI {
00045 
00046 class Symtab;
00047 class Region;
00048 class FastParser;
00049 
00050 class SYMTAB_EXPORT SymtabReaderFactory : public SymbolReaderFactory
00051 {
00052   private:
00053    std::map<std::string, SymReader *> open_syms;
00054   public:
00055    SymtabReaderFactory();
00056    virtual ~SymtabReaderFactory();
00057    virtual SymReader *openSymbolReader(std::string pathname);
00058    virtual SymReader *openSymbolReader(const char *buffer, unsigned long size);
00059    virtual bool closeSymbolReader(SymReader *sr);
00060 };
00061 
00062 class SYMTAB_EXPORT SymtabReader : public SymReader {
00063    friend class SymtabReaderFactory;
00064   protected:
00065    Symtab *symtab;
00066    int ref_count;
00067    std::vector<SymSegment> segments;
00068    bool ownsSymtab;
00069 
00070   public:
00071    SymtabReader(std::string file_);
00072    SymtabReader(const char *buffer, unsigned long size);
00073    SymtabReader(Symtab *s);
00074    virtual ~SymtabReader();
00075 
00076    virtual Symbol_t getSymbolByName(std::string symname);
00077    virtual unsigned long getSymbolSize(const Symbol_t &sym);
00078    virtual Symbol_t getContainingSymbol(Dyninst::Offset offset);
00079    virtual std::string getInterpreterName();
00080    virtual unsigned getAddressWidth();
00081    
00082    virtual unsigned numSegments();
00083    virtual bool getSegment(unsigned num, SymSegment &seg); 
00084 
00085    virtual Dyninst::Offset getSymbolOffset(const Symbol_t &sym);
00086    virtual Dyninst::Offset getSymbolTOC(const Symbol_t &sym);
00087    virtual std::string getSymbolName(const Symbol_t &sym);
00088    virtual std::string getDemangledName(const Symbol_t &sym);
00089    virtual bool isValidSymbol(const Symbol_t &sym);
00090 
00091    virtual Section_t getSectionByName(std::string name);
00092    virtual Section_t getSectionByAddress(Dyninst::Address addr);
00093    virtual Dyninst::Address getSectionAddress(Section_t sec);
00094    virtual std::string getSectionName(Section_t sec);
00095    virtual bool isValidSection(Section_t sec);
00096 
00097    virtual Dyninst::Offset imageOffset();
00098    virtual Dyninst::Offset dataOffset();  
00099 
00100    virtual void *getElfHandle();
00101   private:
00102    void buildSegments();
00103 };
00104 
00105 extern "C" {
00106    SYMTAB_EXPORT SymbolReaderFactory *getSymtabReaderFactory();
00107 }
00108 
00109 }
00110 }
00111 
00112 #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