Search in sources :

Example 21 with RegisterValue

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

the class CStackMemoryProviderTest method testStackPointer.

@Test
public void testStackPointer() throws DebugExceptionWrapper {
    m_provider.setDebugger(m_debugger);
    assertEquals(-1, m_provider.getStackPointer());
    m_debugger.connect();
    assertEquals(-1, m_provider.getStackPointer());
    final TargetProcessThread thread = new TargetProcessThread(0, ThreadState.SUSPENDED);
    thread.setRegisterValues(Lists.newArrayList(new RegisterValue("esp", BigInteger.valueOf(0x123), new byte[0], false, true)));
    m_provider.setActiveThread(thread);
    assertEquals(0x123, m_provider.getStackPointer());
}
Also used : RegisterValue(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) Test(org.junit.Test)

Example 22 with RegisterValue

use of com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue 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

RegisterValue (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue)22 Test (org.junit.Test)16 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)14 ThreadRegisters (com.google.security.zynamics.binnavi.debug.models.targetinformation.ThreadRegisters)14 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)13 RegisterValues (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues)9 RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)9 MemoryMap (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap)6 MemorySection (com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection)6 BigInteger (java.math.BigInteger)6 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 StepBreakpointsRemovedReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.StepBreakpointsRemovedReply)4 BreakpointConditionSetReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.BreakpointConditionSetReply)3 EchoBreakpointSetReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointSetReply)3 EchoBreakpointsRemovedReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointsRemovedReply)3 TargetInformationReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.TargetInformationReply)3 ProcessManager (com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager)3 DebuggerOptions (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions)3