use of com.google.security.zynamics.binnavi.debug.connection.packets.replies.ThreadClosedReply in project binnavi by google.
the class CDebuggerSynchronizerTest method testThreadClosed.
@Test
public void testThreadClosed() throws DebugExceptionWrapper {
mockDebugger.connect();
debuggerSynchronizer.receivedEvent(new ThreadCreatedReply(0, 0, 18, ThreadState.RUNNING));
assertEquals(1, mockDebugger.getProcessManager().getThreads().size());
debuggerSynchronizer.receivedEvent(new ThreadClosedReply(0, 0, 18));
assertEquals(0, mockDebugger.getProcessManager().getThreads().size());
}
use of com.google.security.zynamics.binnavi.debug.connection.packets.replies.ThreadClosedReply in project binnavi by google.
the class DebuggerTest method testListeners3.
@SuppressWarnings("unchecked")
@Test
public void testListeners3() throws MessageParserException, DebugExceptionWrapper, MaybeNullException {
mockDebugger.connect();
mockDebugger.getProcessManager().addThread(new TargetProcessThread(0, ThreadState.RUNNING));
mockDebugger.getProcessManager().getThread(0).setCurrentAddress(new RelocatedAddress(new CAddress(0)));
mockDebugger.connection.m_synchronizer.receivedEvent(new ResumeThreadReply(0, 0, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new ResumeThreadReply(0, 1, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new SearchReply(0, 0, new CAddress(0)));
mockDebugger.connection.m_synchronizer.receivedEvent(new SearchReply(0, 1, null));
mockDebugger.connection.m_synchronizer.receivedEvent(new SelectFileReply(0, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new SelectFileReply(0, 1));
mockDebugger.getProcessManager().addThread(new TargetProcessThread(0, ThreadState.RUNNING));
mockDebugger.getProcessManager().getThread(0).setCurrentAddress(new RelocatedAddress(new CAddress(0)));
mockDebugger.connection.m_synchronizer.receivedEvent(new SetRegisterReply(0, 0, 0, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new SetRegisterReply(0, 1, 0, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new SingleStepReply(0, 0, 0, new RelocatedAddress(new CAddress(0)), new RegisterValues(new FilledList<ThreadRegisters>())));
mockDebugger.connection.m_synchronizer.receivedEvent(new SingleStepReply(0, 1, 0, new RelocatedAddress(new CAddress(0)), new RegisterValues(new FilledList<ThreadRegisters>())));
mockDebugger.connection.m_synchronizer.receivedEvent(new StepBreakpointHitReply(0, 0, 1, new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(1, Lists.newArrayList(new RegisterValue("eip", BigInteger.ONE, new byte[0], false, false)))))));
mockDebugger.connection.m_synchronizer.receivedEvent(new StepBreakpointHitReply(0, 0, 1, new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(1, Lists.newArrayList(new RegisterValue("eip", BigInteger.ONE, new byte[0], true, false)))))));
mockDebugger.getBreakpointManager().addBreakpoints(BreakpointType.STEP, CommonTestObjects.BP_ADDRESS_123_SET);
mockDebugger.connection.m_synchronizer.receivedEvent(new StepBreakpointSetReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_123_RELOC, 0))));
mockDebugger.connection.m_synchronizer.receivedEvent(new StepBreakpointSetReply(0, 1, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_123_RELOC, 1))));
mockDebugger.connection.m_synchronizer.receivedEvent(new StepBreakpointsRemovedReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_123_RELOC, 0))));
mockDebugger.connection.m_synchronizer.receivedEvent(new StepBreakpointsRemovedReply(0, 1, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_123_RELOC, 1))));
mockDebugger.connection.m_synchronizer.receivedEvent(new SuspendThreadReply(0, 0, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new SuspendThreadReply(0, 1, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new TargetInformationReply(0, 0, TargetInformationParser.parse("<foo><size>32</size><registers></registers><options></options></foo>".getBytes())));
mockDebugger.connection.m_synchronizer.receivedEvent(new TargetInformationReply(0, 1, null));
mockDebugger.getProcessManager().addThread(new TargetProcessThread(0, ThreadState.RUNNING));
mockDebugger.connection.m_synchronizer.receivedEvent(new ThreadClosedReply(0, 0, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new ThreadClosedReply(0, 1, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new ThreadCreatedReply(0, 0, 0, ThreadState.RUNNING));
mockDebugger.connection.m_synchronizer.receivedEvent(new ThreadCreatedReply(0, 1, 0, null));
mockDebugger.connection.m_synchronizer.receivedEvent(new ValidateMemoryReply(0, 0, new CAddress(0), new CAddress(0)));
mockDebugger.connection.m_synchronizer.receivedEvent(new ValidateMemoryReply(0, 1, null, null));
mockDebugger.connection.m_synchronizer.receivedEvent(new WriteMemoryReply(0, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new WriteMemoryReply(0, 1));
mockDebugger.connection.m_synchronizer.receivedEvent(new TerminateReply(0, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new TerminateReply(0, 1));
}
use of com.google.security.zynamics.binnavi.debug.connection.packets.replies.ThreadClosedReply in project binnavi by google.
the class CHistoryStringBuilderTest method testComplete3.
@SuppressWarnings("unchecked")
@Test
public void testComplete3() throws DebugExceptionWrapper, ParserConfigurationException, SAXException, IOException, MessageParserException, MaybeNullException {
final CHistoryStringBuilder builder = new CHistoryStringBuilder();
builder.setDebugger(m_debugger);
m_debugger.connect();
m_synchronizer.receivedEvent(DebuggerMessageBuilder.buildProcessStartReply(mockMemoryModule));
m_debugger.getProcessManager().setTargetInformation(new TargetInformation(5, Lists.newArrayList(new RegisterDescription("eax", 4, true), new RegisterDescription("ebx", 4, false)), new DebuggerOptions(false, false, false, false, false, false, false, false, false, false, 12, 0, new ArrayList<DebuggerException>(), false, false, false)));
m_debugger.getProcessManager().addThread(new TargetProcessThread(1, ThreadState.RUNNING));
m_synchronizer.receivedEvent(new BreakpointConditionSetReply(0, 0));
m_synchronizer.receivedEvent(new BreakpointConditionSetReply(0, 1));
m_synchronizer.receivedEvent(new EchoBreakpointHitReply(0, 0, 1, new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(1, Lists.newArrayList(new RegisterValue("eip", BigInteger.ONE, new byte[0], false, false)))))));
m_synchronizer.receivedEvent(new EchoBreakpointHitReply(0, 0, 1, new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(1, Lists.newArrayList(new RegisterValue("eip", BigInteger.ONE, new byte[0], true, false)))))));
m_debugger.getProcessManager().addThread(new TargetProcessThread(0, ThreadState.RUNNING));
m_debugger.getProcessManager().getThread(0).setCurrentAddress(new RelocatedAddress(new CAddress(0)));
m_debugger.getBreakpointManager().addBreakpoints(BreakpointType.ECHO, BREAKPOINT_ADDRESS);
m_synchronizer.receivedEvent(new EchoBreakpointSetReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(BREAKPOINT_ADDRESS_RELOC, 0))));
m_synchronizer.receivedEvent(new EchoBreakpointSetReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(BREAKPOINT_ADDRESS_RELOC, 1))));
m_synchronizer.receivedEvent(new EchoBreakpointsRemovedReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(BREAKPOINT_ADDRESS_RELOC, 0))));
m_synchronizer.receivedEvent(new EchoBreakpointsRemovedReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(BREAKPOINT_ADDRESS_RELOC, 1))));
m_synchronizer.receivedEvent(new ExceptionOccurredReply(0, 0, 0, 0, new RelocatedAddress(new CAddress(0)), "Test exception"));
m_synchronizer.receivedEvent(new HaltReply(0, 0, 0));
m_synchronizer.receivedEvent(new HaltReply(0, 0, 1));
m_synchronizer.receivedEvent(new ListFilesReply(0, 0, RemoteFileSystem.parse("<foo></foo>".getBytes())));
m_synchronizer.receivedEvent(new ListFilesReply(0, 1, null));
m_synchronizer.receivedEvent(new ListProcessesReply(0, 0, ProcessList.parse("<foo></foo>".getBytes())));
m_synchronizer.receivedEvent(new ListProcessesReply(0, 1, null));
m_synchronizer.receivedEvent(new MemoryMapReply(0, 0, new MemoryMap(new ArrayList<MemorySection>())));
m_synchronizer.receivedEvent(new MemoryMapReply(0, 1, null));
m_synchronizer.receivedEvent(new ModuleLoadedReply(0, 0, new MemoryModule("XXX", "YYYXXX", new RelocatedAddress(new CAddress(0)), 0), new TargetProcessThread(123, ThreadState.SUSPENDED)));
m_synchronizer.receivedEvent(new ModuleUnloadedReply(0, 0, new MemoryModule("XXX", "YYYXXX", new RelocatedAddress(new CAddress(0)), 0)));
m_synchronizer.receivedEvent(new ProcessClosedReply(0, 0));
m_synchronizer.receivedEvent(new ReadMemoryReply(0, 0, new CAddress(0), new byte[8]));
m_synchronizer.receivedEvent(new ReadMemoryReply(0, 1, null, null));
m_synchronizer.receivedEvent(new RegistersReply(0, 0, new RegisterValues(new FilledList<ThreadRegisters>())));
m_synchronizer.receivedEvent(new RegistersReply(0, 1, null));
m_synchronizer.receivedEvent(new RequestTargetReply(0, 0));
m_synchronizer.receivedEvent(new RequestTargetReply(0, 1));
m_synchronizer.receivedEvent(new ResumeReply(0, 0));
m_synchronizer.receivedEvent(new ResumeReply(0, 1));
m_debugger.connect();
m_debugger.getProcessManager().addThread(new TargetProcessThread(0, ThreadState.RUNNING));
m_debugger.getProcessManager().getThread(0).setCurrentAddress(new RelocatedAddress(new CAddress(0)));
m_synchronizer.receivedEvent(new ResumeThreadReply(0, 0, 0));
m_synchronizer.receivedEvent(new ResumeThreadReply(0, 1, 0));
m_synchronizer.receivedEvent(new SearchReply(0, 0, new CAddress(0)));
m_synchronizer.receivedEvent(new SearchReply(0, 1, null));
m_synchronizer.receivedEvent(new SelectFileReply(0, 0));
m_synchronizer.receivedEvent(new SelectFileReply(0, 1));
m_debugger.getProcessManager().addThread(new TargetProcessThread(0, ThreadState.RUNNING));
m_debugger.getProcessManager().getThread(0).setCurrentAddress(new RelocatedAddress(new CAddress(0)));
m_synchronizer.receivedEvent(new SetRegisterReply(0, 0, 0, 0));
m_synchronizer.receivedEvent(new SetRegisterReply(0, 1, 0, 0));
m_synchronizer.receivedEvent(new SingleStepReply(0, 0, 0, new RelocatedAddress(new CAddress(0)), new RegisterValues(new FilledList<ThreadRegisters>())));
m_synchronizer.receivedEvent(new SingleStepReply(0, 1, 0, new RelocatedAddress(new CAddress(0)), new RegisterValues(new FilledList<ThreadRegisters>())));
m_synchronizer.receivedEvent(new StepBreakpointHitReply(0, 0, 1, new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(1, Lists.newArrayList(new RegisterValue("eip", BigInteger.ONE, new byte[0], false, false)))))));
m_synchronizer.receivedEvent(new StepBreakpointHitReply(0, 0, 1, new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(1, Lists.newArrayList(new RegisterValue("eip", BigInteger.ONE, new byte[0], true, false)))))));
m_debugger.getBreakpointManager().addBreakpoints(BreakpointType.STEP, BREAKPOINT_ADDRESS);
m_synchronizer.receivedEvent(new StepBreakpointSetReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(BREAKPOINT_ADDRESS_RELOC, 0))));
m_synchronizer.receivedEvent(new StepBreakpointSetReply(0, 1, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(BREAKPOINT_ADDRESS_RELOC, 1))));
m_synchronizer.receivedEvent(new StepBreakpointsRemovedReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(BREAKPOINT_ADDRESS_RELOC, 0))));
m_synchronizer.receivedEvent(new StepBreakpointsRemovedReply(0, 1, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(BREAKPOINT_ADDRESS_RELOC, 1))));
m_synchronizer.receivedEvent(new SuspendThreadReply(0, 0, 0));
m_synchronizer.receivedEvent(new SuspendThreadReply(0, 1, 0));
m_synchronizer.receivedEvent(new TargetInformationReply(0, 0, TargetInformationParser.parse("<foo><size>32</size><registers></registers><options></options></foo>".getBytes())));
m_synchronizer.receivedEvent(new TargetInformationReply(0, 1, null));
m_debugger.getProcessManager().addThread(new TargetProcessThread(0, ThreadState.RUNNING));
m_synchronizer.receivedEvent(new ThreadClosedReply(0, 0, 0));
m_synchronizer.receivedEvent(new ThreadClosedReply(0, 1, 0));
m_synchronizer.receivedEvent(new ThreadCreatedReply(0, 0, 0, ThreadState.RUNNING));
m_synchronizer.receivedEvent(new ThreadCreatedReply(0, 1, 0, null));
m_synchronizer.receivedEvent(new ValidateMemoryReply(0, 0, new CAddress(0), new CAddress(0)));
m_synchronizer.receivedEvent(new ValidateMemoryReply(0, 1, null, null));
m_synchronizer.receivedEvent(new WriteMemoryReply(0, 0));
m_synchronizer.receivedEvent(new WriteMemoryReply(0, 1));
m_synchronizer.receivedEvent(new TerminateReply(0, 0));
m_synchronizer.receivedEvent(new TerminateReply(0, 1));
}
use of com.google.security.zynamics.binnavi.debug.connection.packets.replies.ThreadClosedReply in project binnavi by google.
the class CDebuggerSynchronizerTest method testInfoString_Wellformed.
@Test
public void testInfoString_Wellformed() throws DebugExceptionWrapper, MaybeNullException {
// Set breakpoints while the debugger is not connected
breakpointManager.addBreakpoints(BreakpointType.REGULAR, CommonTestObjects.BP_ADDRESS_123_SET);
breakpointManager.addBreakpoints(BreakpointType.REGULAR, CommonTestObjects.BP_ADDRESS_456_SET);
breakpointManager.setBreakpointStatus(CommonTestObjects.BP_ADDRESS_456_SET, BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_DISABLED);
assertEquals(BreakpointStatus.BREAKPOINT_INACTIVE, breakpointManager.getBreakpointStatus(BreakpointType.REGULAR, 0));
mockDebugger.connect();
debuggerSynchronizer.receivedEvent(DebuggerMessageBuilder.buildProcessStartReply(CommonTestObjects.MEMORY_MODULE));
assertEquals(0, listener.exception);
assertNotNull(mockDebugger.getProcessManager().getThread(CommonTestObjects.THREAD_ID));
assertEquals(ThreadState.RUNNING, mockDebugger.getProcessManager().getThread(CommonTestObjects.THREAD_ID).getState());
debuggerSynchronizer.receivedEvent(new ThreadClosedReply(0, 0, CommonTestObjects.THREAD_ID));
try {
mockDebugger.getProcessManager().getThread(CommonTestObjects.THREAD_ID);
fail();
} catch (final MaybeNullException exception) {
CUtilityFunctions.logException(exception);
}
// On receiving an info string we request the memory map and the thread created reply triggers
// read registers
assertEquals("CONNECT;READREGS;SET_BREAKPOINTS/" + String.format("%08d", CommonTestObjects.THREAD_ID) + "/REGULAR;RESUME;", mockDebugger.requests);
// Enabled breakpoints are activated
assertEquals(BreakpointStatus.BREAKPOINT_ENABLED, breakpointManager.getBreakpointStatus(BreakpointType.REGULAR, 0));
assertEquals(BreakpointStatus.BREAKPOINT_DISABLED, breakpointManager.getBreakpointStatus(BreakpointType.REGULAR, 1));
}
Aggregations