本文整理汇总了C++中rose::binaryanalysis::partitioner2::Engine::parseContainers方法的典型用法代码示例。如果您正苦于以下问题:C++ Engine::parseContainers方法的具体用法?C++ Engine::parseContainers怎么用?C++ Engine::parseContainers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rose::binaryanalysis::partitioner2::Engine
的用法示例。
在下文中一共展示了Engine::parseContainers方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runtime_error
int
main(int argc, char *argv[]) {
Diagnostics::initialize();
mlog = Sawyer::Message::Facility("tool");
Diagnostics::mfacilities.insertAndAdjust(mlog);
// Parse command-line
P2::Engine engine;
Settings settings;
std::vector<std::string> specimenNames = parseCommandLine(argc, argv, settings).unreachedArgs();
if (specimenNames.size() != 1)
throw std::runtime_error("exactly one binary specimen file should be specified; see --help");
std::string specimenName = boost::starts_with(specimenNames[0], "run:") ? specimenNames[0].substr(4) : specimenNames[0];
Stream info(mlog[INFO]);
// Parse, map, link, and/or relocate
info <<"performing parse, map, and optional link steps";
engine.parseContainers(specimenNames);
Sawyer::Stopwatch loadTimer;
if (settings.performLink) {
BinaryLoader *loader = engine.obtainLoader();
ASSERT_not_null(loader);
loader->set_perform_dynamic_linking(true);
#if 0 // [Robb P. Matzke 2014-10-09]: not always working, but maybe not needed for this analysis
loader->set_perform_relocations(true);
#endif
BOOST_FOREACH (const std::string &paths, settings.libDirs) {
BOOST_FOREACH (const std::string &path, split(':', paths)) {
loader->add_directory(path);
}
}
}
示例2: debugger
int
main(int argc, char *argv[]) {
ROSE_INITIALIZE;
Diagnostics::initAndRegister(&::mlog, "tool");
// Parse command-line
P2::Engine engine;
Settings settings;
std::vector<std::string> specimen = parseCommandLine(argc, argv, engine, settings);
if (specimen.empty()) {
::mlog[FATAL] <<"no specimen supplied on command-line; see --help\n";
exit(1);
}
// Load specimen into ROSE's simulated memory
if (!engine.parseContainers(specimen.front())) {
::mlog[FATAL] <<"cannot parse specimen binary container\n";
exit(1);
}
Disassembler *disassembler = engine.obtainDisassembler();
if (!disassembler) {
::mlog[FATAL] <<"no disassembler for this architecture\n";
exit(1);
}
const RegisterDescriptor REG_IP = disassembler->instructionPointerRegister();
ASSERT_require2(REG_IP.is_valid(), "simulation must know what register serves as the instruction pointer");
// Single-step the specimen natively in a debugger and show each instruction.
BinaryDebugger debugger(specimen);
while (!debugger.isTerminated()) {
uint64_t ip = debugger.readRegister(REG_IP).toInteger();
uint8_t buf[16]; // 16 should be large enough for any instruction
size_t nBytes = debugger.readMemory(ip, sizeof buf, buf);
if (0 == nBytes) {
::mlog[ERROR] <<"cannot read memory at " <<StringUtility::addrToString(ip) <<"\n";
} else if (SgAsmInstruction *insn = disassembler->disassembleOne(buf, ip, nBytes, ip)) {
std::cout <<unparseInstructionWithAddress(insn) <<"\n";
} else {
::mlog[ERROR] <<"cannot disassemble instruction at " <<StringUtility::addrToString(ip) <<"\n";
}
debugger.singleStep();
}
std::cout <<debugger.howTerminated();
}