ROSE 0.11.145.192
DataBlock.h
1#ifndef ROSE_BinaryAnalysis_Partitioner2_DataBlock_H
2#define ROSE_BinaryAnalysis_Partitioner2_DataBlock_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5#include <Rose/BinaryAnalysis/Partitioner2/BasicTypes.h>
6
7#include <Rose/BinaryAnalysis/BasicTypes.h>
8#include <Rose/SourceLocation.h>
9#include <SageBuilderAsm.h>
10
11#include <Sawyer/Attribute.h>
12#include <Sawyer/SharedPointer.h>
13
14#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
15#include <boost/serialization/access.hpp>
16#endif
17
18#include <string>
19
20namespace Rose {
21namespace BinaryAnalysis {
22namespace Partitioner2 {
23
36public:
39
40private:
41 bool isFrozen_; // true if object is read-only because it's in the CFG
42 rose_addr_t startVa_; // starting address
43 SgAsmType *type_; // type of data stored in this block
44 std::string comment_; // arbitrary comment, shown by printableName.
45 std::vector<BasicBlockPtr> attachedBasicBlockOwners_; // attached basic blocks that own this data block, sorted and unique
46 std::vector<FunctionPtr> attachedFunctionOwners_; // attached functions that own this data block, sorted and unique
47 SourceLocation sourceLocation_; // optional location of data in source code
48
49
50#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
51private:
52 friend class boost::serialization::access;
53 template<class S> void serialize(S&, unsigned version);
54#endif
55
56protected:
57 // needed for serialization
58 DataBlock();
59 DataBlock(rose_addr_t startVa, SgAsmType *type);
60
61public:
62 ~DataBlock();
63
64public:
66 static Ptr instance(rose_addr_t startVa, SgAsmType*);
67
73 static Ptr instanceBytes(rose_addr_t startVa, size_t nBytes);
74
78 bool isFrozen() const { return isFrozen_; }
79
81 rose_addr_t address() const { return startVa_; }
82
84 size_t size() const;
85
91 SgAsmType* type() const { return type_; }
92 void type(SgAsmType *t);
98 const std::string& comment() const;
99 void comment(const std::string& s);
112 size_t nAttachedOwners() const;
113
117 const std::vector<FunctionPtr>& attachedFunctionOwners() const;
118
122 const std::vector<BasicBlockPtr>& attachedBasicBlockOwners() const;
125
127 std::string printableName() const;
128
135 std::vector<uint8_t> read(const MemoryMapPtr&) const;
136
137private:
138 friend class Partitioner;
139 void freeze();
140 void thaw();
141
142 // Insert the specified owner into this data block.
143 void insertOwner(const BasicBlockPtr&);
144 void insertOwner(const FunctionPtr&);
145
146 // Erase the specified owner of this data block.
147 void eraseOwner(const BasicBlockPtr&);
148 void eraseOwner(const FunctionPtr&);
149};
150
151
152} // namespace
153} // namespace
154} // namespace
155
156// Class versions must be at global scope
158
159#endif
160#endif
void type(SgAsmType *t)
Property: Type of data stored in this block.
std::vector< uint8_t > read(const MemoryMapPtr &) const
Read static data from a memory map.
AddressInterval extent() const
Addresses represented.
static Ptr instanceBytes(rose_addr_t startVa, size_t nBytes)
Static allocating constructor.
Sawyer::SharedPointer< DataBlock > Ptr
Shared pointer to a data block.
Definition DataBlock.h:38
size_t nAttachedOwners() const
Number of attached basic block and function owners.
SgAsmType * type() const
Property: Type of data stored in this block.
Definition DataBlock.h:91
const std::vector< BasicBlockPtr > & attachedBasicBlockOwners() const
Basic blocks that are attached to the partitioner and own this data block.
const SourceLocation & sourceLocation() const
Property: Optional location of data in source code.
const std::string & comment() const
Property: Comment.
const std::vector< FunctionPtr > & attachedFunctionOwners() const
Functions that are attached to the partitioner and own this data block.
size_t size() const
Returns the size in bytes.
static Ptr instance(rose_addr_t startVa, SgAsmType *)
Static allocating constructor.
void sourceLocation(const SourceLocation &)
Property: Optional location of data in source code.
std::string printableName() const
A printable name for this data block.
rose_addr_t address() const
Returns the starting address.
Definition DataBlock.h:81
void comment(const std::string &s)
Property: Comment.
bool isFrozen() const
Determine if data block is read-only.
Definition DataBlock.h:78
Partitions instructions into basic blocks and functions.
Information about a source location.
API and storage for attributes.
Definition Attribute.h:215
Base class for reference counted objects.
Reference-counting intrusive smart pointer.
Base class for binary types.
The ROSE library.