1#ifndef ROSE_BinaryAnalysis_HotPatch_H
2#define ROSE_BinaryAnalysis_HotPatch_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
6#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/SValue.h>
7#include <Rose/BinaryAnalysis/HotPatch.h>
8#include <Rose/BinaryAnalysis/SmtSolver.h>
9#include <Sawyer/Message.h>
11#include <boost/serialization/access.hpp>
12#include <boost/serialization/nvp.hpp>
13#include <boost/serialization/shared_ptr.hpp>
16namespace BinaryAnalysis {
49#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
51 friend class boost::serialization::access;
54 void serialize(S &s,
const unsigned ) {
55 s & BOOST_SERIALIZATION_NVP(type_);
56 s & BOOST_SERIALIZATION_NVP(register_);
57 s & BOOST_SERIALIZATION_NVP(oldValue_);
58 s & BOOST_SERIALIZATION_NVP(newValue_);
59 s & BOOST_SERIALIZATION_NVP(behavior_);
150#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
152 friend class boost::serialization::access;
155 void serialize(S &s,
const unsigned ) {
156 s & BOOST_SERIALIZATION_NVP(records_);
176 return records_.size();
189 records_.push_back(record);
190 return records_.size() - 1;
199 ASSERT_require(idx < records_.size());
200 return records_[idx];
203 ASSERT_require(idx < records_.size());
204 return records_[idx];
Describes a single hot patch.
InstructionSemantics::BaseSemantics::SValuePtr oldValue() const
Property: Value to match.
Type type() const
Property: Type of record.
void newValue(const InstructionSemantics::BaseSemantics::SValuePtr &v)
Property: Replacement value.
Behavior
Behavior when a record matches.
@ MATCH_BREAK
Don't try to match more records after a match is found.
@ MATCH_CONTINUE
Try to match additional subsequent records.
Record(RegisterDescriptor reg, const InstructionSemantics::BaseSemantics::SValuePtr &oldValue, const InstructionSemantics::BaseSemantics::SValuePtr &newValue, Behavior behavior=MATCH_CONTINUE)
Construct a record that substitutes a register.
void reg(RegisterDescriptor r)
Property: Register to be matched.
RegisterDescriptor reg() const
Property: Register to be matched.
Record()
Construct a no-op record.
void behavior(Behavior b)
Property: Behavior after matching.
Type
Type of patch record.
@ PATCH_NONE
Type for default-constructed records.
@ PATCH_REGISTER
Change the value of a register.
void oldValue(const InstructionSemantics::BaseSemantics::SValuePtr &v)
Property: Value to match.
InstructionSemantics::BaseSemantics::SValuePtr newValue() const
Property: Replacement value.
Behavior behavior() const
Property: Behavior after matching.
Describes how to modify machine state after each instruction.
void clear()
Remove all records from this object.
std::vector< Record > Records
Ordered list of hot patch records.
Records & records()
Property: Hot patch records.
const Record & operator[](size_t idx) const
Reference a particular record.
size_t apply(const InstructionSemantics::BaseSemantics::RiscOperatorsPtr &) const
Apply records to a machine state.
static Sawyer::Message::Facility mlog
Diagnostic output for hot patching.
size_t append(const Record &record)
Append a hot-patch record.
Record & operator[](size_t idx)
Reference a particular record.
const Records & records() const
Property: Hot patch records.
size_t operator()(const InstructionSemantics::BaseSemantics::RiscOperatorsPtr &ops) const
Apply records to a machine state.
static void initDiagnostics()
Initialize diagnostic output.
size_t nRecords() const
Number of hot-patch records in this object.
Describes (part of) a physical CPU register.
boost::shared_ptr< RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to a RISC operators object.