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());
}
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());
}
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();
}
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);
}
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;
}
Aggregations