addrtranslate-sysv.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(addrtranslate_sysv_h_)
00032 #define addrtranslate_sysv_h_
00033 
00034 #include "common/h/addrtranslate.h"
00035 
00036 namespace Dyninst {
00037 
00038 class FCNode
00039 {
00040    friend class FileCache;
00041 protected:
00042    string filename;
00043    dev_t device;
00044    ino_t inode;
00045 
00046    bool parsed_file;
00047    bool parsed_file_fast;
00048    bool parse_error;
00049    bool is_interpreter;
00050 
00051    string interpreter_name;
00052    vector<SymSegment> segments;
00053    unsigned addr_size;
00054    Offset r_debug_offset;
00055    Offset r_trap_offset;
00056    SymReader *symreader;
00057    SymbolReaderFactory *factory;
00058 
00059    void parsefile();
00060 
00061 public:
00062    FCNode(string f, dev_t d, ino_t i, SymbolReaderFactory *factory_);
00063 
00064    string getFilename();
00065 
00066    string getInterpreter();
00067    void markInterpreter();
00068    void getSegments(vector<SymSegment> &segs);
00069    unsigned getAddrSize();
00070    Offset get_r_debug();
00071    Offset get_r_trap();
00072 };
00073 
00074 class FileCache
00075 {
00076 private:
00077    vector<FCNode *> nodes;
00078    
00079 public:
00080    FileCache();
00081    
00082    FCNode *getNode(const string &filename, Dyninst::SymbolReaderFactory *factory_);
00083 };
00084 
00085 extern FileCache files;
00086 
00087 struct LibCmp
00088 {
00089    bool operator()(const std::pair<Address, std::string> &a,
00090                    const std::pair<Address, std::string> &b) const
00091    {
00092       if (a.first != b.first)
00093          return a.first < b.first;
00094       return a.second < b.second;
00095    }
00096 };
00097 
00098 class AddressTranslateSysV : public AddressTranslate
00099 {
00100 public:
00101    bool init();
00102    virtual bool refresh();
00103    virtual Address getLibraryTrapAddrSysV();
00104 
00105    AddressTranslateSysV(int pid, ProcessReader *reader_, 
00106                         SymbolReaderFactory *reader_fact,
00107                         std::string exe_name,
00108                         Address interp_base);
00109    AddressTranslateSysV();
00110    virtual ~AddressTranslateSysV() {};
00111 
00112 private:
00113    ProcessReader *reader;
00114    Address interpreter_base;
00115    Address program_base;
00116    Address page_size;
00117    bool set_interp_base;
00118    int address_size;
00119    FCNode *interpreter;
00120 
00121    unsigned previous_r_state;
00122    unsigned current_r_state;
00123 
00124    Address r_debug_addr;
00125    Address trap_addr;
00126    Address getTrapAddrFromRdebug();
00127 
00128    LoadedLib *getLoadedLibByNameAddr(Address addr, std::string name);
00129    typedef std::map<std::pair<Address, std::string>, LoadedLib *, LibCmp> sorted_libs_t;
00130    sorted_libs_t sorted_libs;
00131 
00132    /* platform-specific functions */
00133    std::string getExecName();
00134    ProcessReader *createDefaultDebugger(int pid);
00135 
00136    /* 
00137     * These functions need to set r_debug_addr, trap_addr and address_size
00138     */
00139    bool parseDTDebug();
00140    bool parseInterpreter();
00141 
00142    bool setInterpreter();
00143    bool setAddressSize();
00144    bool setInterpreterBase();
00145    LoadedLib *getAOut();
00146 
00147    // PPC64-Linux uses an AIX-style function pointer, so the trap addr
00148    // we're provided is a pointer to the actual address.
00149 
00150    bool plat_getTrapAddr();
00151    Address real_trap_addr;
00152 
00153    Address adjustForAddrSpaceWrap(Address addr, std::string name);
00154 
00155 };
00156 
00157 }
00158 
00159 #endif
00160 
00161 
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 12 Jul 2013 for SymtabAPI by  doxygen 1.6.1