use of com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress in project binnavi by google.
the class CBreakpointFunctionsTest method test2DeleteBreakpoints.
@Test
public void test2DeleteBreakpoints() {
final INaviModule mockModule = new MockModule();
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(0)))));
final Breakpoint breakPoint = debugger.getBreakpointManager().getBreakpoint(BreakpointType.REGULAR, new BreakpointAddress(mockModule, new UnrelocatedAddress(new CAddress(0))));
@SuppressWarnings("unused") final CAddress address = new CAddress(0);
final BaseNode root = new BaseNode();
final BreakpointCondition bpCondition = new BreakpointCondition("foo", root);
breakPoint.setCondition(bpCondition);
breakPoint.setDescription("purzel");
debuggerProvider.addDebugger(debugger);
final CBreakpointTableModel tableModel = new CBreakpointTableModel(debuggerProvider);
final int[] rows = { 0 };
assertEquals(1, tableModel.getRowCount());
CBreakpointRemoveFunctions.deleteBreakpoints(debuggerProvider, rows);
assertEquals(0, tableModel.getRowCount());
}
use of com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress in project binnavi by google.
the class Trace method addEvent.
// ! Adds an event to the trace.
/**
* Adds a regular breakpoint event to the trace.
*
* @param tid The thread ID of the thread that caused the event.
* @param module The module the address belongs to. This argument can be null.
* @param address The address of the event.
* @param type Type of the event.
*/
public void addEvent(final int tid, final Module module, final Address address, final TraceEventType type) {
Preconditions.checkNotNull(address, "Error: Address argument can not be null");
trace.addEvent(new com.google.security.zynamics.binnavi.debug.models.trace.TraceEvent(tid, new BreakpointAddress(module == null ? null : module.getNative(), new UnrelocatedAddress(new CAddress(address.toLong()))), type.getNative(), new ArrayList<com.google.security.zynamics.binnavi.debug.models.trace.TraceRegister>()));
}
use of com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress in project binnavi by google.
the class BreakpointHelpers method getBreakpoints.
/**
* Returns the addresses of a view where breakpoints are set.
*
* @param debugger The debugger that set the breakpoint.
* @param view The view to search through.
* @param type Type of the breakpoints to search for.
*
* @return The addresses of the view where breakpoints of a given type are set.
*/
private static List<Address> getBreakpoints(final Debugger debugger, final View view, final BreakpointType type) {
Preconditions.checkNotNull(debugger, "Error: Debugger argument can not be null");
Preconditions.checkNotNull(view, "Error: View argument can not be null");
final BreakpointManager manager = debugger.getBreakpointManager();
final List<Address> breakpoints = new ArrayList<Address>();
for (final ViewNode node : view.getGraph().getNodes()) {
if (node instanceof CodeNode) {
breakpoints.addAll(getBreakpoints(debugger, (CodeNode) node, type));
} else if (node instanceof FunctionNode) {
final FunctionNode fnode = (FunctionNode) node;
final BreakpointAddress address = new BreakpointAddress(fnode.getFunction().getNative().getModule(), new UnrelocatedAddress(fnode.getFunction().getNative().getAddress()));
if (manager.getNative().hasBreakpoint(type, address)) {
breakpoints.add(new Address(address.getAddress().getAddress().toBigInteger()));
}
}
}
return breakpoints;
}
use of com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress in project binnavi by google.
the class BreakpointManager method removeBreakpoint.
// ! Removes a regular breakpoint.
/**
* Removes a regular breakpoint from a given address.
*
* @param module The module the breakpoint is tied to. This argument can be null.
* @param address The address of the breakpoint.
*/
public void removeBreakpoint(final Module module, final Address address) {
Preconditions.checkNotNull(address, "Error: Address argument can not be null");
final BreakpointStatus currentStatus = com.google.security.zynamics.binnavi.debug.models.breakpoints.enums.BreakpointStatus.BREAKPOINT_DELETING;
final BreakpointAddress breakpointAddress = new BreakpointAddress(module == null ? null : module.getNative(), new UnrelocatedAddress(new CAddress(address.toLong())));
breakpointManager.setBreakpointStatus(Sets.newHashSet(breakpointAddress), BreakpointType.REGULAR, currentStatus);
}
use of com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress in project binnavi by google.
the class BreakpointManager method getBreakpoint.
// ! Returns a regular breakpoint from a given address.
/**
* Returns the regular breakpoint at the given address.
*
* @param module The module the breakpoint belongs to. This argument can be null.
* @param address The address of the breakpoint to return.
*
* @return The breakpoint at the given address.
*/
public Breakpoint getBreakpoint(final Module module, final Address address) {
Preconditions.checkNotNull(address, "Error: Address argument can not be null");
final com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint internalBreakpoint = breakpointManager.getBreakpoint(BreakpointType.REGULAR, new BreakpointAddress(module == null ? null : module.getNative(), new UnrelocatedAddress(new CAddress(address.toLong()))));
return breakpointMap.get(internalBreakpoint);
}
Aggregations