use of com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger 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.MockDebugger in project binnavi by google.
the class CMemorySectionPanelSynchronizerTest method testChangingAddress.
@Test
public void testChangingAddress() throws DebugExceptionWrapper {
// Makes sure to update the combo box when the active address changes
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
debugger.connect();
m_model.setActiveDebugger(debugger);
final MemorySection section1 = new MemorySection(new CAddress(0x1000), new CAddress(0x1FF0));
final MemorySection section2 = new MemorySection(new CAddress(0x3000), new CAddress(0x3FF0));
final MemoryMap memoryMap = new MemoryMap(Lists.newArrayList(section1, section2));
debugger.connection.m_synchronizer.receivedEvent(new MemoryMapReply(0, 0, memoryMap));
assertEquals(2, m_sectionBox.getItemCount());
assertEquals(section1, m_sectionBox.getItemAt(0).getObject());
assertEquals(section2, m_sectionBox.getItemAt(1).getObject());
assertEquals(section1, m_sectionBox.getSelectedItem().getObject());
m_model.setActiveMemoryAddress(new CAddress(0x3000), false);
assertEquals(section2, m_sectionBox.getSelectedItem().getObject());
m_synchronizer.dispose();
debugger.close();
}
use of com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger in project binnavi by google.
the class CMemorySectionPanelSynchronizerTest method testReceiveTargetInformation.
@Test
public void testReceiveTargetInformation() throws DebugExceptionWrapper {
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
final TargetProcessThread thread = new TargetProcessThread(1, ThreadState.SUSPENDED);
debugger.getProcessManager().addThread(thread);
debugger.getProcessManager().setActiveThread(thread);
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));
debugger.connect();
m_model.setActiveDebugger(debugger);
debugger.getProcessManager().setTargetInformation(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)));
assertTrue(m_sectionBox.isEnabled());
debugger.getProcessManager().setTargetInformation(new TargetInformation(32, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, false, false, false, false, false, false, false, 1, 0, new ArrayList<DebuggerException>(), false, false, false)));
assertFalse(m_sectionBox.isEnabled());
m_synchronizer.dispose();
debugger.close();
}
use of com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger in project binnavi by google.
the class CMemorySectionPanelSynchronizerTest 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);
m_model.setActiveDebugger(debugger);
debugger.getProcessManager().setActiveThread(null);
assertFalse(m_sectionBox.isEnabled());
debugger.getProcessManager().addThread(thread);
assertFalse(m_sectionBox.isEnabled());
debugger.getProcessManager().setActiveThread(thread);
assertTrue(m_sectionBox.isEnabled());
debugger.getProcessManager().setActiveThread(null);
assertFalse(m_sectionBox.isEnabled());
debugger.getProcessManager().removeThread(thread);
assertFalse(m_sectionBox.isEnabled());
debugger.getProcessManager().setAttached(false);
m_synchronizer.dispose();
debugger.close();
}
use of com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger in project binnavi by google.
the class CModulesTableModelSynchronizerTest method testSwitchDebugger.
@Test
public void testSwitchDebugger() throws DebugExceptionWrapper {
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
debugger.connect();
debugger.getProcessManager().addModule(new MemoryModule("Hannes", "C:\\Hannes.dll", new RelocatedAddress(new CAddress(0x200)), 0x100));
final MockDebugger debugger2 = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
debugger2.connect();
debugger2.getProcessManager().addModule(new MemoryModule("Hannes", "C:\\Hannes.dll", new RelocatedAddress(new CAddress(0x200)), 0x100));
debugger2.getProcessManager().addModule(new MemoryModule("Hannes", "C:\\Hannes.dll", new RelocatedAddress(new CAddress(0x200)), 0x100));
m_model.setActiveDebugger(debugger);
assertEquals(1, m_tableModel.getRowCount());
m_model.setActiveDebugger(debugger2);
assertEquals(2, m_tableModel.getRowCount());
m_model.setActiveDebugger(null);
assertEquals(0, m_tableModel.getRowCount());
m_synchronizer.dispose();
debugger.close();
debugger2.close();
}
Aggregations