ROSE 0.11.145.192
InstructionProvider.h
1#ifndef ROSE_BinaryAnalysis_InstructionProvider_H
2#define ROSE_BinaryAnalysis_InstructionProvider_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5
6#include <Rose/BinaryAnalysis/BasicTypes.h>
7#include <Rose/BinaryAnalysis/ByteOrder.h>
8#include <Rose/BinaryAnalysis/CallingConvention/BasicTypes.h>
9
10#include <Sawyer/HashMap.h>
11#include <Sawyer/SharedPointer.h>
12
13#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
14#include <boost/serialization/access.hpp>
15#endif
16
17namespace Rose {
18namespace BinaryAnalysis {
19
33public:
36
39
40private:
41 Architecture::BaseConstPtr architecture_; // required architecture
42 Disassembler::BasePtr disassembler_; // disassembler_ is non-null iff memMap_ is non-null
43 MemoryMapPtr memMap_; // optional map from which instructions are decoded if disassembler_
44 mutable InsnMap insnMap_; // this is a cache
45
46#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
47private:
48 friend class boost::serialization::access;
49
50 template<class Archive>
51 void save(Archive&, const unsigned version) const;
52
53 template<class Archive>
54 void load(Archive&, const unsigned version);
55
56 BOOST_SERIALIZATION_SPLIT_MEMBER();
57#endif
58
59private:
60 InstructionProvider(); // used only by boost::serialization
61protected:
63
64public:
66
77
83
90 SgAsmInstruction* operator[](rose_addr_t va) const;
91
97
103
110 size_t nCached() const { return insnMap_.size(); }
111
114
117
120
123
128
134
139
142
144 size_t wordSize() const;
145
147 size_t instructionAlignment() const;
148
155
157 void showStatistics() const;
158};
159
160} // namespace
161} // namespace
162
163// Class versions must be at global scope
164BOOST_CLASS_VERSION(Rose::BinaryAnalysis::InstructionProvider, 2);
165
166#endif
167#endif
Provides and caches instructions.
void showStatistics() const
Print some partitioner performance statistics.
static Ptr instance(const Architecture::BaseConstPtr &, const MemoryMapPtr &)
Allocating Constructor.
Sawyer::SharedPointer< InstructionProvider > Ptr
Shared-ownership pointer.
RegisterDescriptor instructionPointerRegister() const
Register used as the instruction pointer.
Disassembler::BasePtr disassembler() const
Returns the disassembler.
size_t wordSize() const
Word size in bits.
InstructionSemantics::BaseSemantics::DispatcherPtr dispatcher(const InstructionSemantics::BaseSemantics::RiscOperatorsPtr &) const
Instruction dispatcher.
RegisterDescriptor stackSegmentRegister() const
Register used as a segment to access stack memory.
void insert(SgAsmInstruction *)
Insert an instruction into the cache.
size_t instructionAlignment() const
Alignment requirement for instructions.
RegisterDictionaryPtr registerDictionary() const
Returns the register dictionary.
Sawyer::Container::HashMap< rose_addr_t, SgAsmInstruction * > InsnMap
Mapping from address to instruction.
RegisterDescriptor stackPointerRegister() const
Register used as a user-mode stack pointer.
SgAsmInstruction * operator[](rose_addr_t va) const
Returns the instruction at the specified virtual address, or null.
ByteOrder::Endianness defaultByteOrder() const
Default memory byte order.
RegisterDescriptor stackFrameRegister() const
Register used for function call frames.
RegisterDescriptor callReturnRegister() const
Register holding a function call's return address.
size_t nCached() const
Returns number of cached starting addresses.
const CallingConvention::Dictionary & callingConventions() const
Returns the calling convention dictionary.
bool isDisassemblerEnabled() const
Enable or disable the disassembler.
Describes (part of) a physical CPU register.
Container associating values with keys.
Definition HashMap.h:30
size_t size() const
Number of nodes, keys, or values in this container.
Definition HashMap.h:347
Base class for reference counted objects.
Reference-counting intrusive smart pointer.
Base class for machine instructions.
std::shared_ptr< const Base > BaseConstPtr
Reference counted pointer for Architecture::Base.
std::vector< DefinitionPtr > Dictionary
An ordered collection of calling convention definitions.
boost::shared_ptr< RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to a RISC operators object.
boost::shared_ptr< Dispatcher > DispatcherPtr
Shared-ownership pointer to a semantics instruction dispatcher.
The ROSE library.