use of com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress in project binnavi by google.
the class CBreakpointManagerTest method testRemoveSteppingBreakpoint.
@Test
public void testRemoveSteppingBreakpoint() {
assertEquals(1, m_manager.getNumberOfBreakpoints(BreakpointType.STEP));
final MockBreakpointManagerListener listener = new MockBreakpointManagerListener();
m_manager.addListener(listener);
m_manager.removeBreakpoints(BreakpointType.STEP, Sets.newHashSet(new BreakpointAddress(m_module, new UnrelocatedAddress(new CAddress(0x1000)))));
// The breakpoint was removed
assertEquals(0, m_manager.getNumberOfBreakpoints(BreakpointType.STEP));
// Make sure that the message was sent
assertEquals(1, listener.size());
}
use of com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress in project binnavi by google.
the class CBreakpointManagerTest method testGetBreakpoint2.
@Test
public void testGetBreakpoint2() {
assertEquals(BreakpointStatus.BREAKPOINT_INACTIVE, m_manager.getBreakpointStatus(new BreakpointAddress(m_module, new UnrelocatedAddress(new CAddress(0x123))), BreakpointType.REGULAR));
assertEquals(BreakpointStatus.BREAKPOINT_INACTIVE, m_manager.getBreakpointStatus(new BreakpointAddress(m_module, new UnrelocatedAddress(new CAddress(0x456))), BreakpointType.REGULAR));
assertEquals(null, m_manager.getBreakpointStatus(null, BreakpointType.REGULAR));
assertEquals(null, m_manager.getBreakpointStatus(new BreakpointAddress(m_module, new UnrelocatedAddress(new CAddress(0))), BreakpointType.REGULAR));
}
use of com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress 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.disassembly.UnrelocatedAddress 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.disassembly.UnrelocatedAddress in project binnavi by google.
the class CEventTableModelTest method testSimple.
/**
* General test whether the model is working as expected.
*
* @throws RecognitionException
*/
@Test
public void testSimple() throws RecognitionException {
final INaviModule mockModule = new MockModule();
final INaviModule mockModule2 = new MockModule(true);
final INaviModule mockModule3 = new MockModule();
final CEventTableModel model = new CEventTableModel();
final TraceList list = new TraceList(1, "", "", new MockSqlProvider());
list.addEvent(new TraceEvent(1, new BreakpointAddress(mockModule, new UnrelocatedAddress(new CAddress(0x123))), TraceEventType.REGULAR_BREAKPOINT, Lists.newArrayList(new TraceRegister("eax", new CAddress(0x123), new byte[] { 05 }))));
list.addEvent(new TraceEvent(1, new BreakpointAddress(mockModule2, new UnrelocatedAddress(new CAddress(0x124))), TraceEventType.REGULAR_BREAKPOINT, Lists.newArrayList(new TraceRegister("eax", new CAddress(0x123), new byte[] { 06 }))));
list.addEvent(new TraceEvent(1, new BreakpointAddress(mockModule3, new UnrelocatedAddress(new CAddress(0x125))), TraceEventType.REGULAR_BREAKPOINT, Lists.newArrayList(new TraceRegister("eax", new CAddress(0x123), new byte[] { 07, 05 }))));
assertEquals(0, model.getRowCount());
model.setEventList(list);
assertEquals(3, model.getRowCount());
final IFilter<ITraceEvent> filter = new CTraceFilterCreator().createFilter("mem == 05");
model.setFilter(filter);
assertEquals(2, model.getRowCount());
assertEquals(2, model.getEvents().size());
assertEquals(0x123, model.getEvents().get(0).getOffset().getAddress().getAddress().toLong());
assertEquals(0x125, model.getEvents().get(1).getOffset().getAddress().getAddress().toLong());
model.setFilter(null);
assertEquals(3, model.getRowCount());
for (int i = 0; i < model.getRowCount(); i++) {
for (int j = 0; j < model.getColumnCount(); j++) {
model.getValueAt(i, j);
}
}
}
Aggregations