"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/Rose/BinaryAnalysis/Concolic/Architecture.h" between
rose-0.11.49.0.tar.gz and rose-0.11.50.0.tar.gz

About: ROSE is a compiler infrastructure to build source-to-source program transformation and analysis tools for large-scale C, C++, UPC, Fortran, OpenMP, Java, Python and PHP applications.

Architecture.h  (rose-0.11.49.0):Architecture.h  (rose-0.11.50.0)
#ifndef ROSE_BinaryAnalysis_Concolic_Architecture_H #ifndef ROSE_BinaryAnalysis_Concolic_Architecture_H
#define ROSE_BinaryAnalysis_Concolic_Architecture_H #define ROSE_BinaryAnalysis_Concolic_Architecture_H
#include <featureTests.h> #include <featureTests.h>
#ifdef ROSE_ENABLE_CONCOLIC_TESTING #ifdef ROSE_ENABLE_CONCOLIC_TESTING
#include <Rose/BinaryAnalysis/Concolic/BasicTypes.h> #include <Rose/BinaryAnalysis/Concolic/BasicTypes.h>
#include <Rose/BinaryAnalysis/Concolic/ExecutionLocation.h>
#include <Rose/BinaryAnalysis/InstructionSemantics2/BaseSemantics/Types.h> #include <Rose/BinaryAnalysis/InstructionSemantics2/BaseSemantics/Types.h>
#include <Rose/BinaryAnalysis/Partitioner2/BasicTypes.h> #include <Rose/BinaryAnalysis/Partitioner2/BasicTypes.h>
#include <Rose/BinaryAnalysis/RegisterDescriptor.h> #include <Rose/BinaryAnalysis/RegisterDescriptor.h>
#include <Rose/BinaryAnalysis/SmtSolver.h> #include <Rose/BinaryAnalysis/SmtSolver.h>
#include <ByteOrder.h> #include <ByteOrder.h>
#include <Sawyer/BitVector.h> #include <Sawyer/BitVector.h>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
namespace Rose { namespace Rose {
namespace BinaryAnalysis { namespace BinaryAnalysis {
namespace Concolic { namespace Concolic {
/** Base class for architecture-specific operations. */ /** Base class for architecture-specific operations. */
class Architecture: public Sawyer::SharedObject { class Architecture: public Sawyer::SharedObject, public Sawyer::SharedFromThis<A rchitecture> {
public: public:
/** Reference counting pointer. */ /** Reference counting pointer. */
using Ptr = ArchitecturePtr; using Ptr = ArchitecturePtr;
/** Information about system calls. */ /** Information about system calls. */
using SystemCallMap = Sawyer::Container::Map<int /*syscall*/, SystemCallPtr> using SystemCallMap = Sawyer::Container::Map<int /*syscall*/, SyscallCallbac
; ks>;
/** Information about shared memory. */
using SharedMemoryMap = Sawyer::Container::IntervalMap<AddressInterval, Shar
edMemoryCallbacks>;
private: private:
DatabasePtr db_; DatabasePtr db_;
TestCaseId testCaseId_; TestCaseId testCaseId_;
TestCasePtr testCase_; TestCasePtr testCase_;
ExecutionLocation curLocation_; const Partitioner2::Partitioner &partitioner_;
SystemCallMap systemCalls_; ExecutionLocation currentLocation_; // incremented when the
instruction begins execution
SystemCallMap systemCalls_; // callbacks for syscall
s
SharedMemoryMap sharedMemory_; // callbacks for shared
memory
SymbolicExpr::ExprExprHashMap variableValues_; // used for substitution
s
protected: protected:
// See "instance" methods in subclasses // See "instance" methods in subclasses
Architecture(const DatabasePtr&, TestCaseId); Architecture(const DatabasePtr&, TestCaseId, const Partitioner2::Partitioner &);
public: public:
virtual ~Architecture(); virtual ~Architecture();
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////
// Properties // Properties
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////
public: public:
/** Property: Database. /** Property: Database.
* *
* Returns the database used as backing store for parts of this object. Thi s property is read-only, set by the * Returns the database used as backing store for parts of this object. Thi s property is read-only, set by the
skipping to change at line 65 skipping to change at line 72
* Returns the test case ID within the database. This property is read-only , set by the constructor. The return value is * Returns the test case ID within the database. This property is read-only , set by the constructor. The return value is
* always a valid ID. */ * always a valid ID. */
TestCaseId testCaseId() const; TestCaseId testCaseId() const;
/** Property: Test case. /** Property: Test case.
* *
* Returns the test case being executed. This property is read-only, set by the constructor. The return value is always * Returns the test case being executed. This property is read-only, set by the constructor. The return value is always
* non-null. */ * non-null. */
TestCasePtr testCase() const; TestCasePtr testCase() const;
/** Property: Partitioner.
*
* This holds information about the disassembly of the specimen, such as fu
nctions, basic blocks, and instructions. */
const Partitioner2::Partitioner& partitioner() const;
/** Property: Current execution location. /** Property: Current execution location.
* *
* The execution location has two parts: a primary and a secondary. The pri * The execution location has three parts: a primary and a secondary, and w
mary is the execution path length, and the hether it occurs before or after the
* secondary is a serial number that starts at zero for each primary value. * corresponding instruction. The primary is the execution path length, and
Execution locations correspond to the the secondary is a serial number that starts
* locations stored in execution events, therefore when an event is created * at zero for each primary value. Execution locations correspond to the lo
in a parent test case and copied to a child cations stored in execution events, therefore
* test case and then the child test case's events are replayed, the execut * when an event is created in a parent test case and copied to a child tes
ion locations as the child is replayed must t case and then the child test case's events
* match the execution locations that existed in the parent when the execut * are replayed, the execution locations as the child is replayed must matc
ion events were created. h the execution locations that existed in the
* parent when the execution events were created.
* *
* See also, @ref incrementPathLength and @ref nextLocation. * See also, @ref nextInstructionLocation and @ref nextEventLocation.
* *
* @{ */ * @{ */
ExecutionLocation currentLocation() const; ExecutionLocation currentLocation() const;
void currentLocation(const ExecutionLocation&); void currentLocation(const ExecutionLocation&);
/** @} */ /** @} */
/** Property: Information about system calls. /** Property: Information about system calls.
* *
* This is a map indexed by system call number (e.g., SYS_getpid). The valu es of the map contains two types of information: * This is a map indexed by system call number (e.g., SYS_getpid). The valu es of the map contain two types of information:
* *
* @li Information about how a system call should behave. For instance, SYS _getpid should return the same value each time * @li Information about how a system call should behave. For instance, SYS _getpid should return the same value each time
* it's called. * it's called.
* *
* @li Information to make the declaraed behavior possible. For instance, t he concrete and symbolic values returned the * @li Information to make the declaraed behavior possible. For instance, t he concrete and symbolic values returned the
* first time SYS_getpid was called so that we can make it return these sam e values in the future. * first time SYS_getpid was called so that we can make it return these sam e values in the future.
* *
* @{ */ * @{ */
const SystemCallMap& systemCalls() const; const SystemCallMap& systemCalls() const;
SystemCallMap& systemCalls(); SystemCallMap& systemCalls();
/** @} */ /** @} */
/** Property: Information about shared memory.
*
* This is a map indexed by concrete address. The values of the contain two
types of information:
*
* @li Information about how the shared memory region should behave. For in
stance, a reads from shared memory that's
* attached to a timer would probably return monotonically increasing value
s.
*
* @li Information to make the declared behavior possible. For instance, th
e concrete and symbolic values returned
* last time the timer's memory was read so that the new return value can b
e constrained to be greater than or equal
* to the previously returned value.
*
* Each concrete address can have only one @ref SharedMemory object, althou
gh each object can have a list of callbacks.
*
* @{ */
const SharedMemoryMap& sharedMemory() const;
SharedMemoryMap& sharedMemory();
/** @} */
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////
// Functions that can be called before execution starts. // Functions that can be called before execution starts.
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////
public: public:
/** Configures system call behavior. /** Configures system call behavior.
* *
* This function declares how system calls are handled and is called from t he @c instance methods (construction). */ * This function declares how system calls are handled and is called from t he @c instance methods (construction). */
virtual void configureSystemCalls() = 0; virtual void configureSystemCalls() = 0;
/** Configures shared memory behavior.
*
* This function declares how shared memory regions are handled and is call
ed from the @c instance methods
* (constructors). */
virtual void configureSharedMemory() = 0;
/** Add a shared memory callback for a range of addresses. */
void sharedMemory(const AddressInterval&, const SharedMemoryCallbackPtr&);
/** Add a callback for a system call number. */
void systemCalls(size_t syscallId, const SyscallCallbackPtr&);
/** Prepares to execute the specimen concretely. /** Prepares to execute the specimen concretely.
* *
* This should be called before calling any other functions that query or m odify the execution state, such as those that read * This should be called before calling any other functions that query or m odify the execution state, such as those that read
* or write memory and registers. * or write memory and registers.
* *
* The @p directory argument is the name of an existing directory that may be used to create temporary files related to the test * The @p directory argument is the name of an existing directory that may be used to create temporary files related to the test
* case. * case.
* *
* For example, the implementation might create a Linux process from the ex ecutable specimen for this object's test case. */ * For example, the implementation might create a Linux process from the ex ecutable specimen for this object's test case. */
virtual void load(const boost::filesystem::path &tempDirectory) = 0; virtual void load(const boost::filesystem::path &tempDirectory) = 0;
skipping to change at line 145 skipping to change at line 188
virtual std::vector<ExecutionEventPtr> createMemoryHashEvents() = 0; virtual std::vector<ExecutionEventPtr> createMemoryHashEvents() = 0;
/** Create events that would restore register values. /** Create events that would restore register values.
* *
* This function reads all registers and creates events that when replayed would restore the registers to their saved * This function reads all registers and creates events that when replayed would restore the registers to their saved
* values. */ * values. */
virtual std::vector<ExecutionEventPtr> createRegisterRestoreEvents() = 0; virtual std::vector<ExecutionEventPtr> createRegisterRestoreEvents() = 0;
/** Saves a list of events. /** Saves a list of events.
* *
* Each event's test case is set to this object's test case, and the event * Each event's test case is set to this object's test case, and the event
locations set by calling @ref nextLocation for locations set by calling @ref
* each event. The events are written to the database. */ * nextLocationLocation for each event. The events are written to the datab
void saveEvents(const std::vector<ExecutionEventPtr>&); ase. */
void saveEvents(const std::vector<ExecutionEventPtr>&, When);
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////
// High-level functions controlling concrete execution. // High-level functions controlling concrete execution.
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////
public: public:
/** Replay all events. /** Replay all events.
* *
* This is normally called immediately after @ref load. It processes all th e events recorded in the database for this * This is normally called immediately after @ref load. It processes all th e events recorded in the database for this
* test case, causing the concrete execution to return to the state it was in after the last event. Returns the number * test case, causing the concrete execution to return to the state it was in after the last event. Returns the number
* of events processed. */ * of events processed. */
size_t playAllEvents(); size_t playAllEvents(const Partitioner2::Partitioner&);
/** Replay an execution event. /** Replay an execution event.
* *
* Performs the action associated with the specified execution event, and r eturns true if the event was handled. If the * Performs the action associated with the specified execution event, and r eturns true if the event was handled. If the
* implementation was unable to handle the event, then the return value is false. * implementation was unable to handle the event, then the return value is false.
* *
* This might adjust memory, registers, or do some other thing that may or may not affect the execution state. */ * This might adjust memory, registers, or do some other thing that may or may not affect the execution state. */
virtual bool playEvent(const ExecutionEventPtr&); virtual bool playEvent(const ExecutionEventPtr&);
/** Run to the specified event. /** Run to the specified event.
* *
* Execution is advanced until it reaches the specified event. */ * While the current instruction is less than the specified event location,
virtual void runToEvent(const ExecutionEventPtr&); execute the instruction. */
virtual void runToEvent(const ExecutionEventPtr&, const Partitioner2::Partit
ioner&);
/** Read memory bytes as an unsigned integer. /** Read memory bytes as an unsigned integer.
* *
* The number of bytes should be between one and eight, inclusive. */ * The number of bytes should be between one and eight, inclusive. */
uint64_t readMemoryUnsigned(rose_addr_t va, size_t nBytes); uint64_t readMemoryUnsigned(rose_addr_t va, size_t nBytes);
/** Read C-style NUL-terminated string from subordinate. /** Read C-style NUL-terminated string from subordinate.
* *
* Reads up to @p maxBytes bytes or until an ASCII NUL character is read, c oncatenates all the characters (except the NUL) * Reads up to @p maxBytes bytes or until an ASCII NUL character is read, c oncatenates all the characters (except the NUL)
* into a C++ string and returns it. The @p maxBytes includes the NUL termi nator although the NUL terminator is not * into a C++ string and returns it. The @p maxBytes includes the NUL termi nator although the NUL terminator is not
skipping to change at line 241 skipping to change at line 284
/** @} */ /** @} */
/** Read a value from a register. */ /** Read a value from a register. */
virtual Sawyer::Container::BitVector readRegister(RegisterDescriptor) = 0; virtual Sawyer::Container::BitVector readRegister(RegisterDescriptor) = 0;
/** Execute current or specified instruction. /** Execute current or specified instruction.
* *
* Executes the instruction and increments the length of the execution path . * Executes the instruction and increments the length of the execution path .
* *
* @{ */ * @{ */
virtual void executeInstruction() = 0; virtual void executeInstruction(const Partitioner2::Partitioner&) = 0;
virtual void executeInstruction(const InstructionSemantics2::BaseSemantics:: RiscOperatorsPtr&, SgAsmInstruction*) = 0; virtual void executeInstruction(const InstructionSemantics2::BaseSemantics:: RiscOperatorsPtr&, SgAsmInstruction*) = 0;
/** @} */ /** @} */
/** Increment the primary part of the current location. /** Increment the primary part of the current location.
* *
* The primary field of the @ref currentLocation property is incremented, a * The @c primary field of the @ref currentLocation property is incremented
nd the secondary field is set to zero. Returns , the @c secondary field is set to zero, and
* the new location. */ * the @c when field is set to @c AFTER. Returns the new location. */
const ExecutionLocation& incrementPathLength(); const ExecutionLocation& nextInstructionLocation();
/** Increment the secondary part of the current location. /** Increment the secondary part of the current location.
* *
* Increments the serial number for the @ref currentLocation property and r * Increments the serial number for the @ref currentLocation property and r
eturns the new location. */ eturns the new location with its @c when
const ExecutionLocation& nextLocation(); * property set to either @c PRE or @c POST.
*
* @{ */
const ExecutionLocation& nextEventLocation(When);
/** @} */
/** Variables and values for substitutions.
*
* Some events, such as shared-memory-read, have no action but are able to
define variables and give them values.
* This property holds those variable = value assignments.
*
* @{ */
const SymbolicExpr::ExprExprHashMap& variableValues() const;
SymbolicExpr::ExprExprHashMap& variableValues();
/** @} */
/** Returns similar events.
*
* Returns events that are for the same instruction as the specified event,
but occur after it. The events are returned
* in the order they occur. */
std::vector<ExecutionEventPtr> getRelatedEvents(const ExecutionEventPtr&) co
nst;
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////
// Functions related to symbolic states. // Functions related to symbolic states.
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////
public: public:
/** Create initial input variables. /** Create initial input variables.
* *
* Reads the initial concrete state in order to create symbolic variables f or initial input values such as the program * Reads the initial concrete state in order to create symbolic variables f or initial input values such as the program
* arguments, number of program arguments, environment variables, auxilliar y vector, etc. The new variables are added * arguments, number of program arguments, environment variables, auxilliar y vector, etc. The new variables are added
* to the @p inputVariables argument. * to the @p inputVariables argument.
skipping to change at line 301 skipping to change at line 364
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////
// Functions related to operating system emulation // Functions related to operating system emulation
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////
public: public:
/** Called when a system call occurs. /** Called when a system call occurs.
* *
* This function is called after a system call instruction has been execute d symbolically and the system call has been * This function is called after a system call instruction has been execute d symbolically and the system call has been
* entered concretely. */ * entered concretely. */
virtual void systemCall(const Partitioner2::Partitioner&, const InstructionS emantics2::BaseSemantics::RiscOperatorsPtr&) {} virtual void systemCall(const Partitioner2::Partitioner&, const InstructionS emantics2::BaseSemantics::RiscOperatorsPtr&) {}
/** Called when shared memory is read.
*
* This function is called as soon as shared memory is read. It should eith
er perform the read operation and return
* the result, or return null in which case the caller will do the usual re
ad operation. */
virtual std::pair<ExecutionEventPtr, SymbolicExprPtr>
sharedMemoryRead(const SharedMemoryCallbacks&, const Partitioner2::Partition
er&,
const InstructionSemantics2::BaseSemantics::RiscOperatorsPt
r&, rose_addr_t memVa, size_t nBytes);
}; };
} // namespace } // namespace
} // namespace } // namespace
} // namespace } // namespace
#endif #endif
#endif #endif
 End of changes. 18 change blocks. 
33 lines changed or deleted 127 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)