Search in sources :

Example 71 with BreakpointAddress

use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress 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());
}
Also used : Breakpoint(com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint) BaseNode(com.google.security.zynamics.binnavi.debug.models.breakpoints.conditions.BaseNode) CBreakpointTableModel(com.google.security.zynamics.binnavi.Gui.Debug.BreakpointTable.CBreakpointTableModel) DebugTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) DebuggerProvider(com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) BreakpointCondition(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointCondition) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) Test(org.junit.Test)

Example 72 with BreakpointAddress

use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress 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>()));
}
Also used : UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) ArrayList(java.util.ArrayList) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 73 with BreakpointAddress

use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress 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;
}
Also used : CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) Address(com.google.security.zynamics.binnavi.API.disassembly.Address) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) CodeNode(com.google.security.zynamics.binnavi.API.disassembly.CodeNode) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) ArrayList(java.util.ArrayList) FunctionNode(com.google.security.zynamics.binnavi.API.disassembly.FunctionNode) ViewNode(com.google.security.zynamics.binnavi.API.disassembly.ViewNode) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)

Example 74 with BreakpointAddress

use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress 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);
}
Also used : UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) BreakpointStatus(com.google.security.zynamics.binnavi.debug.models.breakpoints.enums.BreakpointStatus) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 75 with BreakpointAddress

use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress 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);
}
Also used : UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Aggregations

BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)87 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)60 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)49 Test (org.junit.Test)39 HashSet (java.util.HashSet)24 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)22 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)15 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)15 Breakpoint (com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint)15 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)13 Address (com.google.security.zynamics.binnavi.API.disassembly.Address)11 BreakpointManager (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager)11 TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)11 ArrayList (java.util.ArrayList)9 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)8 DebugTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings)8 DebuggerProvider (com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider)8 CBreakpointTableModel (com.google.security.zynamics.binnavi.Gui.Debug.BreakpointTable.CBreakpointTableModel)7 TraceLogger (com.google.security.zynamics.binnavi.debug.models.trace.TraceLogger)7 ITraceEvent (com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceEvent)7