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 #if !defined SYM_READER_H_ 00031 #define SYM_READER_H_ 00032 00033 #include "dyntypes.h" 00034 #include <string> 00035 00036 namespace Dyninst 00037 { 00038 00039 class SymbolReaderFactory; 00040 00041 /** 00042 * Symbol_t is an anonymous struct that any SymReader can use for a symbol 00043 * handle. Some symbol readers may not want to store the objects behind a 00044 * 'void*' on the heap, so we're making Symbol_t big enough that it could 00045 * act as a full symbol handle. Or a SymReader could just choose fill in one 00046 * of the void pointers as a handle to a heap object, if it's comfortable 00047 * doing so. 00048 **/ 00049 struct Symbol_t { 00050 void *v1; 00051 void *v2; 00052 int i1; 00053 int i2; 00054 }; 00055 00056 struct Section_t { 00057 void *v1; 00058 void *v2; 00059 int i1; 00060 int i2; 00061 }; 00062 00063 struct SymSegment { 00064 Dyninst::Offset file_offset; 00065 Dyninst::Address mem_addr; 00066 size_t file_size; 00067 size_t mem_size; 00068 int type; 00069 int perms; 00070 }; 00071 00072 /** 00073 * This may seem like a clunky interface in places, but it was designed such 00074 * that the underlying implementation could be made re-enterant safe (so it 00075 * could be called from a signal handler). 00076 **/ 00077 class COMMON_EXPORT SymReader 00078 { 00079 protected: 00080 SymReader() {} 00081 virtual ~SymReader() {} 00082 public: 00083 virtual Symbol_t getSymbolByName(std::string symname) = 0; 00084 virtual Symbol_t getContainingSymbol(Dyninst::Offset offset) = 0; 00085 virtual std::string getInterpreterName() = 0; 00086 virtual unsigned getAddressWidth() = 0; 00087 00088 virtual unsigned numSegments() = 0; 00089 virtual bool getSegment(unsigned num, SymSegment ®) = 0; 00090 00091 virtual Dyninst::Offset getSymbolOffset(const Symbol_t &sym) = 0; 00092 virtual Dyninst::Offset getSymbolTOC(const Symbol_t &sym) = 0; 00093 virtual std::string getSymbolName(const Symbol_t &sym) = 0; 00094 virtual std::string getDemangledName(const Symbol_t &sym) = 0; 00095 virtual unsigned long getSymbolSize(const Symbol_t &sym) = 0; 00096 virtual bool isValidSymbol(const Symbol_t &sym) = 0; 00097 00098 virtual Section_t getSectionByName(std::string name) = 0; 00099 virtual Section_t getSectionByAddress(Dyninst::Address addr) = 0; 00100 virtual Dyninst::Address getSectionAddress(Section_t sec) = 0; 00101 virtual std::string getSectionName(Section_t sec) = 0; 00102 virtual bool isValidSection(Section_t sec) = 0; 00103 00104 virtual Dyninst::Offset imageOffset() = 0; 00105 virtual Dyninst::Offset dataOffset() = 0; 00106 00107 virtual void *getElfHandle() { return NULL; } 00108 virtual int getFD() 00109 { 00110 return 0; 00111 } 00112 00113 }; 00114 00115 class COMMON_EXPORT SymbolReaderFactory 00116 { 00117 public: 00118 SymbolReaderFactory() {} 00119 virtual ~SymbolReaderFactory() {} 00120 virtual SymReader *openSymbolReader(std::string pathname) = 0; 00121 virtual SymReader *openSymbolReader(const char *buffer, unsigned long size) = 0; 00122 virtual bool closeSymbolReader(SymReader *sr) = 0; 00123 }; 00124 00125 } 00126 00127 extern "C" { 00128 Dyninst::SymbolReaderFactory *getSymReaderFactory(); 00129 } 00130 00131 #endif
1.6.1