use of com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings in project binnavi by google.
the class CThreadInformationPanelTest method test.
/**
* This test makes sure that going from no debugger to a debugger works fine.
*/
@Test
public void test() 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());
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 CBookmarksTableModelTest method test2getValueAt.
@Test
public void test2getValueAt() {
final DebugTargetSettings target = new ModuleTargetSettings(CommonTestObjects.MODULE);
final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
final CBookmarkTableModel model = new CBookmarkTableModel(debuggerProvider);
final IAddress address = new MockAddress();
final CBookmark bookmark = new CBookmark(address, "foo");
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
debugger.getBreakpointManager().addBreakpoints(BreakpointType.REGULAR, CommonTestObjects.BP_ADDRESS_0_SET);
debuggerProvider.addDebugger(debugger);
final BookmarkManager bookmarkManager = debugger.getBookmarkManager();
bookmarkManager.addBookmark(bookmark);
assertEquals(1, bookmarkManager.getNumberOfBookmarks());
assertEquals("foo", model.getValueAt(0, 2));
assertEquals(address.toHexString(), model.getValueAt(0, 1));
assertEquals(debugger.getPrintableString(), model.getValueAt(0, 0));
final int[] rows = { 0 };
CBookmarkFunctions.deleteBookmarks(debuggerProvider, rows);
assertEquals(0, bookmarkManager.getNumberOfBookmarks());
model.dispose();
}
use of com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings in project binnavi by google.
the class CTraceLoggerTest method testOverwrittenEchoBreakpoint.
@Test
public void testOverwrittenEchoBreakpoint() throws DebugExceptionWrapper {
// Scenario: Echo breakpoint of the trace is overwritten by a regular breakpoint
final ITraceListProvider provider = new MockTraceListProvider();
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(module));
debugger.setAddressTranslator(module, new CAddress(0), new CAddress(0x1000));
debugger.connect();
final TraceLogger logger = new TraceLogger(provider, debugger);
final MockTraceLoggerListener listener = new MockTraceLoggerListener();
logger.addListener(listener);
final MockSqlProvider sqlProvider = new MockSqlProvider();
final TraceList trace = new TraceList(1, "Foo", "Bar", sqlProvider);
final Set<BreakpointAddress> addresses = new HashSet<BreakpointAddress>();
addresses.add(new BreakpointAddress(module, new UnrelocatedAddress(new CAddress(0x100))));
addresses.add(new BreakpointAddress(module, new UnrelocatedAddress(new CAddress(0x200))));
logger.start(trace, addresses, 1);
debugger.getBreakpointManager().addBreakpoints(BreakpointType.REGULAR, Sets.newHashSet(new BreakpointAddress(module, new UnrelocatedAddress(new CAddress(0x100)))));
assertEquals("++-", listener.events);
logger.stop();
assertEquals("++--!", listener.events);
// Start the trace mode again to make sure all resources were cleaned
// up in the previous run.
logger.start(trace, addresses, 1);
logger.stop();
debugger.close();
}
use of com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings in project binnavi by google.
the class CTraceLoggerTest method testTargetClosed.
@Test
public void testTargetClosed() throws DebugExceptionWrapper {
final ITraceListProvider provider = new MockTraceListProvider();
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(module));
debugger.setAddressTranslator(module, new CAddress(0), new CAddress(0x1000));
debugger.connect();
final TraceLogger logger = new TraceLogger(provider, debugger);
final MockTraceLoggerListener listener = new MockTraceLoggerListener();
logger.addListener(listener);
final MockSqlProvider sqlProvider = new MockSqlProvider();
final TraceList trace = new TraceList(1, "Foo", "Bar", sqlProvider);
final Set<BreakpointAddress> addresses = new HashSet<BreakpointAddress>();
addresses.add(new BreakpointAddress(module, new UnrelocatedAddress(new CAddress(0x100))));
logger.start(trace, addresses, 1);
debugger.getProcessManager().setAttached(false);
assertEquals("+!", listener.events);
logger.stop();
// assertEquals(0, debugger.getBreakpointManager().getNumberOfBreakpoints(BreakpointType.ECHO));
// Start the trace mode again to make sure all resources were cleaned
// up in the previous run.
logger.start(trace, addresses, 1);
logger.stop();
debugger.close();
}
use of com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings in project binnavi by google.
the class CMemoryViewerSynchronizerTest method testThreads.
@Test
public void testThreads() throws DebugExceptionWrapper {
m_debugger.connect();
m_debugger.getProcessManager().setAttached(true);
final MockMemoryViewerSynchronizerListener listener = new MockMemoryViewerSynchronizerListener();
m_synchronizer.addListener(listener);
final TargetProcessThread thread = new TargetProcessThread(1, ThreadState.RUNNING);
m_debugger.getProcessManager().addThread(thread);
m_debugger.getProcessManager().setActiveThread(thread);
thread.setState(ThreadState.SUSPENDED);
thread.setState(ThreadState.RUNNING);
final MockDebugger debugger2 = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
m_model.setActiveDebugger(debugger2);
m_model.setActiveDebugger(m_debugger);
m_debugger.getProcessManager().removeThread(thread);
m_debugger.getProcessManager().setAttached(false);
m_synchronizer.removeListener(listener);
m_synchronizer.dispose();
}
Aggregations