ROSE  0.9.10.47
FunctionInfo.h
1 #ifndef FUNCTION_INFO_H
2 #define FUNCTION_INFO_H
3 
4 #include <BinaryAstHash.h>
5 #include "Combinatorics.h"
6 
15 namespace LibraryIdentification
16 {
22  {
23  public:
37  FunctionInfo(const std::string& ifuncName, const std::string& ifuncHash, const std::string& ilibHash) :
38  funcName(ifuncName), funcHash(ifuncHash), libHash(ilibHash), sgAsmFunc(0) {};
39 
54  FunctionInfo(SgAsmFunction* function, const std::string& ilibHash) :
55  funcName(function->get_name()), libHash(ilibHash), sgAsmFunc(function)
56  {
57  initializeHash(function);
58  }
59 
73  FunctionInfo(SgAsmFunction* function, LibraryInfo& libInfo) :
74  funcName(function->get_name()), libHash(libInfo.libHash), sgAsmFunc(function)
75  {
76  initializeHash(function);
77  }
78 
88  FunctionInfo(const std::string& ifuncHash) :
89  funcName(""), funcHash(ifuncHash), libHash(""), sgAsmFunc(0) {};
90 
101  funcName(function->get_name()), libHash(""), sgAsmFunc(function)
102  {
103  initializeHash(function);
104  }
105 
106  friend bool operator<(const FunctionInfo& lhs, const FunctionInfo& rhs)
107  {
108  return lhs.funcHash < rhs.funcHash;
109  }
110 
111 
112  //@brief The name of the function
113  std::string funcName;
114 
115  //@brief A hash that should uniquely identify the function
116  std::string funcHash;
117 
118  //@brief A hash that should uniquely identify the library the
119  //function belongs to. It should already be in the database.
120  std::string libHash;
121 
122  //@brief A pointer to the binary version of this function IF
123  //IT'S AVAILIBLE. THIS IS LIKELY TO BE NULL
124  SgAsmFunction* sgAsmFunc;
125 
126 
127  private:
128  void initializeHash(SgNode* function)
129  {
130  //Should make the hash optional via factory method in Combinatorics.h
132  Rose::Combinatorics::Hasher& hasher = dynamic_cast<Rose::Combinatorics::Hasher&>(fnv);
133 
134  Rose::BinaryAnalysis::AstHash astHash(hasher);
135  astHash.traverse((SgNode*)function,preorder);
136  funcHash = fnv.toString();
137  }
138  };
139 
140 }
141 
142 
143 
144 #endif //FUNCTION_INFO
class FunctionInfo Combines all the information to uniquely identify a single function in one object...
Definition: FunctionInfo.h:21
Represents a synthesized function.
FunctionInfo(SgAsmFunction *function, const std::string &ilibHash)
FunctionInfo.
Definition: FunctionInfo.h:54
Fowler-Noll-Vo hashing using the Hasher interface.
FunctionInfo(SgAsmFunction *function)
FunctionInfo.
Definition: FunctionInfo.h:100
This class represents the base class for all IR nodes within Sage III.
Definition: Cxx_Grammar.h:8672
static std::string toString(const Digest &)
Convert a digest to a hexadecimal string.
FunctionInfo(SgAsmFunction *function, LibraryInfo &libInfo)
FunctionInfo.
Definition: FunctionInfo.h:73
A simple traversal that builds up a hash code for the AST.
Definition: BinaryAstHash.h:28
FunctionInfo(const std::string &ifuncName, const std::string &ifuncHash, const std::string &ilibHash)
FunctionInfo.
Definition: FunctionInfo.h:37
FunctionInfo(const std::string &ifuncHash)
FunctionInfo.
Definition: FunctionInfo.h:88