本文整理汇总了C++中Mapping::init方法的典型用法代码示例。如果您正苦于以下问题:C++ Mapping::init方法的具体用法?C++ Mapping::init怎么用?C++ Mapping::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mapping
的用法示例。
在下文中一共展示了Mapping::init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
int
main(int argc, char *argv[])
{
if (argc < 2)
errx(1, "not enough arguments");
Mapping mapping;
if (mapping.init(argv[1]) < 0)
err(1, "loading %s", argv[1]);
const struct hash_head *heads = mapping.get<hash_head>(0, NR_HASH_HEADS);
for (unsigned head_idx = 0; head_idx < NR_HASH_HEADS; head_idx++) {
const struct hash_head *head = &heads[head_idx];
unsigned chain_length = 0;
unsigned long he_offset;
const hash_entry *he;
he = NULL;
for (he_offset = head->offset; he_offset != 0; ) {
he = mapping.get<hash_entry>(he_offset);
he_offset = he->chain;
chain_length++;
}
for (unsigned x = 0; x < chain_length; x++)
printf("%d\n", x + 1);
}
return 0;
}
示例2: Oracle
int
main(int argc, char *argv[])
{
init_sli();
if (argc != 6)
errx(1, "bad arguments");
const char *binary = argv[1];
const char *types = argv[2];
const char *callgraph = argv[3];
const char *staticdb = argv[4];
const char *trace_file = argv[5];
Mapping traces;
if (traces.init(trace_file) < 0)
err(1, "mapping %s", trace_file);
VexPtr<Oracle> oracle;
{
MachineState *ms = MachineState::readELFExec(binary);
Thread *thr = ms->findThread(ThreadId(1));
oracle = new Oracle(ms, thr, types);
}
oracle->loadCallGraph(oracle, callgraph, staticdb, ALLOW_GC);
success_log = fopen("success.txt", "w");
fail_log = fopen("fail.txt", "w");
invalid_log = fopen("invalid.txt", "w");
if (!success_log || !fail_log || !invalid_log)
err(1, "opening one of the log files");
unsigned long offset;
long cntr = 0;
offset = 0;
while (1) {
const unsigned long *magic = traces.get<unsigned long>(offset);
if (!magic)
break;
if (*magic != 0xaabbccddeeff8844ul)
errx(1, "bad magic number in traces file");
offset += 8;
std::vector<unsigned long> trace;
while (1) {
const unsigned long *slot = traces.get<unsigned long>(offset);
if (!slot)
break;
if (*slot == 0xaabbccddeeff8844ul)
break;
trace.push_back(*slot);
offset += 8;
}
validate_trace(oracle, trace);
cntr++;
assert(cntr == nr_success + nr_fail + nr_invalid);
printf("Done %ld (%f%%). %f%% success, %f%% invalid, %f%% failed\n",
cntr,
(offset * 100.0) / traces.size,
(double)nr_success / cntr * 100,
(double)nr_invalid / cntr * 100,
(double)nr_fail / cntr * 100);
}
return 0;
}