Search in sources :

Example 16 with RegisterValues

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

Example 17 with RegisterValues

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

the class CRegisterValuesParserTest method test3.

@Test
public void test3() throws MessageParserException {
    final RegisterValues information = RegisterValuesParser.parse("<Registers><Thread id=\"3607910890\"><Register name=\"R0\" value=\"0\" memory=\"\"/><Register name=\"R1\" value=\"96722c80\" memory=\"\"/><Register name=\"R2\" value=\"6000001f\" memory=\"\"/><Register name=\"R3\" value=\"ffffc800\" memory=\"\"/><Register name=\"R4\" value=\"2\" memory=\"\"/><Register name=\"R5\" value=\"96101c30\" memory=\"\"/><Register name=\"R6\" value=\"0\" memory=\"\"/><Register name=\"R7\" value=\"0\" memory=\"\"/><Register name=\"R8\" value=\"ffffc894\" memory=\"\"/><Register name=\"R9\" value=\"964c1e70\" memory=\"\"/><Register name=\"R10\" value=\"1\" memory=\"\"/><Register name=\"R11\" value=\"9661f2b4\" memory=\"\"/><Register name=\"R12\" value=\"88045644\" memory=\"\"/><Register name=\"R13(SP)\" value=\"3e02fdf4\" memory=\"\" sp=\"true\"/><Register name=\"R14(LR)\" value=\"88045644\" memory=\"\"/><Register name=\"R15(PC)\" value=\"88045644\"  memory=\"\" pc=\"true\"/><Register name=\"R16(PSR)\" value=\"6000001f\" memory=\"\"/></Thread></Registers>".getBytes());
    assertEquals(3607910890L, information.getThreads().get(0).getTid());
}
Also used : RegisterValues(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues) Test(org.junit.Test)

Aggregations

RegisterValues (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues)17 ThreadRegisters (com.google.security.zynamics.binnavi.debug.models.targetinformation.ThreadRegisters)11 Test (org.junit.Test)10 RegisterValue (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue)9 RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)9 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)8 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)7 EchoBreakpointHitReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointHitReply)6 StepBreakpointHitReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.StepBreakpointHitReply)6 BigInteger (java.math.BigInteger)6 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 BreakpointHitReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.BreakpointHitReply)3 SingleStepReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.SingleStepReply)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