Public Types | Public Member Functions | Static Public Member Functions | List of all members
Rose::BinaryAnalysis::SerialOutput Class Reference


Output binary analysis state.

Writes binary analysis state to a file that can be read later to re-initialize ROSE to the same state.

Definition at line 268 of file SerialIo.h.

#include <Rose/BinaryAnalysis/SerialIo.h>

Inheritance diagram for Rose::BinaryAnalysis::SerialOutput:
Inheritance graph
Collaboration diagram for Rose::BinaryAnalysis::SerialOutput:
Collaboration graph

Public Types

using Ptr = SerialOutputPtr
 Reference counting pointer. More...
- Public Types inherited from Rose::BinaryAnalysis::SerialIo
enum  Format {
 Format of the state file. More...
enum  Savable {
  NO_OBJECT = 0x00000000,
  PARTITIONER = 0x00000001,
  AST = 0x00000002,
  END_OF_DATA = 0x0000fffe,
  ERROR = 0x0000ffff,
  USER_DEFINED = 0x00010000,
  USER_DEFINED_LAST = 0xffffffff
 Types of objects that can be saved. More...
using Ptr = SerialIoPtr
 Reference counting pointer. More...

Public Member Functions

void open (const boost::filesystem::path &fileName) override
 Attach a file. More...
void close () override
 Detach a file. More...
void savePartitioner (const Partitioner2::PartitionerConstPtr &)
 Save a binary analysis partitioner. More...
void saveAst (SgAsmNode *)
 Save a binary AST. More...
void saveAst (SgBinaryComposite *)
template<class T >
void saveObject (Savable objectTypeId, const T &object)
 Save an object to the output stream. More...
- Public Member Functions inherited from Rose::BinaryAnalysis::SerialIo
virtual ~SerialIo ()
 Destructor. More...
bool isOpen () const
 Whether a file is attached. More...
Savable objectType () const
 Type ID for next object. More...
Format format () const
 Property: File format. More...
void format (Format)
 Property: File format. More...
Progress::Ptr progress () const
 Property: Progress reporter. More...
void progress (const Progress::Ptr &)
 Property: Progress reporter. More...
- Public Member Functions inherited from Sawyer::SharedObject
 SharedObject ()
 Default constructor. More...
 SharedObject (const SharedObject &)
 Copy constructor. More...
virtual ~SharedObject ()
 Virtual destructor. More...
SharedObjectoperator= (const SharedObject &)
 Assignment. More...

Static Public Member Functions

static Ptr instance ()
 Factory method to create a new instance. More...
- Static Public Member Functions inherited from Rose::BinaryAnalysis::SerialIo
static Savable userSavable (unsigned offset)
 Create a new Savable enum constant. More...

Additional Inherited Members

- Static Public Attributes inherited from Rose::BinaryAnalysis::SerialIo
static Sawyer::Message::Facility mlog
 Message facility. More...
- Protected Member Functions inherited from Rose::BinaryAnalysis::SerialIo
void setIsOpen (bool b)
void objectType (Savable)
- Protected Attributes inherited from Rose::BinaryAnalysis::SerialIo
Sawyer::ProgressBar< size_t > progressBar_
int fd_

Member Typedef Documentation

Reference counting pointer.

Definition at line 271 of file SerialIo.h.

Member Function Documentation

void Rose::BinaryAnalysis::SerialOutput::open ( const boost::filesystem::path &  )

Attach a file.

When opening an output stream, the file is created or truncated; when opening an input stream the file must already exist. If a file is already attached, then the previous file is closed first before this new one is opened.

Throws an Exception if the file cannot be attached or the previous if any, cannot be closed.

Thread safety: This method is not thread-safe.

Implements Rose::BinaryAnalysis::SerialIo.

void Rose::BinaryAnalysis::SerialOutput::close ( )

Detach a file.

If a file is attached to this I/O object, that file is closed and this object is set to its detached state. This is a no-op if no file is attached.

Throws an Exception if the file cannot be detached.

The close method is automatically called during object destruction, although its exceptions are suppressed in that situation.

Thread safety: This method is not thread-safe.

Implements Rose::BinaryAnalysis::SerialIo.

static Ptr Rose::BinaryAnalysis::SerialOutput::instance ( )

Factory method to create a new instance.

The returned instance is in a detached state, therefore the open method needs to be called before any I/O operations can be invoked.

Definition at line 298 of file SerialIo.h.

void Rose::BinaryAnalysis::SerialOutput::savePartitioner ( const Partitioner2::PartitionerConstPtr )

Save a binary analysis partitioner.

The specified partitioner, including all data reachable from the partitioner such as specimen data, instruction ASTs, and analysis results, is written to the attached file.

Throws an Exception if the partitioner cannot be saved.

Thread safety: This method is not thread-safe. No other thread should be using this object, and no other thread should be modifying the partitioner.

void Rose::BinaryAnalysis::SerialOutput::saveAst ( SgAsmNode )

Save a binary AST.

Saves the entire AST rooted at the specified node. Due to elimination of duplicate objects, saving the same tree (or any subtree) twice will have negligible effect on the output file size.

Throws an Exception if the AST cannot be saved. It is permissible to pass a null pointer, in which case the null pointer is saved and can be read back later.

Thread safety: This method is not thread-safe. Furthermore, it temporarily sets the parent pointer of the specified AST node to null and thus may interfere with threads that reading this part of the AST. It is unsafe to invoke this method while other threads are modifying this part of the AST since AST modification is not thread safe.

template<class T >
void Rose::BinaryAnalysis::SerialOutput::saveObject ( Savable  objectTypeId,
const T &  object 

Save an object to the output stream.

The objectTypeId and corresponding object are written to the output stream. The object must either implement the Boost serialization interface or be understood by the Boost serialization interface. The objectTypeId is used to identify the object type when reading the archive later since the object type must be known before it can be read.

If the object is a pointer, then the object is not actually written a second time if the same object has been written previously. Most objects recursively write all contained objects, and the elision of previously written objects becomes important in this case. When reading object later, the input stream will appear to contain both objects even if they're the same pointer, and will return the same pointer for both objects. I.e., object sharing during output will result in object sharing during input.

Throws an Exception if any errors occur.

Definition at line 346 of file SerialIo.h.

References Rose::BinaryAnalysis::SerialIo::ERROR, Rose::BinaryAnalysis::SerialIo::isOpen(), Sawyer::ProgressBarSettings::minimumUpdateInterval(), Rose::BinaryAnalysis::SerialIo::objectType(), Sawyer::ProgressBar< T, S >::prefix(), Rose::BinaryAnalysis::SerialIo::progress(), and Sawyer::ProgressBar< T, S >::value().

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