Search in sources :

Example 31 with ModuleTargetSettings

use of com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings 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 32 with ModuleTargetSettings

use of com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings 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));
}
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 33 with ModuleTargetSettings

use of com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings 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 34 with ModuleTargetSettings

use of com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings 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 35 with ModuleTargetSettings

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

the class BreakpointLifecycleTest method setUp.

@Before
public void setUp() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
    m_debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    m_debugger.setAddressTranslator(CommonTestObjects.MODULE, mockFileBase, mockImageBase.getAddress());
    m_breakpointManager = m_debugger.getBreakpointManager();
    m_synchronizer = new DebuggerSynchronizer(m_debugger);
    m_synchronizer.addListener(m_listener);
    // assign the synchronizer to the internally used one by the debugger so we can test the
    // synchronizer itself
    // as well as the combination of synchronizer and debugger
    final Field synchronizerField = AbstractDebugger.class.getDeclaredField("synchronizer");
    synchronizerField.setAccessible(true);
    synchronizerField.set(m_debugger, m_synchronizer);
}
Also used : DebuggerSynchronizer(com.google.security.zynamics.binnavi.debug.debugger.synchronizers.DebuggerSynchronizer) Field(java.lang.reflect.Field) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) Before(org.junit.Before)

Aggregations

ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)73 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)65 Test (org.junit.Test)63 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)51 DebuggerProvider (com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider)21 DebugTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings)20 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)20 ArrayList (java.util.ArrayList)19 DebuggerOptions (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions)18 TargetInformation (com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation)18 MemoryMap (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap)17 MemorySection (com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection)17 RegisterDescription (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription)17 TargetInformationReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.TargetInformationReply)16 MemoryMapReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.MemoryMapReply)15 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)15 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)15 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)14 Breakpoint (com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint)11 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)10