ROSE 0.11.145.247
Specimen.h
1#ifndef ROSE_BinaryAnalysis_Concolic_Specimen_H
2#define ROSE_BinaryAnalysis_Concolic_Specimen_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_CONCOLIC_TESTING
5#include <Rose/BinaryAnalysis/Concolic/BasicTypes.h>
6
7#include <boost/filesystem.hpp>
8
9#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
10#include <boost/serialization/access.hpp>
11#include <boost/serialization/nvp.hpp>
12#endif
13
14#include <Sawyer/SharedObject.h>
15#include <Sawyer/SharedPointer.h>
16#include <string>
17#include <vector>
18
19namespace Rose {
20namespace BinaryAnalysis {
21namespace Concolic {
22
27class Specimen: public Sawyer::SharedObject, public Sawyer::SharedFromThis<Specimen> {
28public:
31
33 typedef std::vector<uint8_t> BinaryData;
34
35private:
36 mutable SAWYER_THREAD_TRAITS::Mutex mutex_; // protects the following data members
37 std::string name_; // name of specimen (e.g., for debugging)
38 std::string timestamp_; // time of creation
39 BinaryData content_; // content of the binary executable file
40 mutable bool read_only_; // safe guards from writing content after it has been shared;
41 bool empty_; // indicates if this object is empty
42
43private:
44 friend class boost::serialization::access;
45
46 template<class S>
47 void serialize(S &s, const unsigned /*version*/) {
48 s & BOOST_SERIALIZATION_NVP(name_);
49 s & BOOST_SERIALIZATION_NVP(content_);
50 s & BOOST_SERIALIZATION_NVP(empty_);
51 }
52
53protected:
54 Specimen();
55
56public:
57 ~Specimen();
58
61 static Ptr instance(const boost::filesystem::path &executableName);
62 static Ptr instance();
71 void open(const boost::filesystem::path &executableName);
72
79 void close();
80
86 bool isEmpty() const;
87
96 std::string name() const; // value return is intentional for thread safety
97 void name(const std::string&);
105 std::string printableName(const DatabasePtr &db = DatabasePtr());
106
108 void toYaml(std::ostream&, const DatabasePtr&, std::string prefix);
109
120 std::string timestamp() const;
121 void timestamp(const std::string&);
130 const std::vector<uint8_t>& content() const;
131
132 // FIXME[Robb Matzke 2019-08-12]: content is read-only, created by constructor. Therefore this member shouldn't be defined,
133 // or at least should be private.
136 void content(std::vector<uint8_t> binary_data);
137};
138
139} // namespace
140} // namespace
141} // namespace
142
143#endif
144#endif
Creates SharedPointer from this.
Base class for reference counted objects.
Reference-counting intrusive smart pointer.
Sawyer::SharedPointer< Node > Ptr
Reference counting pointer.
void serialize(std::ostream &output, Graph &graph)
Serialize a graph into a stream of bytes.
The ROSE library.