ROSE  0.9.10.103
FunctionInfo.h
1 #ifndef FUNCTION_INFO_H
2 #define FUNCTION_INFO_H
3 
4 #include <BinaryAstHash.h>
5 #include "Combinatorics.h"
6 #include <Partitioner2/Partitioner.h>
7 #include <Partitioner2/Function.h>
16 namespace LibraryIdentification
17 {
23  {
24  public:
38  FunctionInfo(const std::string& ifuncName, const std::string& ifuncHash, const std::string& ilibHash) :
39  funcName(ifuncName), funcHash(ifuncHash), libHash(ilibHash), binaryFunction() {};
40 
58  funcName(function->name()), libHash(ilibHash), binaryFunction(function)
59  {
60  initializeHash(partitioner, function);
61  }
62 
79  funcName(function->name()), libHash(libInfo.libHash), binaryFunction(function)
80  {
81  initializeHash(partitioner, function);
82  }
83 
93  FunctionInfo(const std::string& ifuncHash) :
94  funcName(""), funcHash(ifuncHash), libHash(""), binaryFunction() {};
95 
106  funcName(function->name()), libHash(""), binaryFunction(function)
107  {
108  initializeHash(partitioner, function);
109  }
110 
111  friend bool operator<(const FunctionInfo& lhs, const FunctionInfo& rhs)
112  {
113  return lhs.funcHash < rhs.funcHash;
114  }
115 
116 
117  //@brief The name of the function
118  std::string funcName;
119 
120  //@brief A hash that should uniquely identify the function
121  std::string funcHash;
122 
123  //@brief A hash that should uniquely identify the library the
124  //function belongs to. It should already be in the database.
125  std::string libHash;
126 
127  //@brief A pointer to the binary version of this function IF
128  //IT'S AVAILIBLE. THIS IS LIKELY TO BE NULL
130 
131 
132  private:
134  { //Ordered set, so it should always be the same order...
136  Rose::Combinatorics::Hasher& hasher = dynamic_cast<Rose::Combinatorics::Hasher&>(fnv);
137  Rose::BinaryAnalysis::AstHash astHash(hasher);
138 
139  const std::set<rose_addr_t>& basicBlocks = function->basicBlockAddresses();
140 
141  for(std::set<rose_addr_t>::const_iterator bbIt = basicBlocks.begin(); bbIt != basicBlocks.end(); ++bbIt)
142  {
144  ROSE_ASSERT(bb != NULL);
145  astHash.appendBasicBlock(bb);
146 
147  }
148 
149  funcHash = fnv.toString();
150  }
151 
152  };
153 
154 }
155 
156 
157 
158 #endif //FUNCTION_INFO
class FunctionInfo Combines all the information to uniquely identify a single function in one object...
Definition: FunctionInfo.h:22
BasicBlock::Ptr basicBlockExists(rose_addr_t startVa) const
Determines whether a discovered basic block exists in the CFG/AUM.
FunctionInfo(const Rose::BinaryAnalysis::Partitioner2::Partitioner &partitioner, Rose::BinaryAnalysis::Partitioner2::Function::Ptr function)
FunctionInfo.
Definition: FunctionInfo.h:105
Fowler-Noll-Vo hashing using the Hasher interface.
static std::string toString(const Digest &)
Convert a digest to a hexadecimal string.
FunctionInfo(const Rose::BinaryAnalysis::Partitioner2::Partitioner &partitioner, Rose::BinaryAnalysis::Partitioner2::Function::Ptr function, const std::string &ilibHash)
FunctionInfo.
Definition: FunctionInfo.h:57
A simple traversal that builds up a hash code for the AST.
Definition: BinaryAstHash.h:29
FunctionInfo(const Rose::BinaryAnalysis::Partitioner2::Partitioner &partitioner, Rose::BinaryAnalysis::Partitioner2::Function::Ptr function, LibraryInfo &libInfo)
FunctionInfo.
Definition: FunctionInfo.h:78
FunctionInfo(const std::string &ifuncName, const std::string &ifuncHash, const std::string &ilibHash)
FunctionInfo.
Definition: FunctionInfo.h:38
Partitions instructions into basic blocks and functions.
Definition: Partitioner.h:293
FunctionInfo(const std::string &ifuncHash)
FunctionInfo.
Definition: FunctionInfo.h:93