1#ifndef ROSE_BinaryAnalysis_LibraryIdentification_H
2#define ROSE_BinaryAnalysis_LibraryIdentification_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_LIBRARY_IDENTIFICATION
6#include <Rose/BinaryAnalysis/Partitioner2/BasicTypes.h>
8#include <Sawyer/CommandLine.h>
9#include <Sawyer/Database.h>
10#include <Sawyer/Message.h>
11#include <Sawyer/SharedObject.h>
12#include <Sawyer/SharedPointer.h>
20namespace BinaryAnalysis {
33class LibraryIdentification {
51 std::vector<std::regex> includeRes;
59 boost::filesystem::path includeFile;
72 std::vector<std::regex> excludeRes;
80 boost::filesystem::path excludeFile;
86 size_t minFunctionInsns = 0;
97 bool identifyFunctionsByHash =
false;
113 std::string version_;
114 std::string architecture_;
116 std::string cversion_;
119 Library(
const std::string &hash,
const std::string &name,
const std::string &version,
const std::string &architecture,
120 time_t ctime,
const std::string &cversion);
128 static Ptr instance(
const std::string &hash,
const std::string &name,
const std::string &version,
129 const std::string &architecture);
136 static Ptr instance(
const std::string &hash,
const std::string &name,
const std::string &version,
137 const std::string &architecture, time_t creationTime,
const std::string &creationVersion);
144 const std::string&
hash()
const;
150 const std::string& name()
const;
155 const std::string& version()
const;
160 const std::string& architecture()
const;
166 time_t creationTime()
const;
172 const std::string& creationVersion()
const;
188 rose_addr_t address_;
190 std::string demangledName_;
193 Library::Ptr library_;
195 std::string cversion_;
198 Function(rose_addr_t address,
const std::string &name,
const std::string &demangledName,
const std::string &hash,
199 size_t nInsns, time_t ctime,
const std::string &cversion,
const Library::Ptr &library);
207 static Ptr instance(rose_addr_t address,
const std::string &name,
const std::string &demangledName,
208 const std::string &hash,
size_t nInsns,
const Library::Ptr &library);
215 static Ptr instance(rose_addr_t address,
const std::string &name,
const std::string &demangledName,
216 const std::string &hash,
size_t nInsns, time_t creationTime,
const std::string &creationVersion,
217 const Library::Ptr &library);
223 rose_addr_t address()
const;
228 const std::string& name()
const;
237 const std::string&
hash()
const;
240 size_t nInsns()
const;
243 Library::Ptr library()
const;
246 time_t creationTime()
const;
249 const std::string& creationVersion()
const;
259 std::string databaseUrl_;
260 Sawyer::Database::Connection db_;
263 boost::filesystem::path cachedIncludeFile_;
265 boost::filesystem::path cachedExcludeFile_;
269 LibraryCache libraryCache_;
296 void connect(
const std::string &databaseUrl);
302 void createDatabase(
const std::string &databaseUrl);
315 Function::Ptr insertFunction(
const Library::Ptr&,
const Partitioner2::PartitionerConstPtr&,
const Partitioner2::FunctionPtr&);
316 bool insertFunction(
const Function::Ptr&);
325 size_t insertLibrary(
const Library::Ptr&,
const Partitioner2::PartitionerConstPtr&);
334 Library::Ptr library(
const std::string &hash);
339 std::vector<Library::Ptr> libraries();
348 std::vector<Function::Ptr> functions();
349 std::vector<Function::Ptr> functions(
const Library::Ptr&);
353 std::vector<Function::Ptr> search(
const Partitioner2::PartitionerConstPtr &partitioner,
const Partitioner2::FunctionPtr&);
367 std::string
hash(
const Partitioner2::PartitionerConstPtr&,
const Partitioner2::FunctionPtr&)
const;
370 static size_t nInsns(
const Partitioner2::PartitionerConstPtr&,
const Partitioner2::FunctionPtr&);
383 void upgradeDatabase();
386 void createLibrary(
const Library::Ptr&);
391 void createFunction(
const Function::Ptr&);
395 bool isIncluded(
const Function::Ptr&);
396 bool isIncluded(
const Partitioner2::PartitionerConstPtr&,
const Partitioner2::FunctionPtr&);
399 bool isExcluded(
const Function::Ptr&);
400 bool isExcluded(
const Partitioner2::PartitionerConstPtr&,
const Partitioner2::FunctionPtr&);
404 bool isConsidered(
const Function::Ptr&);
405 bool isConsidered(
const Partitioner2::PartitionerConstPtr&,
const Partitioner2::FunctionPtr&);
409 void cacheNamesFromFile(
const boost::filesystem::path &fileName, boost::filesystem::path &cachedFileName ,
413 std::vector<Function::Ptr> functions(Sawyer::Database::Statement);
A collection of related switch declarations.
Container associating values with keys.
Holds a value or nothing.
Base class for reference counted objects.
Reference-counting intrusive smart pointer.
void initDiagnostics()
Initialize diagnostics.
Sawyer::SharedPointer< Node > Ptr
Reference counting pointer.
Hash hash(const std::vector< Ptr > &)
Hash zero or more expressions.
Sawyer::CommandLine::SwitchGroup commandLineSwitches(Settings &settings)
Command-line switches for unparser settings.
ROSE_DLL_API Sawyer::Message::Facility mlog
Diagnostic facility for the ROSE library as a whole.
std::string demangledName(std::string)
Compute demangled version of mangled name.
Settings settings
Command-line settings for the rosebud tool.