本文整理汇总了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));
}
}