Search in sources :

Example 26 with BreakpointAddress

use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress in project binnavi by google.

the class CBreakpointRemoveFunctions method disableAllView.

/**
   * Disables all breakpoints which are part of a view.
   * 
   * @param debuggerProvider Provides the debuggers where breakpoints can be set.
   * @param view The view to consider when disabling the breakpoints.
   */
public static void disableAllView(final BackEndDebuggerProvider debuggerProvider, final INaviView view) {
    Preconditions.checkNotNull(debuggerProvider, "IE01889: Debugger provider argument can not be null");
    Preconditions.checkNotNull(view, "IE02009: View argument can't be null");
    for (final IDebugger debugger : debuggerProvider) {
        final BreakpointManager manager = debugger.getBreakpointManager();
        final Set<BreakpointAddress> addressesToDisable = new HashSet<BreakpointAddress>();
        for (int i = 0; i < manager.getNumberOfBreakpoints(BreakpointType.REGULAR); i++) {
            final BreakpointAddress address = manager.getBreakpoint(BreakpointType.REGULAR, i).getAddress();
            if (CViewHelpers.containsAddress(view, address.getAddress())) {
                addressesToDisable.add(address);
            }
        }
        manager.setBreakpointStatus(addressesToDisable, BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_DISABLED);
    }
}
Also used : BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) BreakpointManager(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) Breakpoint(com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint) HashSet(java.util.HashSet)

Example 27 with BreakpointAddress

use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress in project binnavi by google.

the class CBreakpointRemoveFunctions method deleteBreakpoints.

/**
   * Deletes the breakpoints specified by the rows argument.
   * 
   * @param debuggerProvider Provides the debuggers where breakpoints can be set.
   * @param rows Rows that identify the breakpoints.
   */
public static void deleteBreakpoints(final BackEndDebuggerProvider debuggerProvider, final int[] rows) {
    Preconditions.checkNotNull(debuggerProvider, "IE01886: Debugger provider argument can not be null");
    Preconditions.checkNotNull(rows, "IE02253: Rows argument can't be null");
    final ArrayList<Pair<IDebugger, BreakpointAddress>> addresses = new ArrayList<Pair<IDebugger, BreakpointAddress>>();
    for (final int row : rows) {
        final Pair<IDebugger, Integer> breakpoint = CBreakpointTableHelpers.findBreakpoint(debuggerProvider, row);
        final BreakpointManager manager = breakpoint.first().getBreakpointManager();
        final int breakpointIndex = breakpoint.second();
        addresses.add(new Pair<IDebugger, BreakpointAddress>(breakpoint.first(), manager.getBreakpoint(BreakpointType.REGULAR, breakpointIndex).getAddress()));
    }
    for (final Pair<IDebugger, BreakpointAddress> p : addresses) {
        final BreakpointManager manager = p.first().getBreakpointManager();
        final BreakpointAddress address = p.second();
        manager.setBreakpointStatus(Sets.newHashSet(address), BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_DELETING);
    }
}
Also used : ArrayList(java.util.ArrayList) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) BreakpointManager(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) Breakpoint(com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint) Pair(com.google.security.zynamics.zylib.general.Pair)

Example 28 with BreakpointAddress

use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress in project binnavi by google.

the class CBreakpointPainter method paintBreakpoints.

/**
   * Paints breakpoints into a function node.
   * 
   * @param manager The breakpoint manager that provides breakpoint information.
   * @param node The visible BinNavi node where the breakpoint is painted.
   * @param functionNode The function node that contains the raw data for the BinNavi node.
   */
public static void paintBreakpoints(final BreakpointManager manager, final NaviNode node, final INaviFunctionNode functionNode) {
    Preconditions.checkNotNull(manager, "IE02374: Manager argument can not be null");
    Preconditions.checkNotNull(node, "IE02375: Node argument can not be null");
    Preconditions.checkNotNull(functionNode, "IE02376: Code node argument can not be null");
    final INaviFunction function = functionNode.getFunction();
    final INaviModule module = function.getModule();
    final int FUNCTION_BREAKPOINT_LINE = 1;
    final BreakpointAddress address = new BreakpointAddress(module, new UnrelocatedAddress(function.getAddress()));
    if (manager.hasBreakpoint(BreakpointType.REGULAR, address)) {
        node.setHighlighting(CHighlightLayers.BREAKPOINT_LAYER, FUNCTION_BREAKPOINT_LINE, BreakpointManager.getBreakpointColor(manager.getBreakpointStatus(address, BreakpointType.REGULAR)));
    } else {
        // If there is no breakpoint, clear potential older breakpoint line.
        node.clearHighlighting(500, FUNCTION_BREAKPOINT_LINE);
    }
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction)

Example 29 with BreakpointAddress

use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress in project binnavi by google.

the class CBreakpointPainter method paintBreakpoints.

/**
   * Paints breakpoints into code nodes.
   * 
   * @param manager The breakpoint manager that provides breakpoint information.
   * @param node The visible BinNavi node where the breakpoint is painted.
   * @param codeNode The code node that contains the raw data for the BinNavi node.
   */
public static void paintBreakpoints(final BreakpointManager manager, final NaviNode node, final INaviCodeNode codeNode) {
    Preconditions.checkNotNull(manager, "IE02171: Manager argument can not be null");
    Preconditions.checkNotNull(node, "IE02172: Node argument can not be null");
    Preconditions.checkNotNull(codeNode, "IE02173: Code node argument can not be null");
    for (final INaviInstruction instruction : codeNode.getInstructions()) {
        final BreakpointAddress address = new BreakpointAddress(instruction.getModule(), new UnrelocatedAddress(instruction.getAddress()));
        final int line = CCodeNodeHelpers.instructionToLine(codeNode, instruction);
        if (manager.hasBreakpoint(BreakpointType.REGULAR, address)) {
            // Only the address is highlighted when breakpoints are set on instructions
            // visible in code nodes.
            final int addressCharacters = address.getAddress().getAddress().toHexString().length();
            node.setHighlighting(CHighlightLayers.BREAKPOINT_LAYER, line, 0, addressCharacters, BreakpointManager.getBreakpointColor(manager.getBreakpointStatus(address, BreakpointType.REGULAR)));
        } else {
            // If there is no breakpoint, clear potential older breakpoint line.
            node.clearHighlighting(CHighlightLayers.BREAKPOINT_LAYER, line);
        }
    }
}
Also used : UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

Example 30 with BreakpointAddress

use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress in project binnavi by google.

the class PostgreSQLProviderTest method testTraceFunctionsSave1.

@Test
public void testTraceFunctionsSave1() throws CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException {
    final INaviProject project = getProvider().createProject("SOME_PROJECT");
    getProvider().createTrace(project, "SOME_TRACE", "SOME_TRACE_DESCRIPTION");
    project.load();
    final TraceList trace = project.getContent().getTraces().get(0);
    final INaviModule module = getProvider().loadModules().get(0);
    module.load();
    final long tid = 0x1L;
    final UnrelocatedAddress address2 = new UnrelocatedAddress(new CAddress(0x1234));
    final BreakpointAddress address = new BreakpointAddress(module, address2);
    final TraceEventType type = TraceEventType.ECHO_BREAKPOINT;
    final List<TraceRegister> values = new ArrayList<>();
    final ITraceEvent event = new TraceEvent(tid, address, type, values);
    trace.addEvent(event);
    trace.setDescription("burzelbarf");
    PostgreSQLTraceFunctions.save((AbstractSQLProvider) getProvider(), trace);
    project.close();
    INaviProject project2 = null;
    for (final INaviProject cProject : getProvider().loadProjects()) {
        if (cProject.getConfiguration().getId() == project.getConfiguration().getId()) {
            project2 = cProject;
        }
    }
    getProvider().createTrace(project2, "SOME_TRACE_2", "SOME_TRACE_DESCRIPTION_2");
    project2.load();
    final TraceList trace2 = project2.getContent().getTraces().get(0);
    assertEquals("burzelbarf", trace2.getDescription());
}
Also used : TraceEventType(com.google.security.zynamics.binnavi.debug.models.trace.TraceEventType) ArrayList(java.util.ArrayList) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) TraceRegister(com.google.security.zynamics.binnavi.debug.models.trace.TraceRegister) TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) ITraceEvent(com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceEvent) ITraceEvent(com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceEvent) TraceEvent(com.google.security.zynamics.binnavi.debug.models.trace.TraceEvent) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

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