本文整理汇总了C++中Listing::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Listing::begin方法的具体用法?C++ Listing::begin怎么用?C++ Listing::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Listing
的用法示例。
在下文中一共展示了Listing::begin方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: files
static void
list_combined(const SqlDatabase::TransactionPtr &tx, int func_id, bool show_assembly)
{
CloneDetection::FilesTable files(tx);
Events events;
gather_events(tx, func_id);
load_events(tx, func_id, events/*out*/);
gather_instructions(tx, func_id, events);
Listing listing;
gather_source_code(tx);
load_source_code(tx, listing/*out*/);
// Get lines of assembly code and insert them into the correct place in the Listing.
if (show_assembly) {
SqlDatabase::StatementPtr stmt = tx->statement("select"
// 0 1 2 3
" insn.src_file_id, insn.src_line, insn.position, insn.address,"
// 4 5 6
" insn.assembly, func.id, func.name"
" from tmp_insns as insn"
" join semantic_functions as func on insn.func_id = func.id"
" order by position");
for (SqlDatabase::Statement::iterator row=stmt->begin(); row!=stmt->end(); ++row) {
int src_file_id = row.get<int>(0);
int src_line_num = row.get<int>(1);
SourcePosition srcpos(src_file_id, src_line_num);
int pos = row.get<int>(2);
rose_addr_t addr = row.get<rose_addr_t>(3);
std::string assembly = row.get<std::string>(4);
int func_id = row.get<int>(5);
std::string func_name = row.get<std::string>(6);
listing[srcpos].assembly_code.insert(std::make_pair(addr, AssemblyCode(pos, addr, assembly, func_id, func_name)));
}
// Listing header
std::cout <<"WARNING: This listing should be read cautiously. It is ordered according to the\n"
<<" source code with assembly lines following the source code line from which\n"
<<" they came. However, the compiler does not always generate machine\n"
<<" instructions in the same order as source code. When a discontinuity\n"
<<" occurs in the assembly instruction listing, it will be marked by a \"#\"\n"
<<" character. The assembly instructions are also numbered according to\n"
<<" their relative positions in the binary function.\n"
<<"\n"
<<" The prefix area contains either source location information or test trace\n"
<<" information. Note that trace information might be incomplete because\n"
<<" tracing was disabled or only partially enabled, or the trace includes\n"
<<" instructions that are not present in this function listing (e.g., when\n"
<<" execution follows a CALL instruction). The following notes are possible:\n"
<<" * \"Nx\" where N is an integer indicates that this instruction\n"
<<" was reached N times during testing. These notes are typically\n"
<<" only attached to the first instruction of a basic block and only\n"
<<" if the trace contains EV_REACHED events. Lack of an Nx notation\n"
<<" doesn't necessarily mean that the basic block was not reached, it\n"
<<" only means that there is no EV_REACHED event for that block.\n"
<<" * \"N<\" where N is an integer indicates that the instruction\n"
<<" on the previous line consumed N inputs. Information about the\n"
<<" inputs is listed on the right side of this line.\n"
<<" * \"N>\" where N is an integer indicates that the instruction\n"
<<" on the previous line produced N memory outputs. Information about the\n"
<<" outputs is listed on the right side of this line. Only the final\n"
<<" write to a memory address is considered a true output, and such\n"
<<" writes will be marked with the string \"final\".\n"
<<" * \"BR\" indicates that the instruction on the previous line is a\n"
<<" control flow branch point. The right side of the line shows more\n"
<<" detailed information about how many times the branch was taken.\n"
<<" * \"FAULT\" indicates that the test was terminated at the previous\n"
<<" instruction. The right side of the line shows the distribution of\n"
<<" faults that occurred here.\n"
<<"\n"
<<" /------------- Prefix area\n"
<<" /-------------/-------------- Source file ID or assembly function ID\n"
<<" | /------/--------------- Source line number or assembly instruction index\n"
<<" | | /-/---------------- Instruction out-of-order indicator\n"
<<" | | |/ /----------- Instruction virtual address\n"
<<" | | | |\n"
<<"vvvv vvvvv/| |\n"
<<"vvvvvvvvvv v vvvvvvvvvv\n";
}
// Show the listing
int prev_func_id = -1, prev_position = -1;
std::set<int> seen_files;
for (Listing::iterator li=listing.begin(); li!=listing.end(); ++li) {
int file_id = li->first.file_id;
if (seen_files.insert(file_id).second) {
if (file_id>=0) {
std::cout <<"\n" <<std::setw(4) <<std::right <<file_id <<".file |"
<<(opt.colorize?"\033[33;4m":"") <<files.name(file_id) <<(opt.colorize?"\033[m":"") <<"\n";
} else {
std::cout <<"\n" <<std::string(11, ' ') <<"|"
<<(opt.colorize?"\033[33;4m":"") <<"instructions not associated with a source file"
<<(opt.colorize?"\033[m":"") <<"\n";
}
}
if (file_id>=0) {
std::cout <<std::setw(4) <<std::right <<file_id <<"." <<std::setw(6) <<std::left <<li->first.line_num
<<"|"
<<(opt.colorize?"\033[34m":"")
//.........这里部分代码省略.........