use of com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue in project binnavi by google.
the class EchoBreakpointHitSynchronizer method handleSuccess.
@Override
protected void handleSuccess(final EchoBreakpointHitReply reply) {
final BreakpointManager manager = getDebugger().getBreakpointManager();
final long tid = reply.getThreadId();
for (final ThreadRegisters threadRegisters : reply.getRegisterValues()) {
if (tid == threadRegisters.getTid()) {
for (final RegisterValue registerValue : threadRegisters) {
if (registerValue.isPc()) {
final RelocatedAddress address = new RelocatedAddress(new CAddress(registerValue.getValue()));
manager.setBreakpointStatus(Sets.newHashSet(DebuggerHelpers.getBreakpointAddress(getDebugger(), address)), BreakpointType.ECHO, BreakpointStatus.BREAKPOINT_HIT);
break;
}
}
}
}
}
use of com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue 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.RegisterValue 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.RegisterValue 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());
}
use of com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue in project binnavi by google.
the class RegisterValuesParser method parseThreadNode.
/**
* Parses a single thread node.
*
* @param node The node to parse.
*
* @return The thread registers object created from the content of the node.
*
* @throws MessageParserException Thrown if parsing the thread node failed.
*/
private static ThreadRegisters parseThreadNode(final Node node) throws MessageParserException {
final List<RegisterValue> registerValues = new ArrayList<>();
final long tid = Long.valueOf(node.getAttributes().getNamedItem("id").getNodeValue());
final NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); ++i) {
final Node child = children.item(i);
final String registerName = getAttribute(child, "name");
final BigInteger registerValue = new BigInteger(getAttribute(child, "value"), 16);
final byte[] memory = MemoryStringParser.parseMemoryString(getAttribute(child, "memory"));
final boolean isPc = hasAttribute(child, "pc");
final boolean isSp = hasAttribute(child, "sp");
registerValues.add(new RegisterValue(registerName, registerValue, memory, isPc, isSp));
}
return new ThreadRegisters(tid, registerValues);
}
Aggregations