コード例 #1
0
ファイル: SimplifyCFG.cpp プロジェクト: JoelMarcey/redex
void SimplifyCFGPass::run_pass(DexStoresVector& stores,
                           ConfigFiles& /* unused */,
                           PassManager& mgr) {
  const auto& scope = build_class_scope(stores);
  auto total_insns_removed =
      walk::parallel::reduce_methods<int64_t, Scope>(
          scope,
          [](DexMethod* m) -> int64_t {
            auto code = m->get_code();
            if (code == nullptr) {
              return 0;
            }

            int64_t before_insns = code->count_opcodes();

            // build and linearize the CFG
            code->build_cfg(/* editable */ true);
            code->clear_cfg();

            int64_t after_insns = code->count_opcodes();
            return before_insns - after_insns;
          },
          [](int64_t a, int64_t b) { return a + b; });
  mgr.set_metric("insns_removed", total_insns_removed);
}
コード例 #2
0
ファイル: mrbig.c プロジェクト: qbranch-code/Qbranch.MrBig
void mrbig(void)
{
	char *p;
	time_t t, lastrun;
	int sleeptime, i;
	char hostname[256];
	DWORD hostsize;

	/*
	 * install exception logging/stacktrace handler.
	 * We need to resolve the symbol at run time because windows 2000
	 * does not have it.
	 */
	do {
		HMODULE dll;
		PVOID (*ptr) (ULONG First,PVECTORED_EXCEPTION_HANDLER Handler) = NULL;
		dll = LoadLibraryEx("kernel32.dll", NULL, 0);
		if (dll == NULL)
			break;
		ptr = (typeof(ptr))GetProcAddress(dll, "AddVectoredExceptionHandler");
		if (ptr == NULL)
			break;
		ptr(1, VectoredExceptionHandler);
		mrlog("VectoredExceptionHandler handler has been installed");
	} while(0);

	if (debug) {
		mrlog("mrbig()");
	}
	for (i = 0; _environ[i]; i++) {
		startup_log("%s", _environ[i]);
	}
	for (;;) {
		if (debug) mrlog("main loop");
		read_cfg("mrbig", cfgfile);
		readcfg();
		t = time(NULL);
		strlcpy(now, ctime(&t), sizeof now);
		p = strchr(now, '\n');
		if (p) *p = '\0';
		hostsize = sizeof hostname;
		if (GetComputerName(hostname, &hostsize)) {
			for (i = 0; hostname[i]; i++)
				hostname[i] = tolower(hostname[i]);
			snprcat(now, sizeof now, " [%s]", hostname);
		}

		cpu();
		check_chunks("after cpu test");

		disk();
		check_chunks("after disk test");

		memory();
		check_chunks("after memory test");

		msgs();
		check_chunks("after msgs test");

		procs();
		check_chunks("after procs test");

		svcs();
		check_chunks("after svcs test");

		wmi();
		check_chunks("after wmi test");

		if (pickupdir[0]) ext_tests();

		lastrun = t;
		t = time(NULL);
		if (t < lastrun) {
			mrlog("mainloop: timewarp detected, sleep for %d",
				mrloop);
			sleeptime = mrloop;
		} else {
			sleeptime = mrloop-(t-lastrun);
		}
		if (sleeptime < SLEEP_MIN) sleeptime = SLEEP_MIN;
		if (debug) mrlog("started at %d, finished at %d, sleep for %d",
			(int)lastrun, (int)t, sleeptime);
		clear_cfg();
		if (debug) {
			dump_chunks();
			check_chunks("after main loop");
		}
		Sleep(sleeptime*1000);
	}
}
コード例 #3
0
ファイル: IRCode.cpp プロジェクト: facebook/redex
void IRCode::build_cfg(bool editable) {
  clear_cfg();
  m_cfg = std::make_unique<cfg::ControlFlowGraph>(
      m_ir_list, m_registers_size, editable);
}