use of com.google.security.zynamics.binnavi.debug.debugger.DebugExceptionWrapper 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.debugger.DebugExceptionWrapper in project binnavi by google.
the class CDebuggerFunctions method stepInto.
/**
* Lets the debugger execute a single step.
*
* @param parent Parent window used for dialogs.
* @param debugger The debugger that executes the single step.
*/
public static void stepInto(final JFrame parent, final IDebugger debugger) {
checkArguments(parent, debugger);
if (!debugger.isConnected()) {
return;
}
final TargetProcessThread activeThread = debugger.getProcessManager().getActiveThread();
try {
debugger.getProcessManager().setActiveThread(null);
debugger.singleStep();
} catch (final DebugExceptionWrapper e) {
CUtilityFunctions.logException(e);
debugger.getProcessManager().setActiveThread(activeThread);
final String innerMessage = "E00192: " + "Could not send single step command to the debug client";
final String innerDescription = CUtilityFunctions.createDescription("BinNavi could not send the single step 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.debugger.DebugExceptionWrapper in project binnavi by google.
the class Debugger method writeRegister.
// ! Writes a register value.
/**
* Changes the value of a register in the given thread.
*
* @param tid Thread ID of the thread whose register value is changed.
* @param register Name of the register to change.
* @param value The new value of the register.
*
* @throws DebugException Thrown if the message could not be sent to the debug client.
*/
public void writeRegister(final long tid, final String register, final long value) throws DebugException {
Preconditions.checkNotNull(register, "Error: Register argument can not be null");
Preconditions.checkNotNull(m_debugger.getProcessManager().getTargetInformation(), "Error: Target information string has not yet been received");
final List<RegisterDescription> registers = m_debugger.getProcessManager().getTargetInformation().getRegisters();
int index = 0;
for (final RegisterDescription description : registers) {
if (description.getName().equalsIgnoreCase(register)) {
if (!description.isEditable()) {
throw new IllegalArgumentException("Error: Selected register can not be edited");
}
break;
}
index++;
}
if (index == registers.size()) {
throw new IllegalArgumentException("Error: Unknown register name");
}
try {
m_debugger.setRegister(tid, index, BigInteger.valueOf(value));
} catch (final DebugExceptionWrapper e) {
throw new DebugException(e);
}
}
Aggregations