use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress in project binnavi by google.
the class MockDebugger method setBreakPoints.
@Override
public void setBreakPoints(final Set<BreakpointAddress> breakpoints, final BreakpointType type) throws DebugExceptionWrapper {
requests += "SET_BREAKPOINTS/";
for (final BreakpointAddress breakpointAddress : breakpoints) {
requests += breakpointAddress.getAddress().getAddress().toHexString();
requests += "/";
requests += type;
}
requests += ";";
processCounter();
}
use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress in project binnavi by google.
the class CDebuggerFunctions method stepBlock.
/**
* Lets the debugger step to the next block.
*
* @param parent Parent window used for dialogs.
* @param debugger The debugger that steps to the next block.
* @param graph The graph where the step operation happens.
*/
public static void stepBlock(final JFrame parent, final IDebugger debugger, final ZyGraph graph) {
checkArguments(parent, debugger, graph);
if (!debugger.isConnected()) {
return;
}
final TargetProcessThread activeThread = debugger.getProcessManager().getActiveThread();
if (activeThread == null) {
return;
}
final RelocatedAddress currentAddress = activeThread.getCurrentAddress();
if (currentAddress == null) {
CMessageBox.showError(parent, "Could not step because the selected thread is not suspended");
return;
}
final UnrelocatedAddress oldAddress = debugger.memoryToFile(currentAddress);
final Set<BreakpointAddress> relocatedBlockAddresses = CStepBlockHelper.getNextBlocks(graph, oldAddress);
if (relocatedBlockAddresses.isEmpty()) {
CMessageBox.showError(parent, "Couldn't step to the next block");
return;
} else {
debugger.getProcessManager().setActiveThread(null);
final Set<BreakpointAddress> setBreakpoints = new HashSet<BreakpointAddress>();
debugger.getBreakpointManager().addBreakpoints(BreakpointType.STEP, relocatedBlockAddresses);
setBreakpoints.addAll(relocatedBlockAddresses);
try {
debugger.resume();
} catch (final DebugExceptionWrapper e) {
// TODO: Step breakpoints should be removed at this point
debugger.getProcessManager().setActiveThread(activeThread);
CUtilityFunctions.logException(e);
final String innerMessage = "E00045: " + "Could not send step block command to the debug client";
final String innerDescription = CUtilityFunctions.createDescription("BinNavi could not send the step block command to the debug client.", new String[] { "There was a problem with the connection to the debug client." }, new String[] { "The state of the debugged process remains unchanged." });
NaviErrorDialog.show(parent, innerMessage, innerDescription, e);
}
}
}
use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress in project binnavi by google.
the class CDebuggerFunctions method stepOver.
/**
* Lets the debugger step over the next instruction.
*
* @param parent Parent window used for dialogs.
* @param debugger The debugger that steps over the next instruction.
* @param graph The graph where the step operation happens.
*/
public static void stepOver(final JFrame parent, final IDebugger debugger, final ZyGraph graph) {
checkArguments(parent, debugger, graph);
if (!debugger.isConnected()) {
return;
}
final TargetProcessThread activeThread = debugger.getProcessManager().getActiveThread();
if (activeThread == null) {
return;
}
final RelocatedAddress currentAddress = activeThread.getCurrentAddress();
if (currentAddress == null) {
CMessageBox.showError(parent, "Could not step because the selected thread is not suspended");
return;
}
final UnrelocatedAddress oldAddress = debugger.memoryToFile(currentAddress);
final Set<BreakpointAddress> relocatedAddresses = CStepOverHelper.getNextInstructions(graph, oldAddress);
if (relocatedAddresses.isEmpty()) {
CMessageBox.showError(parent, "Couldn't step over the current instruction");
return;
} else {
debugger.getProcessManager().setActiveThread(null);
debugger.getBreakpointManager().addBreakpoints(BreakpointType.STEP, relocatedAddresses);
try {
debugger.resume();
} catch (final DebugExceptionWrapper e) {
// TODO: Step breakpoints should be removed at this point
debugger.getProcessManager().setActiveThread(activeThread);
CUtilityFunctions.logException(e);
final String innerMessage = "E00087: " + "Could not send step over command to the debug client";
final String innerDescription = CUtilityFunctions.createDescription("BinNavi could not send the step over command to the debug client.", new String[] { "There was a problem with the connection to the debug client." }, new String[] { "The state of the debugged process remains unchanged." });
NaviErrorDialog.show(parent, innerMessage, innerDescription, e);
}
}
}
use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress in project binnavi by google.
the class CStepEndHelper method getEndAddresses.
/**
* Returns the addresses of all final instructions of a graph.
*
* @param graph The graph whose final addresses are returned.
*
* @return The final addresses of the graph.
*/
public static Set<BreakpointAddress> getEndAddresses(final ZyGraph graph) {
final Set<BreakpointAddress> instructions = new HashSet<BreakpointAddress>();
graph.iterate(new INodeCallback<NaviNode>() {
@Override
public IterationMode next(final NaviNode node) {
if ((node.getRawNode() instanceof INaviCodeNode) && node.getChildren().isEmpty()) {
final INaviCodeNode cnode = (INaviCodeNode) node.getRawNode();
final INaviInstruction lastInstruction = Iterables.getLast(cnode.getInstructions());
instructions.add(new BreakpointAddress(lastInstruction.getModule(), new UnrelocatedAddress(lastInstruction.getAddress())));
}
return IterationMode.CONTINUE;
}
});
return instructions;
}
use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress in project binnavi by google.
the class CStepOverHelper method stepInCodeNode.
/**
* Adds the addresses of a instructions that follow another instruction to a list when
* single-stepping in a code node.
*
* @param node The code node where the step over operation happens.
* @param address The address in question.
* @param instructions List to extend with the successor instructions.
*/
private static void stepInCodeNode(final INaviCodeNode node, final UnrelocatedAddress address, final Set<BreakpointAddress> instructions) {
final int instructionIndex = CCodeNodeHelpers.getInstruction(node, address.getAddress());
if (instructionIndex != -1) {
if (instructionIndex < node.instructionCount() - 1) {
// ... and the basic block is large enough that the following
// instruction is also part of the basic block.
final INaviInstruction instruction = Iterables.get(node.getInstructions(), instructionIndex + 1);
instructions.add(new BreakpointAddress(instruction.getModule(), new UnrelocatedAddress(instruction.getAddress())));
} else {
// ... but the instruction is the last instruction of the basic block,
// so we have to look into the child nodes of the basic block.
instructions.addAll(CSteppingHelper.getSuccessors(node));
}
}
}
Aggregations