ROSE  0.11.145.0
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 14 of file NoOperation.h.

#include <Rose/BinaryAnalysis/NoOperation.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 InstructionSemantics::BaseSemantics::DispatcherPtr &cpu)
 Construct a new analysis with specified virtual CPU. More...
 
 NoOperation (const BinaryAnalysis::Disassembler::BasePtr &)
 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

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

Member Typedef Documentation

An interval of instruction indices.

Definition at line 17 of file NoOperation.h.

A vector of instruction indices.

Definition at line 20 of file NoOperation.h.

Constructor & Destructor Documentation

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

Default constructor.

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

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

Construct a new analysis with specified virtual CPU.

Definition at line 77 of file NoOperation.h.

Rose::BinaryAnalysis::NoOperation::NoOperation ( const BinaryAnalysis::Disassembler::BasePtr )
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 InstructionSemantics::BaseSemantics::RegisterStateGeneric and the memory state is derived from InstructionSemantics::BaseSemantics::MemoryCellList.

Definition at line 96 of file NoOperation.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 InstructionSemantics::BaseSemantics::RegisterStateGeneric and the memory state is derived from InstructionSemantics::BaseSemantics::MemoryCellList.

Definition at line 97 of file NoOperation.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 NoOperation.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 NoOperation.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 NoOperation.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 NoOperation.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 67 of file NoOperation.h.


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