use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread in project binnavi by google.
the class CFollowInDumpMenu method addFollowInDumpMenu.
/**
* Adds the menu that follow in dump menu for the clicked instruction.
*
* @param menu The code node menu that is extended.
* @param model The graph model that provides information about the graph.
* @param node The node whose menu is created.
* @param clickedObject The object that was clicked.
* @param y The y-coordinate of the click.
*/
public static void addFollowInDumpMenu(final JPopupMenu menu, final CGraphModel model, final NaviNode node, final Object clickedObject, final double y) {
Preconditions.checkNotNull(menu, "IE02371: menu argument can not be null");
Preconditions.checkNotNull(model, "IE02372: model argument can not be null");
Preconditions.checkNotNull(node, "IE02373: node argument can not be null");
final int line = node.positionToRow(y);
if (line == -1) {
return;
}
final INaviCodeNode codeNode = (INaviCodeNode) node.getRawNode();
final INaviInstruction instruction = CCodeNodeHelpers.lineToInstruction(codeNode, line);
if (instruction != null) {
final IDebugger debugger = CGraphDebugger.getDebugger(model.getDebuggerProvider(), instruction);
if ((debugger != null) && (clickedObject instanceof COperandTreeNode)) {
final TargetProcessThread activeThread = debugger.getProcessManager().getActiveThread();
if (activeThread != null) {
final CDebugPerspectiveModel viewModel = (CDebugPerspectiveModel) model.getGraphPanel().getViewModel().getModel(PerspectiveType.DebugPerspective);
final COperandTreeNode treeNode = (COperandTreeNode) clickedObject;
final boolean added = addFollowInDumpMenu(menu, viewModel, debugger, activeThread, instruction.getModule(), treeNode);
if (added) {
menu.addSeparator();
}
}
}
}
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread in project binnavi by google.
the class CDebuggerSynchronizerTest method testRemoveBreakpoint_Active.
@SuppressWarnings("unchecked")
@Test
public void testRemoveBreakpoint_Active() throws DebugExceptionWrapper {
mockDebugger.connect();
breakpointManager.addBreakpoints(BreakpointType.REGULAR, CommonTestObjects.BP_ADDRESS_456_SET);
breakpointManager.setBreakpointStatus(CommonTestObjects.BP_ADDRESS_456_SET, BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_ACTIVE);
mockDebugger.getProcessManager().addThread(new TargetProcessThread(123, ThreadState.SUSPENDED));
breakpointManager.setBreakpointStatus(CommonTestObjects.BP_ADDRESS_456_SET, BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_DELETING);
debuggerSynchronizer.receivedEvent(new BreakpointsRemovedReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_456_RELOC, 0))));
assertEquals(0, listener.exception);
assertEquals(0, breakpointManager.getNumberOfBreakpoints(BreakpointType.REGULAR));
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread in project binnavi by google.
the class CDebuggerSynchronizerTest method testStepBreakpointLifecycle.
/**
* This test is used to determine whether the step breakpoint lifecycle (Set Step BP -> Hit Step
* BP -> Remove Step BP) works correctly.
*
* @throws DebugExceptionWrapper Thrown if something goes wrong.
*/
@SuppressWarnings("unchecked")
@Test
public void testStepBreakpointLifecycle() throws DebugExceptionWrapper {
mockDebugger.connect();
final TargetProcessThread thread = new TargetProcessThread(0, ThreadState.RUNNING);
mockDebugger.getProcessManager().addThread(thread);
mockDebugger.getBreakpointManager().addBreakpoints(BreakpointType.STEP, CommonTestObjects.BP_ADDRESS_123_SET);
mockDebugger.getBreakpointManager().addBreakpoints(BreakpointType.STEP, CommonTestObjects.BP_ADDRESS_456_SET);
debuggerSynchronizer.receivedEvent(new StepBreakpointSetReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_123_RELOC, 0), new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_456_RELOC, 0))));
assertEquals(BreakpointStatus.BREAKPOINT_ACTIVE, mockDebugger.getBreakpointManager().getBreakpointStatus(CommonTestObjects.BP_ADDRESS_123, BreakpointType.STEP));
assertEquals(BreakpointStatus.BREAKPOINT_ACTIVE, mockDebugger.getBreakpointManager().getBreakpointStatus(CommonTestObjects.BP_ADDRESS_456, BreakpointType.STEP));
final RegisterValues registerValues = new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(0, Lists.newArrayList(new RegisterValue("esp", BigInteger.valueOf(0x123), new byte[0], true, false)))));
debuggerSynchronizer.receivedEvent(new StepBreakpointHitReply(0, 0, 0, registerValues));
listener.toString();
assertTrue(Iterables.isEmpty(mockDebugger.getBreakpointManager().getBreakpoints(BreakpointType.STEP)));
assertEquals(thread, mockDebugger.getProcessManager().getActiveThread());
assertEquals(0x123, thread.getCurrentAddress().getAddress().toLong());
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread in project binnavi by google.
the class CDebuggerSynchronizerTest method testHitBreakpoint_UnknownBreakpoint.
@Test
public void testHitBreakpoint_UnknownBreakpoint() throws MessageParserException {
mockDebugger.getProcessManager().addThread(new TargetProcessThread(123, ThreadState.SUSPENDED));
debuggerSynchronizer.receivedEvent(DebuggerMessageBuilder.buildRegularBreakpointHit(CommonTestObjects.BP_ADDRESS_456_RELOC));
assertEquals(0, listener.exception);
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread in project binnavi by google.
the class CDebuggerSynchronizerTest method testHandleExceptionOccured.
@Test
public void testHandleExceptionOccured() throws DebugExceptionWrapper, MaybeNullException {
mockDebugger.connect();
final TargetProcessThread thread = new TargetProcessThread(18, ThreadState.RUNNING);
mockDebugger.getProcessManager().addThread(thread);
debuggerSynchronizer.receivedEvent(new ExceptionOccurredReply(0, 0, 18, 5, CommonTestObjects.BP_ADDRESS_123_RELOC, "Test exception"));
assertEquals(thread, mockDebugger.getProcessManager().getActiveThread());
assertEquals(ThreadState.RUNNING, mockDebugger.getProcessManager().getThread(18).getState());
assertEquals(CommonTestObjects.BP_ADDRESS_123_RELOC, mockDebugger.getProcessManager().getThread(18).getCurrentAddress());
assertEquals("CONNECT;READREGS;", mockDebugger.requests);
assertEquals("EXCEPTION_OCCURRED/5;", listener.events);
}
Aggregations