ROSE 0.11.145.276
MemoryTable.h
1#ifndef ROSE_BinaryAnalysis_Partitioner2_MemoryTable_H
2#define ROSE_BinaryAnalysis_Partitioner2_MemoryTable_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5#include <Rose/BinaryAnalysis/Partitioner2/BasicTypes.h>
6
7#include <Rose/BinaryAnalysis/MemoryMap.h>
8#include <Rose/Constants.h>
9
10namespace Rose {
11namespace BinaryAnalysis {
12namespace Partitioner2 {
13
19public:
30 class Entries {
31 public:
33 using Ptr = std::shared_ptr<Entries>;
34
35 virtual ~Entries();
36 Entries();
37
39 bool empty() const;
40
42 virtual size_t size() const = 0;
43
48 virtual bool maybeAppend(const MemoryTable*, Address entryAddr, const std::vector<uint8_t> &bytes) = 0;
49
54 virtual bool maybePrepend(const MemoryTable*, Address entryAddr, const std::vector<uint8_t> &bytes) = 0;
55 };
56
58 class Storage {
59 public:
61 using Ptr = std::shared_ptr<Storage>;
62
63 virtual ~Storage() {};
64
68 virtual std::vector<uint8_t> read(Address, size_t nBytes) = 0;
69 };
70
71private:
72 AddressInterval tableLimits_; // limits for where the table could exist
73 size_t bytesPerEntry_ = 4; // number of bytes in each table entry
74 size_t maxSkippable_ = 0; // max invalid entries before reaching start of table
75 size_t maxPreEntries_ = UNLIMITED; // max number of entries prior to initial start of table
76
77 // After parsing
78 Entries::Ptr entries_; // entries parsed for the table
79 AddressInterval tableLocation_; // where the table actually exists
80 size_t nPreEntries_ = 0; // entries before the original table start address
81
82public:
83 virtual ~MemoryTable();
84protected:
86public:
92
93public:
99 size_t maxInitialSkip() const;
100 void maxInitialSkip(size_t);
106 size_t maxPreEntries() const;
107 void maxPreEntries(size_t);
122 size_t bytesPerEntry() const;
123
126
127public:
135 Address probableTableAddr);
136 AddressInterval scan(const Storage::Ptr&, Address probableTableAddr);
143
145 bool empty() const;
146
148 size_t nEntries() const;
149
154 size_t nPreEntries() const;
155};
156
157} // namespace
158} // namespace
159} // namespace
160
161#endif
162#endif
virtual bool maybePrepend(const MemoryTable *, Address entryAddr, const std::vector< uint8_t > &bytes)=0
Parse a table entry and prepend to this list if the entry is valid.
virtual bool maybeAppend(const MemoryTable *, Address entryAddr, const std::vector< uint8_t > &bytes)=0
Parse a table entry and append to this list if the entry is valid.
virtual size_t size() const =0
Number of entries stored.
std::shared_ptr< Entries > Ptr
Shared-ownership pointer.
Definition MemoryTable.h:33
bool empty() const
True if there are no entries.
Represents the storage for the table.
Definition MemoryTable.h:58
std::shared_ptr< Storage > Ptr
Shared-ownership pointer.
Definition MemoryTable.h:61
virtual std::vector< uint8_t > read(Address, size_t nBytes)=0
Read some bytes of storage.
Utilities for working with tables.
Definition MemoryTable.h:18
bool empty() const
Result: True if the table has no valid entries.
static Ptr instance(const AddressInterval &tableLimits, size_t bytesPerEntry, const Entries::Ptr &entries)
Allocating constructor.
size_t nEntries() const
Result: Total number of valid entries scanned into the table.
void maxPreEntries(size_t)
Property: Max number of entries to prepend before the original start of the table.
AddressInterval scan(const MemoryMap::Constraints &, Address probableTableAddr)
Scan the table and return its location.
void tableLimits(const AddressInterval &)
Property: Limits for table location.
size_t bytesPerEntry() const
Property: Bytes per entry.
AddressInterval tableLimits() const
Property: Limits for table location.
size_t maxPreEntries() const
Property: Max number of entries to prepend before the original start of the table.
Entries::Ptr entries() const
Property: Table entries.
MemoryTableConstPtr ConstPtr
Shared ownership pointer.
Definition MemoryTable.h:24
AddressInterval location() const
Result: Table location in memory.
AddressInterval scan(const PartitionerConstPtr &, const InstructionSemantics::BaseSemantics::RiscOperatorsPtr &, Address probableTableAddr)
Scan the table and return its location.
AddressInterval scan(const Storage::Ptr &, Address probableTableAddr)
Scan the table and return its location.
size_t nPreEntries() const
Result: Number of entries detected before the start of table.
size_t maxInitialSkip() const
Property: Max initial invalid entries.
void maxInitialSkip(size_t)
Property: Max initial invalid entries.
MemoryTablePtr Ptr
Shared ownership pointer.
Definition MemoryTable.h:23
Constraints are used to select addresses from a memory map.
Definition AddressMap.h:76
boost::shared_ptr< RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to a RISC operators object.
std::shared_ptr< MemoryTable > MemoryTablePtr
Shared-ownership pointer for MemoryTable.
std::shared_ptr< const MemoryTable > MemoryTableConstPtr
Shared-ownership pointer for MemoryTable.
std::uint64_t Address
Address.
Definition Address.h:11
The ROSE library.
const size_t UNLIMITED
Effectively unlimited size.
Definition Constants.h:19