Search in sources :

Example 71 with ModuleTargetSettings

use of com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings in project binnavi by google.

the class CMemoryRefreshButtonSynchronizerTest method testThreads.

@Test
public void testThreads() throws DebugExceptionWrapper {
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    debugger.connect();
    debugger.getProcessManager().setAttached(true);
    final TargetProcessThread thread = new TargetProcessThread(1, ThreadState.RUNNING);
    m_model.setActiveDebugger(debugger);
    debugger.getProcessManager().setActiveThread(null);
    assertFalse(m_refreshButton.isEnabled());
    debugger.getProcessManager().addThread(thread);
    assertFalse(m_refreshButton.isEnabled());
    debugger.getProcessManager().setActiveThread(thread);
    assertTrue(m_refreshButton.isEnabled());
    debugger.getProcessManager().setActiveThread(null);
    assertFalse(m_refreshButton.isEnabled());
    debugger.getProcessManager().removeThread(thread);
    assertFalse(m_refreshButton.isEnabled());
    debugger.getProcessManager().setAttached(false);
    m_synchronizer.dispose();
    debugger.close();
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) Test(org.junit.Test)

Example 72 with ModuleTargetSettings

use of com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings in project binnavi by google.

the class CMemoryRefreshButtonSynchronizerTest method testReceiveTargetInformation.

@Test
public void testReceiveTargetInformation() throws DebugExceptionWrapper {
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    debugger.connect();
    m_model.setActiveDebugger(debugger);
    debugger.connection.m_synchronizer.receivedEvent(new TargetInformationReply(0, 0, new TargetInformation(32, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, false, false, true, false, false, false, false, 1, 0, new ArrayList<DebuggerException>(), false, false, false))));
    assertFalse(m_refreshButton.isEnabled());
    assertEquals(m_defaultAction, m_refreshButton.getAction());
    debugger.connection.m_synchronizer.receivedEvent(new TargetInformationReply(0, 0, new TargetInformation(32, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, false, false, false, false, false, false, false, 1, 0, new ArrayList<DebuggerException>(), false, false, false))));
    assertFalse(m_refreshButton.isEnabled());
    assertEquals(m_askAction, m_refreshButton.getAction());
    m_synchronizer.dispose();
    debugger.close();
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) RegisterDescription(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription) TargetInformation(com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation) ArrayList(java.util.ArrayList) DebuggerOptions(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) TargetInformationReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.TargetInformationReply) Test(org.junit.Test)

Example 73 with ModuleTargetSettings

use of com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings in project binnavi by google.

the class CDebuggerSynchronizerTest method setUp.

@Before
public void setUp() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
    mockDebugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    mockDebugger.setAddressTranslator(CommonTestObjects.MODULE, new CAddress(0), new CAddress(0x1000));
    breakpointManager = mockDebugger.getBreakpointManager();
    debuggerSynchronizer = new DebuggerSynchronizer(mockDebugger);
    debuggerSynchronizer.addListener(listener);
    // assign the synchronizer to the internally used one by the debugger so we can test the
    // synchronizer itself
    // as well as the combination of synchronizer and debugger
    final Field synchronizerField = AbstractDebugger.class.getDeclaredField("synchronizer");
    synchronizerField.setAccessible(true);
    synchronizerField.set(mockDebugger, debuggerSynchronizer);
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) DebuggerSynchronizer(com.google.security.zynamics.binnavi.debug.debugger.synchronizers.DebuggerSynchronizer) Field(java.lang.reflect.Field) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Before(org.junit.Before)

Aggregations

ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)73 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)65 Test (org.junit.Test)63 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)51 DebuggerProvider (com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider)21 DebugTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings)20 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)20 ArrayList (java.util.ArrayList)19 DebuggerOptions (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions)18 TargetInformation (com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation)18 MemoryMap (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap)17 MemorySection (com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection)17 RegisterDescription (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription)17 TargetInformationReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.TargetInformationReply)16 MemoryMapReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.MemoryMapReply)15 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)15 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)15 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)14 Breakpoint (com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint)11 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)10