use of com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint in project binnavi by google.
the class CBreakpointFunctionsTest method test4DisableBreakpoints.
@Test
public void test4DisableBreakpoints() {
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 };
final int[] rows2 = { 1 };
assertFalse(CBreakpointFunctions.allDisabled(debuggerProvider, rows));
try {
CBreakpointRemoveFunctions.disableBreakpoints(debuggerProvider, rows2);
} catch (final IllegalArgumentException e) {
}
CBreakpointRemoveFunctions.disableBreakpoints(debuggerProvider, rows);
assertTrue(CBreakpointFunctions.allDisabled(debuggerProvider, rows));
}
use of com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint in project binnavi by google.
the class CBreakpointFunctionsTest method test3disableAll.
@Test
public void test3disableAll() {
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));
CBreakpointRemoveFunctions.disableAll(debuggerProvider);
assertTrue(CBreakpointFunctions.allDisabled(debuggerProvider, rows));
}
use of com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint in project binnavi by google.
the class CBreakpointFunctionsTest method test5enableFunctions.
@Test
public void test5enableFunctions() {
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));
CBreakpointRemoveFunctions.disableAll(debuggerProvider);
assertTrue(CBreakpointFunctions.allDisabled(debuggerProvider, rows));
CBreakpointSetFunctions.enableAll(debuggerProvider);
assertFalse(CBreakpointFunctions.allDisabled(debuggerProvider, rows));
CBreakpointRemoveFunctions.disableAll(debuggerProvider);
assertTrue(CBreakpointFunctions.allDisabled(debuggerProvider, rows));
CBreakpointSetFunctions.enableBreakpoints(debuggerProvider, rows);
assertFalse(CBreakpointFunctions.allDisabled(debuggerProvider, rows));
}
use of com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint in project binnavi by google.
the class ReplySynchronizer method updateHitBreakpoints.
/**
* Updates the hit state of breakpoints.
*
* @param address The current value of the program counter which is used to determine the state of
* breakpoints.
*/
protected void updateHitBreakpoints(final BreakpointAddress address) {
Preconditions.checkNotNull(address, "IE01048: Address argument can not be null");
final BreakpointManager manager = debugger.getBreakpointManager();
for (final Breakpoint breakpoint : manager.getBreakpoints(BreakpointType.REGULAR)) {
final boolean isAddressSame = address.equals(breakpoint.getAddress());
if ((manager.getBreakpointStatus(breakpoint.getAddress(), BreakpointType.REGULAR) == BreakpointStatus.BREAKPOINT_HIT) && !isAddressSame) {
// Activate the previously hit breakpoint
manager.setBreakpointStatus(Sets.newHashSet(breakpoint.getAddress()), BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_ACTIVE);
break;
} else if (isAddressSame) {
// Hit the currently hit breakpoint
try {
manager.setBreakpointStatus(Sets.newHashSet(breakpoint.getAddress()), BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_HIT);
} catch (final IllegalArgumentException exception) {
// Not one of our breakpoints.
return;
}
}
}
}
use of com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint in project binnavi by google.
the class CDebugBreakpointTest method testRegularBreakpoint.
/**
* Tests whether all getter and setter methods work properly for regular breakpoints.
*/
@Test
public void testRegularBreakpoint() {
final Breakpoint bp = new Breakpoint(BreakpointType.REGULAR, CommonTestObjects.BP_ADDRESS_123);
// Test whether the constructor worked properly.
assertEquals(BreakpointType.REGULAR, bp.getType());
assertEquals(null, bp.getDescription());
assertEquals(BigInteger.valueOf(0x123), bp.getAddress().getAddress().getAddress().toBigInteger());
assertEquals(BreakpointType.REGULAR, bp.getType());
assertEquals(null, bp.getDescription());
assertEquals(BigInteger.valueOf(0x123), bp.getAddress().getAddress().getAddress().toBigInteger());
assertEquals(BreakpointType.REGULAR, bp.getType());
assertEquals(null, bp.getDescription());
assertEquals(BigInteger.valueOf(0x123), bp.getAddress().getAddress().getAddress().toBigInteger());
// Test the comment setter method.
bp.setDescription("foo");
assertEquals(BreakpointType.REGULAR, bp.getType());
assertEquals("foo", bp.getDescription());
assertEquals(BigInteger.valueOf(0x123), bp.getAddress().getAddress().getAddress().toBigInteger());
}
Aggregations