use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress in project binnavi by google.
the class CGraphDebugger method removeBreakpoint.
/**
* Removes a breakpoint from the given address.
*
* @param manager The breakpoint manager that sets the breakpoint.
* @param module The module where the breakpoint was set.
* @param unrelocatedAddress The unrelocated address of the breakpoint.
*/
public static void removeBreakpoint(final BreakpointManager manager, final INaviModule module, final UnrelocatedAddress unrelocatedAddress) {
Preconditions.checkNotNull(manager, "IE01710: Breakpoint manager argument can not be null");
Preconditions.checkNotNull(module, "IE01711: Module argument can not be null");
Preconditions.checkNotNull(unrelocatedAddress, "IE01712: Address argument can not be null");
final BreakpointAddress address = new BreakpointAddress(module, unrelocatedAddress);
if (manager.hasBreakpoint(BreakpointType.REGULAR, address)) {
removeBreakpoints(Sets.newHashSet(address), manager);
}
}
use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress in project binnavi by google.
the class CGraphDebugger method removeBreakpoints.
/**
* Removes a breakpoint from a breakpoint manager.
*
* @param addresses The address of the breakpoint to remove.
* @param manager The breakpoint manager from where the breakpoint is removed.
*/
public static void removeBreakpoints(final Set<BreakpointAddress> addresses, final BreakpointManager manager) {
Preconditions.checkNotNull(manager, "IE01708: Manager argument can not be null");
Preconditions.checkNotNull(addresses, "IE01709: Address argument can not be null");
final Set<BreakpointAddress> addressesToRemoveFromManager = new HashSet<BreakpointAddress>();
final Set<BreakpointAddress> addressesToRemoveFromDebugger = new HashSet<BreakpointAddress>();
for (final BreakpointAddress address : addresses) {
final BreakpointStatus status = manager.getBreakpointStatus(address, BreakpointType.REGULAR);
if ((status == BreakpointStatus.BREAKPOINT_DISABLED) || (status == BreakpointStatus.BREAKPOINT_INACTIVE)) {
addressesToRemoveFromManager.add(address);
}
if (status != BreakpointStatus.BREAKPOINT_DELETING) {
addressesToRemoveFromDebugger.add(address);
}
}
if (addressesToRemoveFromManager.size() != 0) {
manager.removeBreakpoints(BreakpointType.REGULAR, addressesToRemoveFromManager);
}
if (addressesToRemoveFromDebugger.size() != 0) {
manager.setBreakpointStatus(addressesToRemoveFromDebugger, BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_DELETING);
}
}
use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress in project binnavi by google.
the class CDebuggerFunctions method stepEnd.
/**
* Lets the debugger step to the end of the function.
*
* @param parent Parent window used for dialogs.
* @param debugger The debugger that steps to the end of the function.
* @param graph The graph where the step operation happens.
*/
public static void stepEnd(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 Set<BreakpointAddress> relocatedBlockAddresses = CStepEndHelper.getEndAddresses(graph);
if (relocatedBlockAddresses.isEmpty()) {
CMessageBox.showError(parent, "Couldn't step to the end of the function");
return;
} else {
debugger.getProcessManager().setActiveThread(null);
debugger.getBreakpointManager().addBreakpoints(BreakpointType.STEP, relocatedBlockAddresses);
try {
debugger.resume();
} catch (final DebugExceptionWrapper e) {
debugger.getBreakpointManager().removeBreakpoints(BreakpointType.STEP, relocatedBlockAddresses);
debugger.getProcessManager().setActiveThread(activeThread);
CUtilityFunctions.logException(e);
final String innerMessage = "E00086: " + "Could not send step end command to the debug client";
final String innerDescription = CUtilityFunctions.createDescription("BinNavi could not send the step end 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 CSteppingHelper method getAddress.
/**
* Determines the start address of a node.
*
* @param node Node whose address is determined.
*
* @return The start address of the given node or null if the node does not have an address.
*/
private static BreakpointAddress getAddress(final INaviViewNode node) {
if (node instanceof INaviCodeNode) {
final INaviCodeNode ccnode = (INaviCodeNode) node;
final INaviInstruction instruction = Iterables.getFirst(ccnode.getInstructions(), null);
return new BreakpointAddress(instruction.getModule(), new UnrelocatedAddress(instruction.getAddress()));
} else if (node instanceof INaviFunctionNode) {
final INaviFunction function = ((INaviFunctionNode) node).getFunction();
final INaviModule module = function.getModule();
return new BreakpointAddress(module, new UnrelocatedAddress(function.getAddress()));
} else {
// Node types we can not step to
return null;
}
}
use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress in project binnavi by google.
the class CBreakpointFunctionsTest method test6removeFunctions.
@Test
public void test6removeFunctions() throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
final MockFunction mockFunction = new MockFunction();
final INaviModule mockModule = mockFunction.getModule();
CFunctionContainerHelper.addFunction(mockModule.getContent().getFunctionContainer(), mockFunction);
final DebugTargetSettings target = new ModuleTargetSettings(mockModule);
final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(mockModule));
debugger.getBreakpointManager().addBreakpoints(BreakpointType.REGULAR, Sets.newHashSet(new BreakpointAddress(mockModule, new UnrelocatedAddress(new CAddress(0x1234)))));
@SuppressWarnings("unused") final Breakpoint breakPoint = debugger.getBreakpointManager().getBreakpoint(BreakpointType.REGULAR, new BreakpointAddress(mockModule, new UnrelocatedAddress(new CAddress(0x1234))));
debuggerProvider.addDebugger(debugger);
final CBreakpointTableModel tableModel = new CBreakpointTableModel(debuggerProvider);
assertEquals(1, tableModel.getRowCount());
final IFilledList<Pair<IDebugger, INaviFunction>> targets = new FilledList<Pair<IDebugger, INaviFunction>>();
final Pair<IDebugger, INaviFunction> targetPair = new Pair<IDebugger, INaviFunction>(debugger, mockFunction);
targets.add(targetPair);
assertEquals(1, targets.size());
CBreakpointRemoveFunctions.removeBreakpoints(targets);
@SuppressWarnings("unused") final BreakpointManager manager = debugger.getBreakpointManager();
assertEquals(0, tableModel.getRowCount());
}
Aggregations