当前位置: 首页>>代码示例>>C++>>正文


C++ Disassembler::typeOfInst方法代码示例

本文整理汇总了C++中Disassembler::typeOfInst方法的典型用法代码示例。如果您正苦于以下问题:C++ Disassembler::typeOfInst方法的具体用法?C++ Disassembler::typeOfInst怎么用?C++ Disassembler::typeOfInst使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Disassembler的用法示例。


在下文中一共展示了Disassembler::typeOfInst方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: after_predict

void TwoBit::after_predict(unsigned long ip, unsigned long nextIP, bool success)
{
	Disassembler disAssem;
	unsigned int type = disAssem.typeOfInst(ip, pid);

	branchTargetBuffer[TWO_BIT_getBTBOffset(ip)] = nextIP;

	if(InstType(type) == CND_JMP)
	{
		if(success)
		{
			if(state[TWO_BIT_getBTBOffset(ip)] == TT)
				state[TWO_BIT_getBTBOffset(ip)] = TT;
			else if(state[TWO_BIT_getBTBOffset(ip)] == T)
				state[TWO_BIT_getBTBOffset(ip)] = TT;
			else if(state[TWO_BIT_getBTBOffset(ip)] == N)
				state[TWO_BIT_getBTBOffset(ip)] = T;
			else if(state[TWO_BIT_getBTBOffset(ip)] == NN)
				state[TWO_BIT_getBTBOffset(ip)] = N;
		}
		else
		{
			if(state[TWO_BIT_getBTBOffset(ip)] == TT)
				state[TWO_BIT_getBTBOffset(ip)] = T;
			else if(state[TWO_BIT_getBTBOffset(ip)] == T)
				state[TWO_BIT_getBTBOffset(ip)] = N;
			else if(state[TWO_BIT_getBTBOffset(ip)] == N)
				state[TWO_BIT_getBTBOffset(ip)] = NN;
			else if(state[TWO_BIT_getBTBOffset(ip)] == NN)
				state[TWO_BIT_getBTBOffset(ip)] = NN;
		}
	}
}
开发者ID:Holong,项目名称:BSim,代码行数:33,代码来源:2_bit.cpp

示例2: do_predict

void TwoBit::do_predict(unsigned long ip, BranchResult& result)
{
	Disassembler disAssem;
	unsigned int type = disAssem.typeOfInst(ip, pid);

	if(InstType(type) == CALL || InstType(type) == RETURN || InstType(type) == JMP)
	{
		result.setTorF(true);
		result.setJmpAddress(branchTargetBuffer[TWO_BIT_getBTBOffset(ip)]);
	}
	else
	{
		if(state[TWO_BIT_getBTBOffset(ip)] == TT || state[TWO_BIT_getBTBOffset(ip)] == T)
		{
			result.setTorF(true);
			result.setJmpAddress(branchTargetBuffer[TWO_BIT_getBTBOffset(ip)]);
		}
		else
		{
			result.setTorF(false);
		}
	}
}
开发者ID:Holong,项目名称:BSim,代码行数:23,代码来源:2_bit.cpp

示例3: main


//.........这里部分代码省略.........
						printf("%s\n", workLoad[k]);
				}
				break;				
		}
	}

	try {
		if(!loadOn)
			throw 1;
	}
	catch (int ex) {
		errExit("Not WorkLoad");
	}

	struct sigaction act;
	act.sa_handler = int_handler;
	sigemptyset(&act.sa_mask);
	act.sa_flags = 0;
	sigaction(SIGINT, &act, NULL);

	// select profiled program
	Tracer tracer(workLoad[0], &workLoad[0]);

	try {
		tracer.traceStart();
	}
	catch(int exept) {
		errExit("trace start");
	}
	
	// set Simulator
	Simul bSim(tracer.getChildPid(), disAssem, &workLoad[0]);
	pbSim = &bSim;

	// set predictor
	bSim.setPredictor(new NotTaken());
	bSim.setPredictor(new TwoBit());
	bSim.setPredictor(new Correlate());
	bSim.setPredictor(new GShare());
	bSim.setPredictor(new GShareRet());

	gettimeofday(&startTime, NULL);
	/*
	 ** Loop now, tracing the child
	 */
	while (1) {
		/*
		 ** Ok, now we will continue the child, but set the single step bit in
		 ** the psw. This will cause the child to exeute just one instruction and
		 ** trap us again. The wait(2) catches the trap.
		 */ 		
		try {
			tracer.traceSingleStep(infoRegs);
			ip = infoRegs.getRIP();
		}
		catch(int except) {
			if(errno == ESRCH) {
				cout << "Target Process is terminated...." << endl;
				break;
			}
			errMsg("Single step");
			break;
		}
		
		try {
			bSim.runSimulation(ip);
		}
		catch(int execpt) {
			errMsg("runSimulation\n");
		}

		if(debugOn)
		{
			try {
				disAssem->showInst(ip, tracer.getChildPid());
			}
			catch(int ex) {
				errMsg("showInst");
			}
		}

		if(limitInst)
		{
			if(disAssem->typeOfInst(ip, tracer.getChildPid()))
			{
				numOfBranchInst++;

				if(numOfBranchInst >= numOfLimitInst)
					break;
			}
		}
	}
	gettimeofday(&endTime, NULL);
	long endSec = (long)endTime.tv_sec * 1000000 + endTime.tv_usec;
	long startSec = (long)startTime.tv_sec * 1000000 + startTime.tv_usec;
	bSim.setTime(endSec - startSec);

	bSim.printResult(rawOn);
	return 0;
}
开发者ID:Holong,项目名称:BSim,代码行数:101,代码来源:main.cpp


注:本文中的Disassembler::typeOfInst方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。