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());
}
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();
}
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();
}
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();
}
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();
}
}
Aggregations