Search in sources :

Example 11 with UnrelocatedAddress

use of com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress in project binnavi by google.

the class CGraphDebugger method toggleBreakpoint.

/**
   * Sets or removes a breakpoint from a function node.
   *
   * @param debuggerProvider Debugger provider that contains all possible debuggers for the function
   *        node.
   * @param functionNode Function node object where the breakpoint is set or removed.
   */
public static void toggleBreakpoint(final BackEndDebuggerProvider debuggerProvider, final INaviFunctionNode functionNode) {
    Preconditions.checkNotNull(debuggerProvider, "IE01721: Debugger provider argument can not be null");
    Preconditions.checkNotNull(functionNode, "IE01722: Function node argument can not be null");
    if (functionNode.getFunction().getType() == FunctionType.IMPORT) {
        // We can not set breakpoints on imported functions
        return;
    }
    final IDebugger debugger = getDebugger(debuggerProvider, functionNode);
    if (debugger == null) {
        return;
    }
    final INaviModule module = functionNode.getFunction().getModule();
    CGraphDebugger.toggleBreakpoint(debugger.getBreakpointManager(), module, new UnrelocatedAddress(functionNode.getFunction().getAddress()));
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)

Example 12 with UnrelocatedAddress

use of com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress 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 13 with UnrelocatedAddress

use of com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress 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 14 with UnrelocatedAddress

use of com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress in project binnavi by google.

the class ZyCodeNodeBuilder method buildFunctionLine.

/**
   * Builds the function line of a code node. This line gives information about the function from
   * where the code node originally came from.
   * 
   * @param node The node that provides the raw data.
   * @param content The node content where the function line is added.
   * @param modifier Calculates the address strings. This argument can be null.
   */
private static void buildFunctionLine(final INaviCodeNode node, final ZyLabelContent content, final INodeModifier modifier) {
    try {
        final INaviFunction parentFunction = node.getParentFunction();
        final String address = modifier == null ? parentFunction.getAddress().toHexString() : modifier.getAddress(parentFunction.getModule(), new UnrelocatedAddress(parentFunction.getAddress()), true);
        final String name = parentFunction.getName();
        content.addLineContent(new ZyLineContent(address + PADDING_AFTER_FUNCTION_ADDRESS + parentFunction.getModule().getConfiguration().getName() + "::" + name, BOLD_FONT, Lists.newArrayList(new CStyleRunData(0, -1, Color.BLACK)), null));
    } catch (final MaybeNullException exception) {
    // If there is no parent function, the parent function is not shown in the code node.
    }
}
Also used : CStyleRunData(com.google.security.zynamics.zylib.gui.zygraph.realizers.CStyleRunData) MaybeNullException(com.google.security.zynamics.binnavi.Exceptions.MaybeNullException) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction)

Example 15 with UnrelocatedAddress

use of com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress 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

UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)81 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)60 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)60 Test (org.junit.Test)49 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)28 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)15 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)15 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)13 Address (com.google.security.zynamics.binnavi.API.disassembly.Address)12 ArrayList (java.util.ArrayList)11 TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)10 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)9 HashSet (java.util.HashSet)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 Breakpoint (com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint)8 FilledList (com.google.security.zynamics.zylib.types.lists.FilledList)8 CBreakpointTableModel (com.google.security.zynamics.binnavi.Gui.Debug.BreakpointTable.CBreakpointTableModel)7 TraceLogger (com.google.security.zynamics.binnavi.debug.models.trace.TraceLogger)7