1#ifndef ROSE_BinaryAnalysis_Concolic_Database_H
2#define ROSE_BinaryAnalysis_Concolic_Database_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_CONCOLIC_TESTING
5#include <Rose/BinaryAnalysis/Concolic/BasicTypes.h>
7#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/BasicTypes.h>
8#include <Rose/Constants.h>
9#include <rose_strtoull.h>
11#include <Sawyer/BiMap.h>
12#include <Sawyer/Database.h>
13#include <Sawyer/Optional.h>
15#include <boost/numeric/conversion/cast.hpp>
21namespace BinaryAnalysis {
42 Sawyer::Database::Connection connection_;
50 TestSuiteId testSuiteId_;
64 static Ptr instance(
const std::string &url);
67 Sawyer::Database::Connection connection() {
81 static Ptr create(
const std::string &url);
82 static Ptr create(
const std::string &url,
const std::string &testSuiteName);
93 std::vector<TestSuiteId> testSuites();
102 TestSuitePtr testSuite();
103 TestSuiteId testSuite(
const TestSuitePtr&);
114 std::vector<SpecimenId> specimens();
117 std::vector<SpecimenId> specimens(TestSuiteId);
120 void eraseSpecimens(TestSuiteId);
130 std::vector<TestCaseId> testCases();
133 std::vector<TestCaseId> testCases(SpecimenId);
136 void eraseTestCases(SpecimenId);
146 std::vector<ExecutionEventId> executionEvents();
151 std::vector<ExecutionEventId> executionEvents(TestCaseId);
154 size_t nExecutionEvents(TestCaseId);
160 std::vector<ExecutionEventId> executionEvents(TestCaseId, uint64_t primaryKey);
165 std::vector<ExecutionEventId> executionEventsSince(TestCaseId, ExecutionEventId startingAt);
170 std::vector<uint64_t> executionEventKeyFrames(TestCaseId);
173 void eraseExecutionEvents(TestCaseId);
185 TestSuitePtr object(TestSuiteId, Update update = Update::YES);
186 TestCasePtr object(TestCaseId, Update update = Update::YES);
187 SpecimenPtr object(SpecimenId, Update update = Update::YES);
188 ExecutionEventPtr object(ExecutionEventId, Update update = Update::YES);
199 TestSuiteId
id(
const TestSuitePtr&, Update update = Update::YES);
200 TestCaseId
id(
const TestCasePtr&, Update update = Update::YES);
201 SpecimenId
id(
const SpecimenPtr&, Update update = Update::YES);
202 ExecutionEventId
id(
const ExecutionEventPtr&, Update update = Update::YES);
208 TestSuiteId
erase(TestSuiteId);
209 TestCaseId
erase(TestCaseId);
210 SpecimenId
erase(SpecimenId);
211 ExecutionEventId
erase(ExecutionEventId);
218 template<
class ObjectPo
inter>
219 typename ObjectTraits<typename ObjectPointer::Pointee>::Id
220 save(
const ObjectPointer &obj) {
227 template<
class ObjectPo
inter>
228 void save(
const std::vector<ObjectPointer> &objects) {
229 for (
auto object: objects)
237 std::vector<typename Id::Pointer>
238 objects(
const std::vector<Id> &ids, Update update = Update::YES) {
239 std::vector<typename Id::Pointer> retval;
241 retval.push_back(object(
id, update));
248 template<
class ObjectPo
inter>
249 std::vector<typename ObjectTraits<ObjectPointer>::Id>
250 ids(
const std::vector<ObjectPointer> &objects, Update update = Update::YES) {
251 std::vector<typename ObjectTraits<ObjectPointer>::Id> retval;
252 for (
auto object: objects)
253 retval.push_back(
id(object, update));
263 TestSuitePtr findTestSuite(
const std::string &nameOrId);
269 std::vector<SpecimenId> findSpecimensByName(
const std::string &name);
281 bool rbaExists(SpecimenId);
291 void saveRbaFile(
const boost::filesystem::path&, SpecimenId);
301 void extractRbaFile(
const boost::filesystem::path&, SpecimenId);
308 void eraseRba(SpecimenId);
317 bool symbolicStateExists(TestCaseId);
323 void saveSymbolicState(TestCaseId,
const InstructionSemantics::BaseSemantics::StatePtr&);
328 InstructionSemantics::BaseSemantics::StatePtr extractSymbolicState(TestCaseId);
333 void eraseSymbolicState(TestCaseId);
343 bool concreteResultExists(TestCaseId);
352 void saveConcreteResult(
const TestCasePtr&,
const ConcreteResultPtr&);
358 ConcreteResultPtr readConcreteResult(TestCaseId);
364 std::vector<TestCaseId> needConcreteTesting(
size_t n = UNLIMITED);
378 void assocTestCaseWithTestSuite(TestCaseId, TestSuiteId);
384 std::vector<TestCaseId> needConcolicTesting(
size_t n = UNLIMITED);
395 void insertConcreteResults(
const TestCasePtr &testCase,
const ConcreteResult& details);
405 static std::string timestamp();
One-to-one mapping between source and target values.
Holds a value or nothing.
Creates SharedPointer from this.
Base class for reference counted objects.
Reference-counting intrusive smart pointer.
Sawyer::SharedPointer< Node > Ptr
Reference counting pointer.
void erase(GlobalVariables &, const AddressInterval &toErase)
Erase some global variables.
Id id(const std::string &name)
Returns the ID for an attribute name.