use of com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint in project binnavi by google.
the class CTraceLoggerTest method testCase1637.
@Test
public void testCase1637() throws DebugExceptionWrapper, InterruptedException {
// This test tries to check for a race condition that happens like this:
//
// 1. Trace mode is stopping
// 2. Stopping trace mode removes listeners of hit breakpoint before breakpoint is hit
// 3. Echo breakpoint is hit => listener is removed again
//
// Result: Crash
final ITraceListProvider provider = new MockTraceListProvider();
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(module));
debugger.connect();
final MockModule module = new MockModule();
debugger.setAddressTranslator(module, new CAddress(0), new CAddress(0x1000));
final Set<BreakpointAddress> addresses = new HashSet<BreakpointAddress>();
for (int i = 0; i < 1000; i++) {
addresses.add(new BreakpointAddress(module, new UnrelocatedAddress(new CAddress(i))));
}
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);
logger.start(trace, addresses, 1);
final Breakpoint breakpoint = debugger.getBreakpointManager().getBreakpoint(BreakpointType.ECHO, new BreakpointAddress(module, new UnrelocatedAddress(new CAddress(999))));
new Thread() {
@Override
public void run() {
logger.stop();
}
}.start();
new Thread() {
@Override
public void run() {
debugger.getBreakpointManager().setBreakpointStatus(Sets.newHashSet(breakpoint.getAddress()), breakpoint.getType(), BreakpointStatus.BREAKPOINT_HIT);
}
}.start();
while (logger.activeEchoBreakpointCount() != 0) {
Thread.sleep(100);
}
}
use of com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint 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.models.breakpoints.Breakpoint 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));
}
use of com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint in project binnavi by google.
the class CBreakpointFunctionsTest method test1Simple.
@Test
public void test1Simple() {
final INaviModule mockModule = new MockModule();
final DebugTargetSettings target = new ModuleTargetSettings(mockModule);
final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(mockModule));
debugger.getBreakpointManager().addBreakpoints(BreakpointType.REGULAR, Sets.newHashSet(new BreakpointAddress(mockModule, new UnrelocatedAddress(new CAddress(0)))));
final Breakpoint breakPoint = debugger.getBreakpointManager().getBreakpoint(BreakpointType.REGULAR, new BreakpointAddress(mockModule, new UnrelocatedAddress(new CAddress(0))));
@SuppressWarnings("unused") 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);
@SuppressWarnings("unused") final CBreakpointTableModel tableModel = new CBreakpointTableModel(debuggerProvider);
final int[] rows = { 0 };
assertFalse(CBreakpointFunctions.allDisabled(debuggerProvider, rows));
assertTrue(CBreakpointFunctions.allNotDisabled(debuggerProvider, rows));
}
use of com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint in project binnavi by google.
the class CBreakpointFunctionsTest method test2DeleteBreakpoints.
@Test
public void test2DeleteBreakpoints() {
final INaviModule mockModule = new MockModule();
final DebugTargetSettings target = new ModuleTargetSettings(mockModule);
final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(mockModule));
debugger.getBreakpointManager().addBreakpoints(BreakpointType.REGULAR, Sets.newHashSet(new BreakpointAddress(mockModule, new UnrelocatedAddress(new CAddress(0)))));
final Breakpoint breakPoint = debugger.getBreakpointManager().getBreakpoint(BreakpointType.REGULAR, new BreakpointAddress(mockModule, new UnrelocatedAddress(new CAddress(0))));
@SuppressWarnings("unused") 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);
final int[] rows = { 0 };
assertEquals(1, tableModel.getRowCount());
CBreakpointRemoveFunctions.deleteBreakpoints(debuggerProvider, rows);
assertEquals(0, tableModel.getRowCount());
}
Aggregations