示例#1
0
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
0
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;
}