Search in sources :

Example 1 with FilledList

use of com.google.security.zynamics.zylib.types.lists.FilledList 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 2 with FilledList

use of com.google.security.zynamics.zylib.types.lists.FilledList 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)

Example 3 with FilledList

use of com.google.security.zynamics.zylib.types.lists.FilledList in project binnavi by google.

the class CMemorySectionPanelSynchronizerTest method testReceiveTargetInformation.

@Test
public void testReceiveTargetInformation() throws DebugExceptionWrapper {
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    final TargetProcessThread thread = new TargetProcessThread(1, ThreadState.SUSPENDED);
    debugger.getProcessManager().addThread(thread);
    debugger.getProcessManager().setActiveThread(thread);
    final MemorySection section1 = new MemorySection(new CAddress(0x100), new CAddress(0x1FF));
    final MemorySection section2 = new MemorySection(new CAddress(0x300), new CAddress(0x3FF));
    final MemoryMap memoryMap = new MemoryMap(Lists.newArrayList(section1, section2));
    debugger.connection.m_synchronizer.receivedEvent(new MemoryMapReply(0, 0, memoryMap));
    debugger.connect();
    m_model.setActiveDebugger(debugger);
    debugger.getProcessManager().setTargetInformation(new TargetInformation(32, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, true, false, false, false, false, false, false, 1, 0, new ArrayList<DebuggerException>(), false, false, false)));
    assertTrue(m_sectionBox.isEnabled());
    debugger.getProcessManager().setTargetInformation(new TargetInformation(32, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, false, false, false, false, false, false, false, 1, 0, new ArrayList<DebuggerException>(), false, false, false)));
    assertFalse(m_sectionBox.isEnabled());
    m_synchronizer.dispose();
    debugger.close();
}
Also used : MemoryMap(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) MemoryMapReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.MemoryMapReply) DebuggerException(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerException) TargetInformation(com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation) DebuggerOptions(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 4 with FilledList

use of com.google.security.zynamics.zylib.types.lists.FilledList in project binnavi by google.

the class ProcessTest method testGetTargetInformation.

@Test
public void testGetTargetInformation() {
    final MockProcessListener listener = new MockProcessListener();
    final ProcessManager manager = new ProcessManager();
    final Process process = new Process(manager);
    process.addListener(listener);
    assertNull(process.getTargetInformation());
    manager.setTargetInformation(new com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation(5, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, false, false, false, false, false, false, false, 12, 0, new ArrayList<DebuggerException>(), false, false, false)));
    final TargetInformation t1 = process.getTargetInformation();
    final TargetInformation t2 = process.getTargetInformation();
    assertNotNull(t1);
    assertEquals(t1, t2);
    assertEquals("changedTargetInformation;", listener.events);
    assertEquals(5, process.getTargetInformation().getAddressSize());
    assertEquals(false, process.getTargetInformation().canTerminate());
    process.removeListener(listener);
}
Also used : FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) DebuggerException(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerException) DebuggerOptions(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions) ProcessManager(com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager) Test(org.junit.Test)

Example 5 with FilledList

use of com.google.security.zynamics.zylib.types.lists.FilledList in project binnavi by google.

the class PostgreSQLTracesLoader method loadTraceEventValues.

/**
 * Loads the event values of a trace from the database.
 *
 * @param connection Connection to the database.
 * @param traceList The trace to load.
 *
 * @return The event values.
 *
 * @throws SQLException Thrown if the values could not be loaded.
 */
private static List<List<TraceRegister>> loadTraceEventValues(final CConnection connection, final TraceList traceList) throws SQLException {
    final List<List<TraceRegister>> values = new ArrayList<>();
    final String query = "select position, register_name, register_value, memory_value from " + CTableNames.TRACE_EVENT_VALUES_TABLE + " where trace_id = " + traceList.getId() + " order by position asc";
    final ResultSet resultSet = connection.executeQuery(query, true);
    int currentPosition = -1;
    try {
        List<TraceRegister> registers = new ArrayList<TraceRegister>();
        while (resultSet.next()) {
            final int position = resultSet.getInt("position");
            if (position != currentPosition) {
                if (!registers.isEmpty()) {
                    values.add(Lists.newArrayList(registers));
                    registers = new FilledList<TraceRegister>();
                }
                currentPosition = position;
            }
            final String name = PostgreSQLHelpers.readString(resultSet, "register_name");
            final long value = resultSet.getLong("register_value");
            final byte[] memory = resultSet.getBytes("memory_value");
            registers.add(new TraceRegister(name, new CAddress(value), memory));
        }
        if (!registers.isEmpty()) {
            values.add(Lists.newArrayList(registers));
        }
    } finally {
        resultSet.close();
    }
    return values;
}
Also used : TraceRegister(com.google.security.zynamics.binnavi.debug.models.trace.TraceRegister) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) IFilledList(com.google.security.zynamics.zylib.types.lists.IFilledList) TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList) ArrayList(java.util.ArrayList) List(java.util.List) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Aggregations

FilledList (com.google.security.zynamics.zylib.types.lists.FilledList)31 Test (org.junit.Test)18 IFilledList (com.google.security.zynamics.zylib.types.lists.IFilledList)17 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)11 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)9 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)8 MockFunction (com.google.security.zynamics.binnavi.disassembly.MockFunction)7 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)7 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)5 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)5 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)5 INaviEdge (com.google.security.zynamics.binnavi.disassembly.INaviEdge)5 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)5 MockView (com.google.security.zynamics.binnavi.disassembly.MockView)5 ArrayList (java.util.ArrayList)5 MemoryMap (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap)4 MemorySection (com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection)4 DebuggerException (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerException)4 DebuggerOptions (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions)4 TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)4