Search in sources :

Example 16 with ThreadRegisters

use of com.google.security.zynamics.binnavi.debug.models.targetinformation.ThreadRegisters in project binnavi by google.

the class CDebuggerSynchronizerTest method testStepBreakpointLifecycle.

/**
   * This test is used to determine whether the step breakpoint lifecycle (Set Step BP -> Hit Step
   * BP -> Remove Step BP) works correctly.
   *
   * @throws DebugExceptionWrapper Thrown if something goes wrong.
   */
@SuppressWarnings("unchecked")
@Test
public void testStepBreakpointLifecycle() throws DebugExceptionWrapper {
    mockDebugger.connect();
    final TargetProcessThread thread = new TargetProcessThread(0, ThreadState.RUNNING);
    mockDebugger.getProcessManager().addThread(thread);
    mockDebugger.getBreakpointManager().addBreakpoints(BreakpointType.STEP, CommonTestObjects.BP_ADDRESS_123_SET);
    mockDebugger.getBreakpointManager().addBreakpoints(BreakpointType.STEP, CommonTestObjects.BP_ADDRESS_456_SET);
    debuggerSynchronizer.receivedEvent(new StepBreakpointSetReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_123_RELOC, 0), new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_456_RELOC, 0))));
    assertEquals(BreakpointStatus.BREAKPOINT_ACTIVE, mockDebugger.getBreakpointManager().getBreakpointStatus(CommonTestObjects.BP_ADDRESS_123, BreakpointType.STEP));
    assertEquals(BreakpointStatus.BREAKPOINT_ACTIVE, mockDebugger.getBreakpointManager().getBreakpointStatus(CommonTestObjects.BP_ADDRESS_456, BreakpointType.STEP));
    final RegisterValues registerValues = new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(0, Lists.newArrayList(new RegisterValue("esp", BigInteger.valueOf(0x123), new byte[0], true, false)))));
    debuggerSynchronizer.receivedEvent(new StepBreakpointHitReply(0, 0, 0, registerValues));
    listener.toString();
    assertTrue(Iterables.isEmpty(mockDebugger.getBreakpointManager().getBreakpoints(BreakpointType.STEP)));
    assertEquals(thread, mockDebugger.getProcessManager().getActiveThread());
    assertEquals(0x123, thread.getCurrentAddress().getAddress().toLong());
}
Also used : BigInteger(java.math.BigInteger) RegisterValue(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue) StepBreakpointSetReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.StepBreakpointSetReply) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) StepBreakpointHitReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.StepBreakpointHitReply) ThreadRegisters(com.google.security.zynamics.binnavi.debug.models.targetinformation.ThreadRegisters) RegisterValues(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues) Test(org.junit.Test)

Aggregations

ThreadRegisters (com.google.security.zynamics.binnavi.debug.models.targetinformation.ThreadRegisters)16 RegisterValue (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue)14 RegisterValues (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues)11 RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)10 Test (org.junit.Test)10 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)9 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)9 BigInteger (java.math.BigInteger)7 EchoBreakpointHitReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointHitReply)5 StepBreakpointHitReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.StepBreakpointHitReply)5 StepBreakpointSetReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.StepBreakpointSetReply)5 EchoBreakpointSetReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointSetReply)4 EchoBreakpointsRemovedReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointsRemovedReply)4 StepBreakpointsRemovedReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.StepBreakpointsRemovedReply)4 BreakpointConditionSetReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.BreakpointConditionSetReply)3 Address (com.google.security.zynamics.binnavi.API.disassembly.Address)2 Trace (com.google.security.zynamics.binnavi.API.disassembly.Trace)2 TracePoint (com.google.security.zynamics.binnavi.API.disassembly.TracePoint)2 ExceptionOccurredReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.ExceptionOccurredReply)2 HaltReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.HaltReply)2