use of com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider 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.debugger.DebuggerProvider 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.DebuggerProvider in project binnavi by google.
the class CBoookmarkFunctionsTest method test2DeleteBookmarks.
@Test
public void test2DeleteBookmarks() {
final DebugTargetSettings target = new ModuleTargetSettings(CommonTestObjects.MODULE);
final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
final CBookmarkTableModel model = new CBookmarkTableModel(debuggerProvider);
final CBookmark bookmark = new CBookmark(new MockAddress(), "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());
final int[] rows = { 0 };
CBookmarkFunctions.deleteBookmarks(debuggerProvider, rows);
assertEquals(0, bookmarkManager.getNumberOfBookmarks());
model.dispose();
}
use of com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider in project binnavi by google.
the class CGraphDebuggerTest method testToggleBreakpoint2.
@Test
public void testToggleBreakpoint2() {
final MockModule module = new MockModule();
module.getConfiguration().setDebugger(m_debugger);
m_debugger.setAddressTranslator(module, m_fileBase, m_imageBase);
final DebugTargetSettings target = new ModuleTargetSettings(module);
final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
debuggerProvider.addDebugger(m_debugger);
final CFunction function = new CFunction(module, new MockView(), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, m_provider);
final CFunctionNode functionNode = new CFunctionNode(0, function, 0, 0, 0, 0, Color.RED, false, false, null, new HashSet<CTag>(), m_provider);
CGraphDebugger.toggleBreakpoint(debuggerProvider, functionNode);
assertEquals(1, m_debugger.getBreakpointManager().getNumberOfBreakpoints(BreakpointType.REGULAR));
assertEquals(0x123, m_debugger.getBreakpointManager().getBreakpoint(BreakpointType.REGULAR, 0).getAddress().getAddress().getAddress().toLong());
assertEquals(BreakpointStatus.BREAKPOINT_INACTIVE, m_debugger.getBreakpointManager().getBreakpointStatus(BreakpointType.REGULAR, 0));
CGraphDebugger.toggleBreakpoint(debuggerProvider, functionNode);
assertEquals(0, m_debugger.getBreakpointManager().getNumberOfBreakpoints(BreakpointType.REGULAR));
}
use of com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider in project binnavi by google.
the class CGraphDebuggerTest method testToggleBreakpoint3.
@Test
public void testToggleBreakpoint3() {
final MockModule module = new MockModule();
module.getConfiguration().setDebugger(m_debugger);
m_debugger.setAddressTranslator(module, m_fileBase, m_imageBase);
final DebugTargetSettings target = new ModuleTargetSettings(module);
final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
debuggerProvider.addDebugger(m_debugger);
final CFunction function = new CFunction(module, new MockView(), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, m_provider);
final ArrayList<IComment> comments = Lists.<IComment>newArrayList(new CComment(null, CommonTestObjects.TEST_USER_1, null, "Mock Comment"));
final INaviCodeNode codeNode = new CCodeNode(0, 0, 0, 0, 0, Color.RED, Color.RED, false, false, comments, function, new HashSet<CTag>(), new MockSqlProvider());
codeNode.addInstruction(new CInstruction(true, module, new CAddress(0x123), "nop", new ArrayList<COperandTree>(), new byte[] { (byte) 0x90 }, "x86-32", m_provider), null);
codeNode.addInstruction(new CInstruction(true, module, new CAddress(0x124), "nop", new ArrayList<COperandTree>(), new byte[] { (byte) 0x90 }, "x86-32", m_provider), null);
CGraphDebugger.toggleBreakpoint(debuggerProvider, codeNode, 2);
assertEquals(1, m_debugger.getBreakpointManager().getNumberOfBreakpoints(BreakpointType.REGULAR));
assertEquals(0x124, m_debugger.getBreakpointManager().getBreakpoint(BreakpointType.REGULAR, 0).getAddress().getAddress().getAddress().toLong());
assertEquals(BreakpointStatus.BREAKPOINT_INACTIVE, m_debugger.getBreakpointManager().getBreakpointStatus(BreakpointType.REGULAR, 0));
CGraphDebugger.toggleBreakpoint(debuggerProvider, codeNode, 2);
assertEquals(0, m_debugger.getBreakpointManager().getNumberOfBreakpoints(BreakpointType.REGULAR));
}
Aggregations