ROSE  0.9.10.54
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
Rose::BinaryAnalysis::NoOperation Class Reference

Description

Analysis that looks for no-op equivalents.

Definition at line 13 of file BinaryNoOperation.h.

#include <BinaryNoOperation.h>

Collaboration diagram for Rose::BinaryAnalysis::NoOperation:
Collaboration graph
[legend]

Classes

class  StateNormalizer
 Base class for normalizing a state. More...
 

Public Types

typedef Sawyer::Container::Interval< size_t > IndexInterval
 An interval of instruction indices. More...
 
typedef std::vector< IndexIntervalIndexIntervals
 A vector of instruction indices. More...
 

Public Member Functions

 NoOperation ()
 Default constructor. More...
 
 NoOperation (const InstructionSemantics2::BaseSemantics::DispatcherPtr &cpu)
 Construct a new analysis with specified virtual CPU. More...
 
 NoOperation (BinaryAnalysis::Disassembler *)
 Construct a new analysis for a specific disassembler. More...
 
bool isNoop (SgAsmInstruction *) const
 Determines if an instruction is a no-op. More...
 
bool isNoop (const std::vector< SgAsmInstruction * > &) const
 Determines if a sequence of instructions is a no-op. More...
 
IndexIntervals findNoopSubsequences (const std::vector< SgAsmInstruction * > &) const
 Finds all sequences of instructions that are equivalent to no-operation. More...
 
StateNormalizer::Ptr stateNormalizer () const
 Property: state normalizer. More...
 
void stateNormalizer (const StateNormalizer::Ptr &f)
 Property: state normalizer. More...
 
const Sawyer::Optional< rose_addr_t > initialStackPointer () const
 Property: initial concrete value for stack pointer. More...
 
void initialStackPointer (const Sawyer::Optional< rose_addr_t > &v)
 Property: initial concrete value for stack pointer. More...
 
bool ignoreTerminalBranches () const
 Property: Whether terminal branches can be no-ops. More...
 
void ignoreTerminalBranches (bool b)
 Property: Whether terminal branches can be no-ops. More...
 

Static Public Member Functions

static IndexIntervals largestEarliestNonOverlapping (const IndexIntervals &)
 Select certain no-op sequences. More...
 
static std::vector< bool > toVector (const IndexIntervals &, size_t size=0)
 Return a boolean vector. More...
 
static void initDiagnostics ()
 Initializes and registers disassembler diagnostic streams. More...
 

Static Public Attributes

static Sawyer::Message::Facility mlog
 Diagnostic streams. More...
 

Protected Member Functions

InstructionSemantics2::BaseSemantics::StatePtr initialState (SgAsmInstruction *firstInsn) const
 
std::string normalizeState (const InstructionSemantics2::BaseSemantics::StatePtr &) const
 

Member Typedef Documentation

An interval of instruction indices.

Definition at line 16 of file BinaryNoOperation.h.

A vector of instruction indices.

Definition at line 19 of file BinaryNoOperation.h.

Constructor & Destructor Documentation

Rose::BinaryAnalysis::NoOperation::NoOperation ( )
inline

Default constructor.

Since this default constructor has no information about the virtual CPU, it will assume that all instructions have an effect.

Definition at line 73 of file BinaryNoOperation.h.

Rose::BinaryAnalysis::NoOperation::NoOperation ( const InstructionSemantics2::BaseSemantics::DispatcherPtr cpu)
inlineexplicit

Construct a new analysis with specified virtual CPU.

Definition at line 77 of file BinaryNoOperation.h.

Rose::BinaryAnalysis::NoOperation::NoOperation ( BinaryAnalysis::Disassembler )
explicit

Construct a new analysis for a specific disassembler.

An analysis constructed this way will use the symbolic semantics domain.

Member Function Documentation

StateNormalizer::Ptr Rose::BinaryAnalysis::NoOperation::stateNormalizer ( ) const
inline

Property: state normalizer.

The state normalizer is responsible for normalizing a virtual machine state and turning it into a string. When looking for no-ops, if two state strings compare equal then the instruction(s) that transitioned the machine from one state to the other are effectively a no-op. In particular, the state normalizer should probably not try to compare instruction pointer registers, or memory that was read without being written (i.e., memory that sprang into existence by reading). The default normalizer does both of these things if the register state is derived from InstructionSemantics2::BaseSemantics::RegisterStateGeneric and the memory state is derived from InstructionSemantics2::BaseSemantics::MemoryCellList.

Definition at line 96 of file BinaryNoOperation.h.

void Rose::BinaryAnalysis::NoOperation::stateNormalizer ( const StateNormalizer::Ptr f)
inline

Property: state normalizer.

The state normalizer is responsible for normalizing a virtual machine state and turning it into a string. When looking for no-ops, if two state strings compare equal then the instruction(s) that transitioned the machine from one state to the other are effectively a no-op. In particular, the state normalizer should probably not try to compare instruction pointer registers, or memory that was read without being written (i.e., memory that sprang into existence by reading). The default normalizer does both of these things if the register state is derived from InstructionSemantics2::BaseSemantics::RegisterStateGeneric and the memory state is derived from InstructionSemantics2::BaseSemantics::MemoryCellList.

Definition at line 97 of file BinaryNoOperation.h.

const Sawyer::Optional<rose_addr_t> Rose::BinaryAnalysis::NoOperation::initialStackPointer ( ) const
inline

Property: initial concrete value for stack pointer.

A concrete initial value for the stack pointer can be used to help decide whether memory addresses are recently popped. It may be possible to do this without a concrete value also, depending on the semantic domain.

Definition at line 106 of file BinaryNoOperation.h.

void Rose::BinaryAnalysis::NoOperation::initialStackPointer ( const Sawyer::Optional< rose_addr_t > &  v)
inline

Property: initial concrete value for stack pointer.

A concrete initial value for the stack pointer can be used to help decide whether memory addresses are recently popped. It may be possible to do this without a concrete value also, depending on the semantic domain.

Definition at line 107 of file BinaryNoOperation.h.

bool Rose::BinaryAnalysis::NoOperation::ignoreTerminalBranches ( ) const
inline

Property: Whether terminal branches can be no-ops.

If set (the default) then branch instructions that appear as the last instruction of a basic block, and which have one constant, known successor which is not the fall-through address are not considered to be part of any no-op sequence.

Definition at line 116 of file BinaryNoOperation.h.

void Rose::BinaryAnalysis::NoOperation::ignoreTerminalBranches ( bool  b)
inline

Property: Whether terminal branches can be no-ops.

If set (the default) then branch instructions that appear as the last instruction of a basic block, and which have one constant, known successor which is not the fall-through address are not considered to be part of any no-op sequence.

Definition at line 117 of file BinaryNoOperation.h.

bool Rose::BinaryAnalysis::NoOperation::isNoop ( SgAsmInstruction ) const

Determines if an instruction is a no-op.

bool Rose::BinaryAnalysis::NoOperation::isNoop ( const std::vector< SgAsmInstruction * > &  ) const

Determines if a sequence of instructions is a no-op.

IndexIntervals Rose::BinaryAnalysis::NoOperation::findNoopSubsequences ( const std::vector< SgAsmInstruction * > &  ) const

Finds all sequences of instructions that are equivalent to no-operation.

static IndexIntervals Rose::BinaryAnalysis::NoOperation::largestEarliestNonOverlapping ( const IndexIntervals )
static

Select certain no-op sequences.

Given a list of no-op sequences, such as returned by findNoopSubsequences, process the list so that the largest non-overlapping sequences are returned. If sequence A is larger than sequence B, then B is discarded. If A and B are the same size and overlap and A starts before B then B is discarded.

The return value is sorted by decreasing size and contains non-overlapping intervals.

static std::vector<bool> Rose::BinaryAnalysis::NoOperation::toVector ( const IndexIntervals ,
size_t  size = 0 
)
static

Return a boolean vector.

Returns a vector with one element per instruction. The element is true if the instruction is part of one of the specified index intervals. The returned vector will contain at least size elements.

static void Rose::BinaryAnalysis::NoOperation::initDiagnostics ( )
static

Initializes and registers disassembler diagnostic streams.

See Diagnostics::initialize().

Member Data Documentation

Sawyer::Message::Facility Rose::BinaryAnalysis::NoOperation::mlog
static

Diagnostic streams.

Definition at line 66 of file BinaryNoOperation.h.


The documentation for this class was generated from the following file: