ROSE 0.11.145.147
|
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 270 of file SerialIo.h.
#include <Rose/BinaryAnalysis/SerialIo.h>
Public Types | |
using | Ptr = SerialOutputPtr |
Reference counting pointer. | |
Public Types inherited from Rose::BinaryAnalysis::SerialIo | |
enum | Format { BINARY , TEXT , XML } |
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. | |
Public Member Functions | |
void | open (const boost::filesystem::path &fileName) override |
Attach a file. | |
void | close () override |
Detach a file. | |
void | savePartitioner (const Partitioner2::PartitionerConstPtr &) |
Save a binary analysis partitioner. | |
void | saveAst (SgAsmNode *) |
Save a binary AST. | |
void | saveAst (SgBinaryComposite *) |
template<class T > | |
void | saveObject (Savable objectTypeId, const T &object) |
Save an object to the output stream. | |
Public Member Functions inherited from Rose::BinaryAnalysis::SerialIo | |
virtual | ~SerialIo () |
Destructor. | |
bool | isOpen () const |
Whether a file is attached. | |
Savable | objectType () const |
Type ID for next object. | |
Format | format () const |
Property: File format. | |
void | format (Format) |
Property: File format. | |
Progress::Ptr | progress () const |
Property: Progress reporter. | |
void | progress (const Progress::Ptr &) |
Property: Progress reporter. | |
Public Member Functions inherited from Sawyer::SharedObject | |
SharedObject () | |
Default constructor. | |
SharedObject (const SharedObject &) | |
Copy constructor. | |
virtual | ~SharedObject () |
Virtual destructor. | |
SharedObject & | operator= (const SharedObject &) |
Assignment. | |
Static Public Member Functions | |
static Ptr | instance () |
Factory method to create a new instance. | |
Static Public Member Functions inherited from Rose::BinaryAnalysis::SerialIo | |
static Savable | userSavable (unsigned offset) |
Create a new Savable enum constant. | |
Additional Inherited Members | |
Static Public Attributes inherited from Rose::BinaryAnalysis::SerialIo | |
static Sawyer::Message::Facility | mlog |
Message facility. | |
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_ |
Reference counting pointer.
Definition at line 273 of file SerialIo.h.
|
inlineprotected |
Definition at line 286 of file SerialIo.h.
|
overridevirtual |
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.
|
overridevirtual |
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.
|
inlinestatic |
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 300 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.
|
inline |
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 348 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().