Search in sources :

Example 71 with TargetProcessThread

use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread in project binnavi by google.

the class CThreadInformationPanelTest method test2.

/**
   * This test makes sure that going from no debugger to a debugger to no debugger works fine.
   */
@Test
public void test2() throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    // CGraphModelFactory.get(database,
    final IGraphModel graphModel = new MockGraphModel();
    // viewContainer);
    final CDebugPerspectiveModel model = CDebugPerspectiveModelFactory.get(graphModel);
    final CThreadInformationPanel panel = new CThreadInformationPanel(model);
    final IDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    final TargetProcessThread thread = new TargetProcessThread(0, ThreadState.RUNNING);
    debugger.getProcessManager().addThread(thread);
    final LinkedHashSet<?> perspectiveListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(model, "m_listeners"), "m_listeners");
    final LinkedHashSet<?> debuggerListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(ReflectionHelpers.getField(AbstractDebugger.class, debugger, "processManager"), "listeners"), "m_listeners");
    final LinkedHashSet<?> threadListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(thread, "listeners"), "m_listeners");
    assertEquals(1, perspectiveListeners.size());
    assertEquals(1, debuggerListeners.size());
    assertEquals(1, threadListeners.size());
    model.setActiveDebugger(debugger);
    assertEquals(2, threadListeners.size());
    assertEquals(2, debuggerListeners.size());
    model.setActiveDebugger(null);
    assertEquals(1, threadListeners.size());
    assertEquals(1, debuggerListeners.size());
    assertEquals(1, perspectiveListeners.size());
    panel.dispose();
    assertEquals(1, threadListeners.size());
    assertEquals(1, debuggerListeners.size());
    assertEquals(0, perspectiveListeners.size());
}
Also used : LinkedHashSet(java.util.LinkedHashSet) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) CDebugPerspectiveModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.Panels.CDebugPerspectiveModel) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) AbstractDebugger(com.google.security.zynamics.binnavi.debug.debugger.AbstractDebugger) IGraphModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphModel) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) MockGraphModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.MockGraphModel) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) Test(org.junit.Test)

Example 72 with TargetProcessThread

use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread in project binnavi by google.

the class CThreadInformationTableTest method test.

@Test
public void test() {
    final CThreadInformationTable table = new CThreadInformationTable();
    final TargetProcessThread thread = new TargetProcessThread(0, ThreadState.RUNNING);
    assertEquals(0, table.getModel().getRowCount());
    table.getModel().addThread(thread);
    assertEquals(1, table.getModel().getRowCount());
    for (int column = 0; column < table.getModel().getColumnCount(); column++) {
        table.getModel().getValueAt(0, column);
    }
    table.getModel().removeThread(thread);
    assertEquals(0, table.getModel().getRowCount());
    table.getModel().reset();
}
Also used : CThreadInformationTable(com.google.security.zynamics.binnavi.Gui.Debug.ThreadInformationPanel.CThreadInformationTable) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) Test(org.junit.Test)

Example 73 with TargetProcessThread

use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread in project binnavi by google.

the class CRegisterViewSynchronizerTest method testThreads.

@Test
public void testThreads() throws DebugExceptionWrapper {
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    debugger.connect();
    debugger.getProcessManager().setAttached(true);
    debugger.connection.m_synchronizer.receivedEvent(new TargetInformationReply(0, 0, new TargetInformation(32, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, true, false, false, false, false, false, false, 1, 0, new ArrayList<DebuggerException>(), false, false, false))));
    final MemorySection section1 = new MemorySection(new CAddress(0x100), new CAddress(0x1FF));
    final MemorySection section2 = new MemorySection(new CAddress(0x300), new CAddress(0x3FF));
    final MemoryMap memoryMap = new MemoryMap(Lists.newArrayList(section1, section2));
    debugger.connection.m_synchronizer.receivedEvent(new MemoryMapReply(0, 0, memoryMap));
    final TargetProcessThread thread = new TargetProcessThread(1, ThreadState.RUNNING);
    debugger.getProcessManager().addThread(thread);
    m_model.setActiveDebugger(debugger);
    assertFalse(m_registerView.isEnabled());
    final TargetProcessThread thread2 = new TargetProcessThread(2, ThreadState.RUNNING);
    debugger.getProcessManager().addThread(thread2);
    assertFalse(m_registerView.isEnabled());
    debugger.getProcessManager().setActiveThread(thread2);
    assertTrue(m_registerView.isEnabled());
    debugger.getProcessManager().setActiveThread(null);
    assertFalse(m_registerView.isEnabled());
    debugger.getProcessManager().removeThread(thread);
    assertFalse(m_registerView.isEnabled());
    debugger.getProcessManager().setAttached(false);
    m_synchronizer.dispose();
    debugger.close();
}
Also used : MemoryMap(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap) MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) MemoryMapReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.MemoryMapReply) ArrayList(java.util.ArrayList) DebuggerOptions(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) 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) TargetInformationReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.TargetInformationReply) Test(org.junit.Test)

Example 74 with TargetProcessThread

use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread 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 75 with TargetProcessThread

use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread in project binnavi by google.

the class CMemoryViewerSynchronizer method updateGui.

/**
   * Updates the GUI depending on the state of the active debugger.
   */
private void updateGui() {
    final IDebugger debugger = m_debugPerspectiveModel.getCurrentSelectedDebugger();
    final TargetProcessThread thread = debugger == null ? null : debugger.getProcessManager().getActiveThread();
    final boolean connected = debugger != null && debugger.isConnected();
    final boolean suspended = connected && thread != null;
    m_hexView.setEnabled(connected && suspended && m_provider.getDataLength() != 0);
    if (connected) {
        m_hexView.setDefinitionStatus(DefinitionStatus.DEFINED);
    } else {
        // m_hexView.setDefinitionStatus(DefinitionStatus.UNDEFINED);
        m_provider.setMemorySize(0);
        m_hexView.setBaseAddress(0);
        m_hexView.uncolorizeAll();
    }
}
Also used : TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)

Aggregations

TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)91 Test (org.junit.Test)50 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)27 RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)22 TargetInformation (com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation)21 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)20 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)20 DebuggerOptions (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions)20 MemoryMap (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap)19 MemorySection (com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection)18 RegisterDescription (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription)17 IDebugger (com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)16 TargetInformationReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.TargetInformationReply)15 ArrayList (java.util.ArrayList)15 MemoryMapReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.MemoryMapReply)14 RegisterValue (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue)14 MemoryModule (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule)12 ProcessManager (com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager)12 MaybeNullException (com.google.security.zynamics.binnavi.Exceptions.MaybeNullException)10 ThreadRegisters (com.google.security.zynamics.binnavi.debug.models.targetinformation.ThreadRegisters)9