1#ifndef ROSE_BinaryAnalysis_VxcoreParser_H
2#define ROSE_BinaryAnalysis_VxcoreParser_H
4#include <featureTests.h>
5#ifdef ROSE_ENABLE_BINARY_ANALYSIS
7#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/RegisterState.h>
8#include <boost/filesystem.hpp>
9#include <boost/lexical_cast.hpp>
10#include <Rose/Diagnostics.h>
11#include <Rose/BinaryAnalysis/MemoryMap.h>
12#include <Rose/StringUtility.h>
15namespace BinaryAnalysis {
61 boost::filesystem::path fileName_;
66 Exception(
const boost::filesystem::path &fileName,
size_t offset,
const std::string &what)
67 :
Rose::
Exception(what), fileName_(fileName), offset_(offset) {}
73 return StringUtility::cEscape(fileName_.string()) +
":" + boost::lexical_cast<std::string>(offset_) +
": " + what();
79 void print(std::ostream &out)
const {
83 friend std::ostream& operator<<(std::ostream &out,
const Exception &e) {
91 struct HeaderVersion2 {
102 std::string isaName_;
106 static void initDiagnostics();
123 boost::filesystem::path
parseUrl(
const std::string&);
158 const std::string &outputName =
"output");
161 const std::string &outputName =
"output");
165 const std::string &outputName =
"output");
171 const std::string&
isaName()
const {
return isaName_; }
178 bool parseMemory(
const std::string &header, std::istream&,
const MemoryMap::Ptr&,
const std::string &inputName,
179 size_t headerOffset);
184 const std::string &inputName,
size_t headerOffset);
Exception thrown for parse errors.
Exception(const boost::filesystem::path &fileName, size_t offset, const std::string &what)
Create a new exception with a location and error message.
void print(std::ostream &out) const
Emit this exception to a stream.
std::string toString() const
Render this exception as a string.
Parser for Vxcore format files.
const std::string & isaName() const
Parsed instruction set architecture name.
const Settings & settings() const
Property: Settings for parsing and unparsing.
void settings(const Settings &s)
Property: Settings for parsing and unparsing.
static Sawyer::Message::Facility mlog
Diagnostic facility for vxcore file format.
void parse(std::istream &, const MemoryMap::Ptr &, const InstructionSemantics::BaseSemantics::RegisterStatePtr ®isters, const InstructionSemantics::BaseSemantics::RiscOperatorsPtr &ops, const std::string &inputName="input")
Parse input file.
void unparse(std::ostream &, const MemoryMap::Ptr &, const AddressInterval &memoryLimit, const std::string &outputName="output")
Unparse memory and/or registers to this format.
void parse(const boost::filesystem::path &, const MemoryMap::Ptr &)
Parse input file.
Settings & settings()
Property: Settings for parsing and unparsing.
void unparse(std::ostream &, const InstructionSemantics::BaseSemantics::RegisterStatePtr &, const InstructionSemantics::BaseSemantics::RiscOperatorsPtr &, const std::string &outputName="output")
Unparse memory and/or registers to this format.
void parse(const boost::filesystem::path &, const MemoryMap::Ptr &, const InstructionSemantics::BaseSemantics::RegisterStatePtr ®isters, const InstructionSemantics::BaseSemantics::RiscOperatorsPtr &ops)
Parse input file.
void unparse(std::ostream &, const MemoryMap::Ptr &, const AddressInterval &memoryLimit, const InstructionSemantics::BaseSemantics::RegisterStatePtr &, const InstructionSemantics::BaseSemantics::RiscOperatorsPtr &, const std::string &outputName="output")
Unparse memory and/or registers to this format.
boost::filesystem::path parseUrl(const std::string &)
Parse a URL and adjust the settings.
void parse(const boost::filesystem::path &, const InstructionSemantics::BaseSemantics::RegisterStatePtr ®isters, const InstructionSemantics::BaseSemantics::RiscOperatorsPtr &ops)
Parse input file.
Base class for all ROSE exceptions.
Holds a value or nothing.
boost::shared_ptr< RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to a RISC operators object.
boost::shared_ptr< RegisterState > RegisterStatePtr
Shared-ownership pointer to a register state.
ROSE_UTIL_API std::string cEscape(const std::string &, char context='"')
Escapes characters that are special to C/C++.
Settings that control the parser and unparser.
unsigned version
Format version number.
unsigned protDefault
Default memory protection when none are specified or overridden.
Sawyer::Optional< unsigned > protOverride
Memory protection to overrides parsed values.