2 * See the dyninst/COPYRIGHT file for copyright information.
4 * We provide the Paradyn Tools (below described as "Paradyn")
5 * on an AS IS basis, and do not warrant its validity or performance.
6 * We reserve the right to update, modify, or discontinue this
7 * software at any time. We shall have no obligation to supply such
8 * updates or modifications or any other form of support to you.
10 * By your use of Paradyn, you understand and agree that we (or any
11 * other person or entity with proprietary rights in Paradyn) are
12 * under no obligation to provide either maintenance services,
13 * update services, notices of latent defects, or correction of
14 * defects for Paradyn.
16 * This library is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU Lesser General Public
18 * License as published by the Free Software Foundation; either
19 * version 2.1 of the License, or (at your option) any later version.
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Lesser General Public License for more details.
26 * You should have received a copy of the GNU Lesser General Public
27 * License along with this library; if not, write to the Free Software
28 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
37 #include "Annotatable.h"
38 #include "Serialization.h"
44 class LineInformation;
48 class Statement : public AnnotatableSparse, public Serializable
51 friend class std::vector<Statement>;
52 friend class LineInformation;
54 Statement(const char *file, unsigned int line, unsigned int col = 0,
55 Offset start_addr = (Offset) -1L, Offset end_addr = (Offset) -1L) :
56 file_(file ? std::string(file) : std::string()),
58 start_addr_(start_addr),
66 std::string file_; // Maybe this should be module?
76 Statement() : first(NULL), second(line_) {}
77 struct StatementLess {
78 bool operator () ( const Statement &lhs, const Statement &rhs ) const;
81 typedef StatementLess LineNoTupleLess;
83 bool operator==(const Statement &cmp) const;
86 SYMTAB_EXPORT Offset startAddr() { return start_addr_;}
87 SYMTAB_EXPORT Offset endAddr() {return end_addr_;}
88 SYMTAB_EXPORT std::string getFile() { return file_;}
89 SYMTAB_EXPORT unsigned int getLine() {return line_;}
90 SYMTAB_EXPORT unsigned int getColumn() {return column;}
92 SYMTAB_EXPORT Serializable *serialize_impl(SerializerBase *sb, const char *tag = "Statement") THROW_SPEC (SerializerError);
94 // Does dyninst really need these?
95 SYMTAB_EXPORT void setLine(unsigned int l) {line_ = l;}
96 SYMTAB_EXPORT void setColumn(unsigned int l) {column = l;}
97 SYMTAB_EXPORT void setFile(const char * l) {file_ = std::string(l); first = file_.c_str();}
98 SYMTAB_EXPORT void setStartAddr(Offset l) {start_addr_ = l;}
99 SYMTAB_EXPORT void setEndAddr(Offset l) {end_addr_ = l;}
102 typedef Statement LineNoTuple;
103 #define MODULE_ANNOTATABLE_CLASS AnnotatableSparse
105 class Module : public LookupInterface,
107 public MODULE_ANNOTATABLE_CLASS
113 SYMTAB_EXPORT Module();
114 SYMTAB_EXPORT Module(supportedLanguages lang, Offset adr, std::string fullNm,
116 SYMTAB_EXPORT Module(const Module &mod);
117 SYMTAB_EXPORT bool operator==(Module &mod);
119 SYMTAB_EXPORT Serializable * serialize_impl(SerializerBase *sb, const char *tag = "Module") THROW_SPEC (SerializerError);
121 SYMTAB_EXPORT const std::string &fileName() const;
122 SYMTAB_EXPORT const std::string &fullName() const;
123 SYMTAB_EXPORT bool setName(std::string newName);
125 SYMTAB_EXPORT supportedLanguages language() const;
126 SYMTAB_EXPORT void setLanguage(supportedLanguages lang);
128 SYMTAB_EXPORT Offset addr() const;
129 SYMTAB_EXPORT Symtab *exec() const;
131 SYMTAB_EXPORT bool isShared() const;
132 SYMTAB_EXPORT ~Module();
134 // Symbol output methods
135 SYMTAB_EXPORT virtual bool findSymbol(std::vector<Symbol *> &ret,
136 const std::string& name,
137 Symbol::SymbolType sType = Symbol::ST_UNKNOWN,
138 NameType nameType = anyName,
139 bool isRegex = false,
140 bool checkCase = false,
141 bool includeUndefined = false);
142 SYMTAB_EXPORT virtual bool getAllSymbolsByType(std::vector<Symbol *> &ret,
143 Symbol::SymbolType sType);
144 SYMTAB_EXPORT virtual bool getAllSymbols(std::vector<Symbol *> &ret);
147 // Function based methods
148 SYMTAB_EXPORT bool getAllFunctions(std::vector<Function *>&ret);
149 SYMTAB_EXPORT bool findFunctionByEntryOffset(Function *&ret, const Offset offset);
150 SYMTAB_EXPORT bool findFunctionsByName(std::vector<Function *> &ret, const std::string& name,
151 NameType nameType = anyName,
152 bool isRegex = false,
153 bool checkCase = true);
155 // Variable based methods
156 SYMTAB_EXPORT bool findVariableByOffset(Variable *&ret, const Offset offset);
157 SYMTAB_EXPORT bool findVariablesByName(std::vector<Variable *> &ret, const std::string& name,
158 NameType nameType = anyName,
159 bool isRegex = false,
160 bool checkCase = true);
161 SYMTAB_EXPORT bool getAllVariables(std::vector<Variable *> &ret);
164 // Type output methods
165 SYMTAB_EXPORT virtual bool findType(Type *&type, std::string name);
166 SYMTAB_EXPORT virtual bool findVariableType(Type *&type, std::string name);
168 SYMTAB_EXPORT std::vector<Type *> *getAllTypes();
169 SYMTAB_EXPORT std::vector<std::pair<std::string, Type *> > *getAllGlobalVars();
171 SYMTAB_EXPORT typeCollection *getModuleTypes();
173 /***** Local Variable Information *****/
174 SYMTAB_EXPORT bool findLocalVariable(std::vector<localVar *>&vars, std::string name);
176 /***** Line Number Information *****/
177 SYMTAB_EXPORT bool getAddressRanges(std::vector<std::pair<Offset, Offset> >&ranges,
178 std::string lineSource, unsigned int LineNo);
179 SYMTAB_EXPORT bool getSourceLines(std::vector<Statement *> &lines,
180 Offset addressInRange);
181 SYMTAB_EXPORT bool getSourceLines(std::vector<LineNoTuple> &lines,
182 Offset addressInRange);
183 SYMTAB_EXPORT bool getStatements(std::vector<Statement *> &statements);
184 SYMTAB_EXPORT LineInformation *getLineInformation();
186 SYMTAB_EXPORT bool hasLineInformation();
187 SYMTAB_EXPORT bool setDefaultNamespacePrefix(std::string str);
190 // Super secret private methods that aren't really private
191 SYMTAB_EXPORT typeCollection *getModuleTypesPrivate();
194 bool setLineInfo(Dyninst::SymtabAPI::LineInformation *lineInfo);
197 std::string fileName_; // short file
198 std::string fullName_; // full path to file
199 supportedLanguages language_;
200 Offset addr_; // starting address of module
208 }//namespace SymtabAPI