00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef __MODULE__H__
00032 #define __MODULE__H__
00033
00034 #include "symutil.h"
00035 #include "Symbol.h"
00036
00037 #include "Annotatable.h"
00038 #include "Serialization.h"
00039
00040 namespace Dyninst{
00041 namespace SymtabAPI{
00042
00043 class typeCollection;
00044 class LineInformation;
00045 class localVar;
00046 class Symtab;
00047
00048 class Statement : public AnnotatableSparse, public Serializable
00049 {
00050 friend class Module;
00051 friend class std::vector<Statement>;
00052 friend class LineInformation;
00053
00054 Statement(const char *file, unsigned int line, unsigned int col = 0,
00055 Offset start_addr = (Offset) -1L, Offset end_addr = (Offset) -1L) :
00056 file_(file ? std::string(file) : std::string()),
00057 line_(line),
00058 start_addr_(start_addr),
00059 end_addr_(end_addr),
00060 first(file_.c_str()),
00061 second(line_),
00062 column(col)
00063 {
00064 }
00065
00066 std::string file_;
00067 unsigned int line_;
00068 Offset start_addr_;
00069 Offset end_addr_;
00070
00071 public:
00072 const char *first;
00073 unsigned int second;
00074 unsigned int column;
00075
00076 Statement() : first(NULL), second(line_) {}
00077 struct StatementLess {
00078 bool operator () ( const Statement &lhs, const Statement &rhs ) const;
00079 };
00080
00081 typedef StatementLess LineNoTupleLess;
00082
00083 bool operator==(const Statement &cmp) const;
00084 ~Statement() {}
00085
00086 SYMTAB_EXPORT Offset startAddr() { return start_addr_;}
00087 SYMTAB_EXPORT Offset endAddr() {return end_addr_;}
00088 SYMTAB_EXPORT std::string getFile() { return file_;}
00089 SYMTAB_EXPORT unsigned int getLine() {return line_;}
00090 SYMTAB_EXPORT unsigned int getColumn() {return column;}
00091
00092 SYMTAB_EXPORT Serializable *serialize_impl(SerializerBase *sb, const char *tag = "Statement") THROW_SPEC (SerializerError);
00093
00094
00095 SYMTAB_EXPORT void setLine(unsigned int l) {line_ = l;}
00096 SYMTAB_EXPORT void setColumn(unsigned int l) {column = l;}
00097 SYMTAB_EXPORT void setFile(const char * l) {file_ = std::string(l); first = file_.c_str();}
00098 SYMTAB_EXPORT void setStartAddr(Offset l) {start_addr_ = l;}
00099 SYMTAB_EXPORT void setEndAddr(Offset l) {end_addr_ = l;}
00100 };
00101
00102 typedef Statement LineNoTuple;
00103 #define MODULE_ANNOTATABLE_CLASS AnnotatableSparse
00104
00105 class Module : public LookupInterface,
00106 public Serializable,
00107 public MODULE_ANNOTATABLE_CLASS
00108 {
00109 friend class Symtab;
00110
00111 public:
00112
00113 SYMTAB_EXPORT Module();
00114 SYMTAB_EXPORT Module(supportedLanguages lang, Offset adr, std::string fullNm,
00115 Symtab *img);
00116 SYMTAB_EXPORT Module(const Module &mod);
00117 SYMTAB_EXPORT bool operator==(Module &mod);
00118
00119 SYMTAB_EXPORT Serializable * serialize_impl(SerializerBase *sb, const char *tag = "Module") THROW_SPEC (SerializerError);
00120
00121 SYMTAB_EXPORT const std::string &fileName() const;
00122 SYMTAB_EXPORT const std::string &fullName() const;
00123 SYMTAB_EXPORT bool setName(std::string newName);
00124
00125 SYMTAB_EXPORT supportedLanguages language() const;
00126 SYMTAB_EXPORT void setLanguage(supportedLanguages lang);
00127
00128 SYMTAB_EXPORT Offset addr() const;
00129 SYMTAB_EXPORT Symtab *exec() const;
00130
00131 SYMTAB_EXPORT bool isShared() const;
00132 SYMTAB_EXPORT ~Module();
00133
00134
00135 SYMTAB_EXPORT virtual bool findSymbol(std::vector<Symbol *> &ret,
00136 const std::string& name,
00137 Symbol::SymbolType sType = Symbol::ST_UNKNOWN,
00138 NameType nameType = anyName,
00139 bool isRegex = false,
00140 bool checkCase = false,
00141 bool includeUndefined = false);
00142 SYMTAB_EXPORT virtual bool getAllSymbolsByType(std::vector<Symbol *> &ret,
00143 Symbol::SymbolType sType);
00144 SYMTAB_EXPORT virtual bool getAllSymbols(std::vector<Symbol *> &ret);
00145
00146
00147
00148 SYMTAB_EXPORT bool getAllFunctions(std::vector<Function *>&ret);
00149 SYMTAB_EXPORT bool findFunctionByEntryOffset(Function *&ret, const Offset offset);
00150 SYMTAB_EXPORT bool findFunctionsByName(std::vector<Function *> &ret, const std::string& name,
00151 NameType nameType = anyName,
00152 bool isRegex = false,
00153 bool checkCase = true);
00154
00155
00156 SYMTAB_EXPORT bool findVariableByOffset(Variable *&ret, const Offset offset);
00157 SYMTAB_EXPORT bool findVariablesByName(std::vector<Variable *> &ret, const std::string& name,
00158 NameType nameType = anyName,
00159 bool isRegex = false,
00160 bool checkCase = true);
00161 SYMTAB_EXPORT bool getAllVariables(std::vector<Variable *> &ret);
00162
00163
00164
00165 SYMTAB_EXPORT virtual bool findType(Type *&type, std::string name);
00166 SYMTAB_EXPORT virtual bool findVariableType(Type *&type, std::string name);
00167
00168 SYMTAB_EXPORT std::vector<Type *> *getAllTypes();
00169 SYMTAB_EXPORT std::vector<std::pair<std::string, Type *> > *getAllGlobalVars();
00170
00171 SYMTAB_EXPORT typeCollection *getModuleTypes();
00172
00173
00174 SYMTAB_EXPORT bool findLocalVariable(std::vector<localVar *>&vars, std::string name);
00175
00176
00177 SYMTAB_EXPORT bool getAddressRanges(std::vector<std::pair<Offset, Offset> >&ranges,
00178 std::string lineSource, unsigned int LineNo);
00179 SYMTAB_EXPORT bool getSourceLines(std::vector<Statement *> &lines,
00180 Offset addressInRange);
00181 SYMTAB_EXPORT bool getSourceLines(std::vector<LineNoTuple> &lines,
00182 Offset addressInRange);
00183 SYMTAB_EXPORT bool getStatements(std::vector<Statement *> &statements);
00184 SYMTAB_EXPORT LineInformation *getLineInformation();
00185
00186 SYMTAB_EXPORT bool hasLineInformation();
00187 SYMTAB_EXPORT bool setDefaultNamespacePrefix(std::string str);
00188
00189
00190
00191 SYMTAB_EXPORT typeCollection *getModuleTypesPrivate();
00192
00193 private:
00194 bool setLineInfo(Dyninst::SymtabAPI::LineInformation *lineInfo);
00195
00196
00197 std::string fileName_;
00198 std::string fullName_;
00199 supportedLanguages language_;
00200 Offset addr_;
00201 Symtab *exec_;
00202 };
00203
00204
00205
00206
00207
00208 }
00209
00210 }
00211 #endif