use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread in project binnavi by google.
the class ResumeThreadSynchronizer method handleSuccess.
@Override
protected void handleSuccess(final ResumeThreadReply reply) {
try {
final TargetProcessThread thread = getDebugger().getProcessManager().getThread(reply.getThreadId());
thread.setState(ThreadState.RUNNING);
} catch (final MaybeNullException exception) {
// Unlike in the error case, this is really a bug.
NaviLogger.severe("Error: Tried to resume unknown thread '%d'", reply.getThreadId());
}
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread in project binnavi by google.
the class ResumeThreadSynchronizer method handleError.
@Override
protected void handleError(final ResumeThreadReply reply) {
try {
final TargetProcessThread thread = getDebugger().getProcessManager().getThread(reply.getThreadId());
// TODO: In case we can not resume the thread, we assume that it is really suspended.
// This is not correct, however. What really needs to happen is that the debug client
// sends the real state of the thread in the error message.
thread.setState(ThreadState.SUSPENDED);
} catch (final MaybeNullException exception) {
// Note: This is not necessary an error situation. Imagine the following
//
// 1. Send ResumeThread to the debug client
// 2. While the command is sent, the thread is closed
// 3. Debug client can not resume the thread
// 4. We land here
NaviLogger.severe("Error: Tried to resume unknown thread '%d'", reply.getThreadId());
}
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread in project binnavi by google.
the class SingleStepSynchronizer method handleSuccess.
@Override
protected void handleSuccess(final SingleStepReply reply) {
final ProcessManager processManager = getDebugger().getProcessManager();
final long tid = reply.getThreadId();
try {
// Find the thread object with the specified TID
final TargetProcessThread thread = processManager.getThread(tid);
// At the end of a single step event, a thread is automatically suspended.
processManager.setActiveThread(thread);
// Update the thread object with the values from the event.
setRegisterValues(reply.getRegisterValues());
updateHitBreakpoints(DebuggerHelpers.getBreakpointAddress(getDebugger(), thread.getCurrentAddress()));
} catch (final MaybeNullException e) {
// 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.
NaviLogger.info("Error: Process manager could not get thread. Exception %s", e);
}
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread in project binnavi by google.
the class SuspendThreadSynchronizer method handleSuccess.
@Override
protected void handleSuccess(final SuspendThreadReply reply) {
try {
final TargetProcessThread thread = getDebugger().getProcessManager().getThread(reply.getThreadId());
thread.setState(ThreadState.SUSPENDED);
} catch (final MaybeNullException exception) {
// Unlike in the error case, this is really a bug.
NaviLogger.severe("Error: Tried to suspend unknown thread '%d'", reply.getThreadId());
}
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread in project binnavi by google.
the class DebuggerTest method testListeners3.
@SuppressWarnings("unchecked")
@Test
public void testListeners3() throws MessageParserException, DebugExceptionWrapper, MaybeNullException {
mockDebugger.connect();
mockDebugger.getProcessManager().addThread(new TargetProcessThread(0, ThreadState.RUNNING));
mockDebugger.getProcessManager().getThread(0).setCurrentAddress(new RelocatedAddress(new CAddress(0)));
mockDebugger.connection.m_synchronizer.receivedEvent(new ResumeThreadReply(0, 0, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new ResumeThreadReply(0, 1, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new SearchReply(0, 0, new CAddress(0)));
mockDebugger.connection.m_synchronizer.receivedEvent(new SearchReply(0, 1, null));
mockDebugger.connection.m_synchronizer.receivedEvent(new SelectFileReply(0, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new SelectFileReply(0, 1));
mockDebugger.getProcessManager().addThread(new TargetProcessThread(0, ThreadState.RUNNING));
mockDebugger.getProcessManager().getThread(0).setCurrentAddress(new RelocatedAddress(new CAddress(0)));
mockDebugger.connection.m_synchronizer.receivedEvent(new SetRegisterReply(0, 0, 0, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new SetRegisterReply(0, 1, 0, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new SingleStepReply(0, 0, 0, new RelocatedAddress(new CAddress(0)), new RegisterValues(new FilledList<ThreadRegisters>())));
mockDebugger.connection.m_synchronizer.receivedEvent(new SingleStepReply(0, 1, 0, new RelocatedAddress(new CAddress(0)), new RegisterValues(new FilledList<ThreadRegisters>())));
mockDebugger.connection.m_synchronizer.receivedEvent(new StepBreakpointHitReply(0, 0, 1, new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(1, Lists.newArrayList(new RegisterValue("eip", BigInteger.ONE, new byte[0], false, false)))))));
mockDebugger.connection.m_synchronizer.receivedEvent(new StepBreakpointHitReply(0, 0, 1, new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(1, Lists.newArrayList(new RegisterValue("eip", BigInteger.ONE, new byte[0], true, false)))))));
mockDebugger.getBreakpointManager().addBreakpoints(BreakpointType.STEP, CommonTestObjects.BP_ADDRESS_123_SET);
mockDebugger.connection.m_synchronizer.receivedEvent(new StepBreakpointSetReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_123_RELOC, 0))));
mockDebugger.connection.m_synchronizer.receivedEvent(new StepBreakpointSetReply(0, 1, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_123_RELOC, 1))));
mockDebugger.connection.m_synchronizer.receivedEvent(new StepBreakpointsRemovedReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_123_RELOC, 0))));
mockDebugger.connection.m_synchronizer.receivedEvent(new StepBreakpointsRemovedReply(0, 1, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_123_RELOC, 1))));
mockDebugger.connection.m_synchronizer.receivedEvent(new SuspendThreadReply(0, 0, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new SuspendThreadReply(0, 1, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new TargetInformationReply(0, 0, TargetInformationParser.parse("<foo><size>32</size><registers></registers><options></options></foo>".getBytes())));
mockDebugger.connection.m_synchronizer.receivedEvent(new TargetInformationReply(0, 1, null));
mockDebugger.getProcessManager().addThread(new TargetProcessThread(0, ThreadState.RUNNING));
mockDebugger.connection.m_synchronizer.receivedEvent(new ThreadClosedReply(0, 0, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new ThreadClosedReply(0, 1, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new ThreadCreatedReply(0, 0, 0, ThreadState.RUNNING));
mockDebugger.connection.m_synchronizer.receivedEvent(new ThreadCreatedReply(0, 1, 0, null));
mockDebugger.connection.m_synchronizer.receivedEvent(new ValidateMemoryReply(0, 0, new CAddress(0), new CAddress(0)));
mockDebugger.connection.m_synchronizer.receivedEvent(new ValidateMemoryReply(0, 1, null, null));
mockDebugger.connection.m_synchronizer.receivedEvent(new WriteMemoryReply(0, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new WriteMemoryReply(0, 1));
mockDebugger.connection.m_synchronizer.receivedEvent(new TerminateReply(0, 0));
mockDebugger.connection.m_synchronizer.receivedEvent(new TerminateReply(0, 1));
}
Aggregations