AddrLookup.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 #ifndef __AddrLookup_H__
00032 #define __AddrLookup_H__
00033 
00034 #include "Annotatable.h"
00035 #include <map>
00036 
00037 namespace Dyninst {
00038 
00039 class AddressTranslate;
00040 class LoadedLib;
00041 
00042 namespace SymtabAPI {
00043 
00044 typedef struct {
00045    std::string name;
00046    Address codeAddr;
00047    Address dataAddr;
00048 } LoadedLibrary;
00049 
00050 class AddressLookup : public AnnotatableSparse
00051 {
00052  private:
00053    AddressTranslate *translator;
00054    AddressLookup(AddressTranslate *trans);
00055    static dyn_hash_map<std::string, std::vector<Symbol *> > syms;
00056    int getSymsVector(std::string str);
00057    std::vector<Symbol *> *getSymsVector(LoadedLib *lib);
00058 
00059    std::map<Symtab *, LoadedLib *> sym_to_ll;
00060    std::map<LoadedLib *, Symtab *> ll_to_sym;
00061 
00062    LoadedLib *getLoadedLib(Symtab *sym);
00063    Dyninst::Address symToAddress(LoadedLib *ll, Symbol *sym);
00064    Symtab *getSymtab(LoadedLib *);
00065  public:
00066    SYMTAB_EXPORT static AddressLookup *createAddressLookup(ProcessReader *reader = NULL);
00067    SYMTAB_EXPORT static AddressLookup *createAddressLookup(PID pid, ProcessReader *reader = NULL);
00068    SYMTAB_EXPORT static AddressLookup *createAddressLookup(const std::vector<LoadedLibrary> &name_addrs);
00069    
00070    SYMTAB_EXPORT bool getAddress(Symtab *tab, Symbol *sym, Address &addr);
00071    SYMTAB_EXPORT bool getAddress(Symtab *tab, Offset off, Address &addr);
00072 
00073    SYMTAB_EXPORT bool getSymbol(Address addr, Symbol* &sym, Symtab* &tab, bool close = false);
00074    SYMTAB_EXPORT bool getOffset(Address addr, Symtab* &tab, Offset &off);
00075    
00076    SYMTAB_EXPORT bool getAllSymtabs(std::vector<Symtab *> &tabs);
00077    SYMTAB_EXPORT bool getLoadAddress(Symtab* sym, Address &load_addr);
00078    SYMTAB_EXPORT bool getDataLoadAddress(Symtab* sym, Address &load_addr);
00079 
00080    SYMTAB_EXPORT bool getLoadAddresses(std::vector<LoadedLibrary> &name_addrs);
00081    SYMTAB_EXPORT bool getExecutable(LoadedLibrary &lib);
00082    SYMTAB_EXPORT bool getOffset(Address addr, LoadedLibrary &lib, Offset &off);
00083 
00084    SYMTAB_EXPORT bool refresh();
00085 
00086    SYMTAB_EXPORT Address getLibraryTrapAddrSysV();
00087    
00088    SYMTAB_EXPORT virtual ~AddressLookup();
00089 };
00090 
00091 }
00092 }
00093 
00094 #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