use of com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues in project binnavi by google.
the class CHistoryStringBuilderTest method testComplete2.
@SuppressWarnings("unchecked")
@Test
public void testComplete2() throws DebugExceptionWrapper {
final CHistoryStringBuilder builder = new CHistoryStringBuilder();
builder.setDebugger(m_debugger);
m_debugger.connect();
m_synchronizer.receivedEvent(DebuggerMessageBuilder.buildProcessStartReply(mockMemoryModule));
m_debugger.getProcessManager().addThread(new TargetProcessThread(1, ThreadState.RUNNING));
m_synchronizer.receivedEvent(new BreakpointConditionSetReply(0, 0));
m_synchronizer.receivedEvent(new BreakpointConditionSetReply(0, 1));
try {
m_synchronizer.receivedEvent(new BreakpointHitReply(0, 0, 1, new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(1, Lists.newArrayList(new RegisterValue("eip", BigInteger.ONE, new byte[0], false, false)))))));
fail();
} catch (final IllegalStateException e) {
}
m_synchronizer.receivedEvent(new BreakpointHitReply(0, 0, 1, new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(1, Lists.newArrayList(new RegisterValue("eip", BigInteger.ONE, new byte[0], true, false)))))));
m_breakpointManager.addBreakpoints(BreakpointType.REGULAR, BREAKPOINT_ADDRESS);
m_synchronizer.receivedEvent(new BreakpointSetReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(BREAKPOINT_ADDRESS_RELOC, 0))));
m_synchronizer.receivedEvent(new BreakpointSetReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(BREAKPOINT_ADDRESS_RELOC, 1))));
m_synchronizer.receivedEvent(new BreakpointsRemovedReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(BREAKPOINT_ADDRESS_RELOC, 0))));
m_synchronizer.receivedEvent(new BreakpointsRemovedReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(BREAKPOINT_ADDRESS_RELOC, 1))));
m_breakpointManager.removeBreakpoints(BreakpointType.REGULAR, BREAKPOINT_ADDRESS);
m_synchronizer.receivedEvent(new DebuggerClosedUnexpectedlyReply());
m_synchronizer.receivedEvent(new DetachReply(0, 0));
m_synchronizer.receivedEvent(new DetachReply(0, 1));
}
use of com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues in project binnavi by google.
the class CRegisterValuesParserTest method test.
@Test
public void test() throws MessageParserException {
final RegisterValues information = RegisterValuesParser.parse("<Registers><Thread id=\"5\"><Register name=\"eax\" value=\"123\" memory=\"\"/></Thread></Registers>".getBytes());
assertEquals("eax", information.getThreads().get(0).getRegisters().get(0).getName());
}
use of com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues in project binnavi by google.
the class StepBreakpointHitSynchronizer method handleSuccess.
@Override
protected void handleSuccess(final StepBreakpointHitReply reply) {
final BreakpointManager manager = getDebugger().getBreakpointManager();
final ProcessManager processManager = getDebugger().getProcessManager();
RelocatedAddress breakpointAddress = null;
final RegisterValues registerValues = reply.getRegisterValues();
final long tid = reply.getThreadId();
for (final ThreadRegisters threadRegisters : registerValues) {
if (tid == threadRegisters.getTid()) {
for (final RegisterValue registerValue : threadRegisters) {
if (registerValue.isPc()) {
breakpointAddress = new RelocatedAddress(new CAddress(registerValue.getValue()));
break;
}
}
}
}
manager.clearBreakpointsPassive(BreakpointType.STEP);
try {
final TargetProcessThread thread = processManager.getThread(tid);
for (final ThreadRegisters threadRegisters : registerValues) {
if (tid == threadRegisters.getTid()) {
// Update the thread with the new register values.
thread.setRegisterValues(threadRegisters.getRegisters());
}
}
processManager.setActiveThread(thread);
thread.setCurrentAddress(breakpointAddress);
} catch (final MaybeNullException exception) {
// Apparently there is no thread with the specified TID.
// This is not necessarily an error because the thread might have
// been closed while this handler was active.
// Nevertheless this should be logged.
NaviLogger.info("Error: Process manager could not get thread. Exception %s", exception);
return;
}
}
use of com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues in project binnavi by google.
the class TraceLoggerTest method testHits.
@Test
public void testHits() throws CouldntSaveDataException, DebugExceptionWrapper {
m_mockDebugger.connect();
final Trace trace = m_logger.start("Name", "Description", Lists.newArrayList(new TracePoint(m_mockModule, new Address(0x100)), new TracePoint(m_mockModule, new Address(0x100))));
m_mockDebugger.connection.m_synchronizer.receivedEvent(new EchoBreakpointHitReply(0, 0, 0, new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(0, Lists.newArrayList(new RegisterValue("esp", BigInteger.valueOf(0x1100), new byte[0], true, false)))))));
m_logger.stop();
assertEquals("Name", trace.getName());
assertEquals("Description", trace.getDescription());
assertEquals(1, trace.getEvents().size());
assertEquals(0x100, trace.getEvents().get(0).getAddress().toLong());
assertEquals("TraceLogger [Debugger 'Mock' : Mock Module]", m_logger.toString());
}
use of com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues in project binnavi by google.
the class TraceLoggerTest method testHitsProject.
@Test
public void testHitsProject() throws CouldntSaveDataException, DebugExceptionWrapper {
m_mockDebugger.connect();
final Trace trace = m_projectLogger.start("Name", "Description", Lists.newArrayList(new TracePoint(m_mockModule, new Address(0x100))));
m_mockDebugger.connection.m_synchronizer.receivedEvent(new EchoBreakpointHitReply(0, 0, 0, new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(0, Lists.newArrayList(new RegisterValue("esp", BigInteger.valueOf(0x1100), new byte[0], true, false)))))));
m_projectLogger.stop();
assertEquals("Name", trace.getName());
assertEquals("Description", trace.getDescription());
assertEquals(1, trace.getEvents().size());
assertEquals(0x100, trace.getEvents().get(0).getAddress().toLong());
assertEquals("TraceLogger [Debugger 'Mock' : Mock Project]", m_projectLogger.toString());
}
Aggregations