Search in sources :

Example 1 with DebuggerProvider

use of com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider in project binnavi by google.

the class CBreakpointTableModelTest method test6Utility.

@Test
public void test6Utility() {
    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);
    @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);
    assertEquals(7, tableModel.getColumnCount());
    assertEquals("Status", tableModel.getColumnName(0));
    assertEquals("Debugger", tableModel.getColumnName(1));
    assertEquals("Unrelocated Address", tableModel.getColumnName(2));
    assertEquals("Relocated Address", tableModel.getColumnName(3));
    assertEquals("Module", tableModel.getColumnName(4));
    assertEquals("Condition", tableModel.getColumnName(5));
    assertEquals("Description", tableModel.getColumnName(6));
    assertEquals(1, tableModel.getRowCount());
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) Breakpoint(com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint) DebuggerProvider(com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider) BreakpointCondition(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointCondition) BaseNode(com.google.security.zynamics.binnavi.debug.models.breakpoints.conditions.BaseNode) DebugTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 2 with DebuggerProvider

use of com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider 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));
}
Also used : Breakpoint(com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint) BaseNode(com.google.security.zynamics.binnavi.debug.models.breakpoints.conditions.BaseNode) CBreakpointTableModel(com.google.security.zynamics.binnavi.Gui.Debug.BreakpointTable.CBreakpointTableModel) DebugTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) DebuggerProvider(com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) BreakpointCondition(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointCondition) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) Test(org.junit.Test)

Example 3 with DebuggerProvider

use of com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider in project binnavi by google.

the class CBreakpointFunctionsTest method test7setBreakpoints.

@Test
public void test7setBreakpoints() throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    final MockFunction mockFunction = new MockFunction();
    final INaviModule mockModule = mockFunction.getModule();
    CFunctionContainerHelper.addFunction(mockModule.getContent().getFunctionContainer(), mockFunction);
    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(0x1234)))));
    @SuppressWarnings("unused") final Breakpoint breakPoint = debugger.getBreakpointManager().getBreakpoint(BreakpointType.REGULAR, new BreakpointAddress(mockModule, new UnrelocatedAddress(new CAddress(0x1234))));
    // CBreakpointAddress address = new CBreakpointAddress(mockModule, new CUnrelocatedAddress(new
    // CAddress(0x2c9)));
    debuggerProvider.addDebugger(debugger);
    final CBreakpointTableModel tableModel = new CBreakpointTableModel(debuggerProvider);
    assertEquals(1, tableModel.getRowCount());
    final IFilledList<Pair<IDebugger, INaviFunction>> targets = new FilledList<Pair<IDebugger, INaviFunction>>();
    final Pair<IDebugger, INaviFunction> targetPair = new Pair<IDebugger, INaviFunction>(debugger, mockFunction);
    targets.add(targetPair);
    CBreakpointRemoveFunctions.removeBreakpoints(targets);
    assertEquals(0, tableModel.getRowCount());
    CBreakpointSetFunctions.setBreakpoints(targets);
    assertEquals(1, tableModel.getRowCount());
}
Also used : MockFunction(com.google.security.zynamics.binnavi.disassembly.MockFunction) Breakpoint(com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint) FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) IFilledList(com.google.security.zynamics.zylib.types.lists.IFilledList) CBreakpointTableModel(com.google.security.zynamics.binnavi.Gui.Debug.BreakpointTable.CBreakpointTableModel) DebugTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) DebuggerProvider(com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) Pair(com.google.security.zynamics.zylib.general.Pair) Test(org.junit.Test)

Example 4 with DebuggerProvider

use of com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider 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));
}
Also used : Breakpoint(com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint) BaseNode(com.google.security.zynamics.binnavi.debug.models.breakpoints.conditions.BaseNode) CBreakpointTableModel(com.google.security.zynamics.binnavi.Gui.Debug.BreakpointTable.CBreakpointTableModel) DebugTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) DebuggerProvider(com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) BreakpointCondition(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointCondition) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) Test(org.junit.Test)

Example 5 with DebuggerProvider

use of com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider in project binnavi by google.

the class CBreakpointFunctionsTest method test6removeFunctions.

@Test
public void test6removeFunctions() throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    final MockFunction mockFunction = new MockFunction();
    final INaviModule mockModule = mockFunction.getModule();
    CFunctionContainerHelper.addFunction(mockModule.getContent().getFunctionContainer(), mockFunction);
    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(0x1234)))));
    @SuppressWarnings("unused") final Breakpoint breakPoint = debugger.getBreakpointManager().getBreakpoint(BreakpointType.REGULAR, new BreakpointAddress(mockModule, new UnrelocatedAddress(new CAddress(0x1234))));
    debuggerProvider.addDebugger(debugger);
    final CBreakpointTableModel tableModel = new CBreakpointTableModel(debuggerProvider);
    assertEquals(1, tableModel.getRowCount());
    final IFilledList<Pair<IDebugger, INaviFunction>> targets = new FilledList<Pair<IDebugger, INaviFunction>>();
    final Pair<IDebugger, INaviFunction> targetPair = new Pair<IDebugger, INaviFunction>(debugger, mockFunction);
    targets.add(targetPair);
    assertEquals(1, targets.size());
    CBreakpointRemoveFunctions.removeBreakpoints(targets);
    @SuppressWarnings("unused") final BreakpointManager manager = debugger.getBreakpointManager();
    assertEquals(0, tableModel.getRowCount());
}
Also used : MockFunction(com.google.security.zynamics.binnavi.disassembly.MockFunction) Breakpoint(com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint) FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) IFilledList(com.google.security.zynamics.zylib.types.lists.IFilledList) CBreakpointTableModel(com.google.security.zynamics.binnavi.Gui.Debug.BreakpointTable.CBreakpointTableModel) DebugTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) BreakpointManager(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) DebuggerProvider(com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) Pair(com.google.security.zynamics.zylib.general.Pair) Test(org.junit.Test)

Aggregations

DebuggerProvider (com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider)21 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)21 DebugTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings)20 Test (org.junit.Test)20 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)16 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)14 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)11 Breakpoint (com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint)10 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)8 BreakpointCondition (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointCondition)8 BaseNode (com.google.security.zynamics.binnavi.debug.models.breakpoints.conditions.BaseNode)8 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)8 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)8 CBreakpointTableModel (com.google.security.zynamics.binnavi.Gui.Debug.BreakpointTable.CBreakpointTableModel)7 MockView (com.google.security.zynamics.binnavi.disassembly.MockView)5 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)4 CFunction (com.google.security.zynamics.binnavi.disassembly.CFunction)4 CBookmarkTableModel (com.google.security.zynamics.binnavi.Gui.Debug.Bookmarks.CBookmarkTableModel)3 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)2 CComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment)2