use of com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings in project binnavi by google.
the class CStackViewSynchronizerTest method testNewThread.
/**
* This test makes sure that freshly created threads have listeners attached.
*
* Test for 2035: Listener issue in the stack view synchronizer
*
* @throws DebugExceptionWrapper
*/
@Test
public void testNewThread() 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));
m_model.setActiveDebugger(debugger);
final TargetProcessThread thread = new TargetProcessThread(1, ThreadState.RUNNING);
debugger.getProcessManager().addThread(thread);
m_synchronizer.dispose();
debugger.close();
}
use of com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings 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.debugger.ModuleTargetSettings in project binnavi by google.
the class CBreakpointTableModelTest method test1Simple.
@Test
public void test1Simple() {
final DebugTargetSettings target = new ModuleTargetSettings(CommonTestObjects.MODULE);
final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
new MockModule();
debugger.getBreakpointManager().addBreakpoints(BreakpointType.REGULAR, BREAKPOINT_ADDRESS_SET);
debuggerProvider.addDebugger(debugger);
@SuppressWarnings("unused") final CBreakpointTableModel tableModel = new CBreakpointTableModel(debuggerProvider);
}
use of com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings in project binnavi by google.
the class CBreakpointTableModelTest method test4getValueAt.
@Test
public void test4getValueAt() {
final DebugTargetSettings target = new ModuleTargetSettings(CommonTestObjects.MODULE);
final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
debugger.getBreakpointManager().addBreakpoints(BreakpointType.REGULAR, BREAKPOINT_ADDRESS_SET);
final Breakpoint breakPoint = debugger.getBreakpointManager().getBreakpoint(BreakpointType.REGULAR, BREAKPOINT_ADDRESS);
final CAddress address = new CAddress(0);
final BaseNode root = new BaseNode();
final BreakpointCondition bpCondition = new BreakpointCondition("foo", root);
breakPoint.setCondition(bpCondition);
breakPoint.setDescription("purzel");
debuggerProvider.addDebugger(debugger);
final CBreakpointTableModel tableModel = new CBreakpointTableModel(debuggerProvider);
assertEquals(com.google.security.zynamics.binnavi.debug.models.breakpoints.enums.BreakpointStatus.BREAKPOINT_INACTIVE, tableModel.getValueAt(0, 0));
assertEquals(debugger.getPrintableString(), tableModel.getValueAt(0, 1));
assertEquals(address, tableModel.getValueAt(0, 2));
assertEquals("foo", tableModel.getValueAt(0, 5));
assertEquals("purzel", tableModel.getValueAt(0, 6));
try {
tableModel.getValueAt(0, 7);
fail();
} catch (final IllegalArgumentException e) {
}
}
use of com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings in project binnavi by google.
the class CBreakpointTableModelTest method test5setValueAt.
@Test
public void test5setValueAt() {
final DebugTargetSettings target = new ModuleTargetSettings(CommonTestObjects.MODULE);
final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
debugger.getBreakpointManager().addBreakpoints(BreakpointType.REGULAR, BREAKPOINT_ADDRESS_SET);
final Breakpoint breakPoint = debugger.getBreakpointManager().getBreakpoint(BreakpointType.REGULAR, BREAKPOINT_ADDRESS);
final BaseNode root = new BaseNode();
final BreakpointCondition bpCondition = new BreakpointCondition("foo", root);
breakPoint.setCondition(bpCondition);
breakPoint.setDescription("purzel");
debuggerProvider.addDebugger(debugger);
final CBreakpointTableModel tableModel = new CBreakpointTableModel(debuggerProvider);
tableModel.setValueAt("piff==0", 0, 5);
tableModel.setValueAt("puff", 0, 6);
assertEquals("piff==0", tableModel.getValueAt(0, 5));
assertEquals("puff", tableModel.getValueAt(0, 6));
}
Aggregations