ROSE  0.10.0.0
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Rose::BinaryAnalysis::VxcoreParser Class Reference

Description

Parser for Vxcore format files.

The vxcore format is a format defined by ROSE itself for loading memory dumps from simple hardware devices. The format is intended to be as simple as possible so that it's easy to produce on the low-memory, low-powered device.

Version 1

Version 1 of this file format consists of two kinds of records: memory and registers.

A memory record begins with header which is line of plain ASCII text terminated by a colon and line-feed. The line contains the starting address, the size in bytes, and the optional memory protection bits. These fields are separated from one another by horizontal white space. The address and size are hexadecimal values without a leading "0x". The optional protection bits are introduced with an equal sign "=" followed by zero or more of the upper-case letters "R" (read), "W" (write), "X" (execute) in any order. Within the protection bits, a hyphen "-" can be used as a placeholder if desired. The header's line-feed is immediately followed by the indicated number of bytes stored in binary format. The bytes are not terminated by any special sequence, but rather lead directly into the next header.

A register record (at most one per file) begins with the word "registers", a space, and the instruction set architecture name recognized by ROSE. Following the header is one line per register, each line being a register name recognized by ROSE, a colon, optional horizontal white space, and a hexadecimal value, this time with a leading "0x".

Definition at line 38 of file BinaryVxcoreParser.h.

#include <BinaryVxcoreParser.h>

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

Classes

class  Exception
 Exception thrown for parse errors. More...
 
struct  Settings
 Settings that control the parser and unparser. More...
 

Public Member Functions

boost::filesystem::path parseUrl (const std::string &)
 Parse a URL and adjust the settings. More...
 
const std::string & isaName () const
 Parsed instruction set architecture name. More...
 
const Settingssettings () const
 Property: Settings for parsing and unparsing.
 
Settingssettings ()
 Property: Settings for parsing and unparsing.
 
void settings (const Settings &s)
 Property: Settings for parsing and unparsing.
 
void parse (const boost::filesystem::path &, const MemoryMap::Ptr &)
 Parse input file. More...
 
void parse (const boost::filesystem::path &, const InstructionSemantics2::BaseSemantics::RegisterStatePtr &registers, const InstructionSemantics2::BaseSemantics::RiscOperatorsPtr &ops)
 Parse input file. More...
 
void parse (const boost::filesystem::path &, const MemoryMap::Ptr &, const InstructionSemantics2::BaseSemantics::RegisterStatePtr &registers, const InstructionSemantics2::BaseSemantics::RiscOperatorsPtr &ops)
 Parse input file. More...
 
void parse (std::istream &, const MemoryMap::Ptr &, const InstructionSemantics2::BaseSemantics::RegisterStatePtr &registers, const InstructionSemantics2::BaseSemantics::RiscOperatorsPtr &ops, const std::string &inputName="input")
 Parse input file. More...
 
void unparse (std::ostream &, const MemoryMap::Ptr &, const AddressInterval &memoryLimit, const std::string &outputName="output")
 Unparse memory and/or registers to this format. More...
 
void unparse (std::ostream &, const InstructionSemantics2::BaseSemantics::RegisterStatePtr &, const InstructionSemantics2::BaseSemantics::RiscOperatorsPtr &, const std::string &outputName="output")
 Unparse memory and/or registers to this format. More...
 
void unparse (std::ostream &, const MemoryMap::Ptr &, const AddressInterval &memoryLimit, const InstructionSemantics2::BaseSemantics::RegisterStatePtr &, const InstructionSemantics2::BaseSemantics::RiscOperatorsPtr &, const std::string &outputName="output")
 Unparse memory and/or registers to this format. More...
 

Static Public Member Functions

static void initDiagnostics ()
 

Static Public Attributes

static Sawyer::Message::Facility mlog
 Diagnostic facility for vxcore file format. More...
 

Member Function Documentation

boost::filesystem::path Rose::BinaryAnalysis::VxcoreParser::parseUrl ( const std::string &  )

Parse a URL and adjust the settings.

Parses the specified URL which should not include the leading "vxcore:", adjusts this object's settings, and returns the file name part of the URL. Throws an Exception for any parsing errors.

Note that this function doesn't actually parse the file, only the URL that contains the file name.

void Rose::BinaryAnalysis::VxcoreParser::parse ( const boost::filesystem::path &  ,
const MemoryMap::Ptr  
)

Parse input file.

The specified file is opened and parsed and the results used to initialize memory and/or registers. If a non-null memory map is passed as an argument, then then file data is copied into the map. If a non-null register state is provided (along with a required RiscOperators object for extraction and concatenation), then registers are set to values contained in the file.

Parse errors throw an Exception.

void Rose::BinaryAnalysis::VxcoreParser::parse ( const boost::filesystem::path &  ,
const InstructionSemantics2::BaseSemantics::RegisterStatePtr registers,
const InstructionSemantics2::BaseSemantics::RiscOperatorsPtr ops 
)

Parse input file.

The specified file is opened and parsed and the results used to initialize memory and/or registers. If a non-null memory map is passed as an argument, then then file data is copied into the map. If a non-null register state is provided (along with a required RiscOperators object for extraction and concatenation), then registers are set to values contained in the file.

Parse errors throw an Exception.

void Rose::BinaryAnalysis::VxcoreParser::parse ( const boost::filesystem::path &  ,
const MemoryMap::Ptr ,
const InstructionSemantics2::BaseSemantics::RegisterStatePtr registers,
const InstructionSemantics2::BaseSemantics::RiscOperatorsPtr ops 
)

Parse input file.

The specified file is opened and parsed and the results used to initialize memory and/or registers. If a non-null memory map is passed as an argument, then then file data is copied into the map. If a non-null register state is provided (along with a required RiscOperators object for extraction and concatenation), then registers are set to values contained in the file.

Parse errors throw an Exception.

void Rose::BinaryAnalysis::VxcoreParser::parse ( std::istream &  ,
const MemoryMap::Ptr ,
const InstructionSemantics2::BaseSemantics::RegisterStatePtr registers,
const InstructionSemantics2::BaseSemantics::RiscOperatorsPtr ops,
const std::string &  inputName = "input" 
)

Parse input file.

The specified file is opened and parsed and the results used to initialize memory and/or registers. If a non-null memory map is passed as an argument, then then file data is copied into the map. If a non-null register state is provided (along with a required RiscOperators object for extraction and concatenation), then registers are set to values contained in the file.

Parse errors throw an Exception.

void Rose::BinaryAnalysis::VxcoreParser::unparse ( std::ostream &  ,
const MemoryMap::Ptr ,
const AddressInterval memoryLimit,
const std::string &  outputName = "output" 
)

Unparse memory and/or registers to this format.

If a non-null memory map is supplied, then the memory that's contained within the specified memoryLimit address range is output (pass AddressInterval::whole() to emit all mapped memory).

If a non-null register state is specified, then output values for all the registers contained in that state, skipping registers that don't have a concrete value. In this case, a RiscOperators object must also be supplied in order to concat and/or extract register parts.

The optional outputName is used to identify the output stream in error messages and exceptions.

void Rose::BinaryAnalysis::VxcoreParser::unparse ( std::ostream &  ,
const InstructionSemantics2::BaseSemantics::RegisterStatePtr ,
const InstructionSemantics2::BaseSemantics::RiscOperatorsPtr ,
const std::string &  outputName = "output" 
)

Unparse memory and/or registers to this format.

If a non-null memory map is supplied, then the memory that's contained within the specified memoryLimit address range is output (pass AddressInterval::whole() to emit all mapped memory).

If a non-null register state is specified, then output values for all the registers contained in that state, skipping registers that don't have a concrete value. In this case, a RiscOperators object must also be supplied in order to concat and/or extract register parts.

The optional outputName is used to identify the output stream in error messages and exceptions.

void Rose::BinaryAnalysis::VxcoreParser::unparse ( std::ostream &  ,
const MemoryMap::Ptr ,
const AddressInterval memoryLimit,
const InstructionSemantics2::BaseSemantics::RegisterStatePtr ,
const InstructionSemantics2::BaseSemantics::RiscOperatorsPtr ,
const std::string &  outputName = "output" 
)

Unparse memory and/or registers to this format.

If a non-null memory map is supplied, then the memory that's contained within the specified memoryLimit address range is output (pass AddressInterval::whole() to emit all mapped memory).

If a non-null register state is specified, then output values for all the registers contained in that state, skipping registers that don't have a concrete value. In this case, a RiscOperators object must also be supplied in order to concat and/or extract register parts.

The optional outputName is used to identify the output stream in error messages and exceptions.

const std::string& Rose::BinaryAnalysis::VxcoreParser::isaName ( ) const
inline

Parsed instruction set architecture name.

Latest encountered instruction set architecture name parsed from the input.

Definition at line 151 of file BinaryVxcoreParser.h.

Member Data Documentation

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

Diagnostic facility for vxcore file format.

Definition at line 85 of file BinaryVxcoreParser.h.


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