Search in sources :

Example 61 with IDebugger

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

the class CMemoryViewerSynchronizerTest method testSwitchDebuggers.

@Test
public void testSwitchDebuggers() throws DebugExceptionWrapper {
    m_debugger.connect();
    m_debugger.getProcessManager().setAttached(true);
    m_debugger.getProcessManager().setMemoryMap(new MemoryMap(Lists.newArrayList(new MemorySection(new CAddress(0x100), new CAddress(0x1FF)))));
    m_model.setActiveMemoryAddress(new CAddress(0x100), false);
    assertEquals(0x100, m_hexView.getCurrentOffset());
    assertEquals(0x100, m_hexView.getData().getDataLength());
    final IDebugger debugger2 = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    debugger2.connect();
    debugger2.getProcessManager().setMemoryMap(new MemoryMap(Lists.newArrayList(new MemorySection(new CAddress(0x10), new CAddress(0x50)))));
    m_model.setActiveDebugger(debugger2);
    assertEquals(0x10, m_hexView.getCurrentOffset());
    assertEquals(0x41, m_hexView.getData().getDataLength());
    m_debugger.getProcessManager().setAttached(false);
    m_synchronizer.dispose();
    debugger2.close();
}
Also used : MemoryMap(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 62 with IDebugger

use of com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger 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)

Aggregations

IDebugger (com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)62 BreakpointManager (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager)16 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)16 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)6 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)6 Breakpoint (com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint)6 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)6 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)6 Test (org.junit.Test)6 MemorySection (com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection)5 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)5 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)5 CDebugPerspectiveModel (com.google.security.zynamics.binnavi.Gui.GraphWindows.Panels.CDebugPerspectiveModel)4 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)4 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)4 BookmarkManager (com.google.security.zynamics.binnavi.models.Bookmarks.memory.BookmarkManager)4 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)4 Pair (com.google.security.zynamics.zylib.general.Pair)4 ArrayList (java.util.ArrayList)4 IGraphModel (com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphModel)3