當前位置: 首頁>>代碼示例>>C++>>正文


C++ Breakpoint::GetInstruction方法代碼示例

本文整理匯總了C++中Breakpoint::GetInstruction方法的典型用法代碼示例。如果您正苦於以下問題:C++ Breakpoint::GetInstruction方法的具體用法?C++ Breakpoint::GetInstruction怎麽用?C++ Breakpoint::GetInstruction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Breakpoint的用法示例。


在下文中一共展示了Breakpoint::GetInstruction方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: DebugLoop

void DebugThreadManager::DebugLoop(ThreadContext& context, bool autostart)
{
	context.stopReason = StopReason::InterruptTrap;
	context.executionState = ThreadState::Stopped;
	changingContexts.PutOne(ThreadUpdate(context));
	
	if (autostart)
	{
		context.Perform(RunCommand::Continue);
	}
	
	Instruction initialInstruction;
	while (context.executionState != ThreadState::Completed)
	{
		RunCommand action = context.GetNextAction();
		UInt32* location = allocator.ToPointer<UInt32>(context.pc);
		try
		{
			if (action == RunCommand::Kill)
			{
				context.pc = allocator.ToIntPtr(context.interpreter.GetEndAddress());
			}
			else if (action == RunCommand::Continue)
			{
				breakpoints->GetRealInstruction(location, initialInstruction);
				location = context.interpreter.ExecuteOne(location, initialInstruction);
				context.interpreter.Execute(location);
				context.pc = allocator.ToIntPtr(context.interpreter.GetEndAddress());
			}
			else if (action == RunCommand::SingleStep)
			{
				breakpoints->GetRealInstruction(location, initialInstruction);
				location = context.interpreter.ExecuteOne(location, initialInstruction);
				context.pc = allocator.ToIntPtr(location);
			}
			else if (action == RunCommand::StepOver)
			{
				Instruction instruction(location->Get());
				if (instruction.OPCD != 18 || instruction.LK == 0)
				{
					// step over is the same as single step, unless we step over a call instruction...
					location = context.interpreter.ExecuteOne(location);
					context.pc = allocator.ToIntPtr(location);
				}
				else
				{
					// ...then we should set a breakpoint on the next instruction, and execute until we reach it,
					// and make sure the stack is the same size (otherwise we're doing recursion).
					Breakpoint stopAtNext = breakpoints->CreateBreakpoint(&location[1]);
					uint32_t stopPC = allocator.ToIntPtr(stopAtNext.GetLocation());
					uint32_t sp = context.machineState.r1;
					do
					{
						try
						{
							// don't be stuck on the breakpoint if it's the first instruction we execute
							breakpoints->GetRealInstruction(location, initialInstruction);
							location = context.interpreter.ExecuteOne(location, stopAtNext.GetInstruction());
							context.interpreter.Execute(location);
							context.pc = allocator.ToIntPtr(context.interpreter.GetEndAddress());
							break;
						}
						catch (Execution::InterpreterException& ex)
						{
							context.pc = ex.GetPC();
							auto cause = ex.GetReason().get();
							if (dynamic_cast<TrapException*>(cause) == nullptr || context.pc != stopPC)
								throw;
						}
					} while (context.machineState.r1 != sp);
				}
			}
			
			context.executionState = context.pc == allocator.ToIntPtr(context.interpreter.GetEndAddress())
				? ThreadState::Completed
				: ThreadState::Stopped;
		}
		catch (Execution::InterpreterException& ex)
		{
			context.pc = ex.GetPC();
			context.executionState = ThreadState::Stopped;
			auto cause = ex.GetReason().get();
			if (dynamic_cast<Execution::InvalidInstructionException*>(cause))
				context.stopReason = StopReason::InvalidInstruction;
			else if (dynamic_cast<Common::AccessViolationException*>(cause))
				context.stopReason = StopReason::AccessViolation;
			else if (dynamic_cast<TrapException*>(cause))
				context.stopReason = StopReason::InterruptTrap;
		}
		
		changingContexts.PutOne(ThreadUpdate(context));
	}
}
開發者ID:jjuran,項目名稱:classix,代碼行數:93,代碼來源:DebugThreadManager.cpp


注:本文中的Breakpoint::GetInstruction方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。