Search in sources :

Example 41 with MaybeNullException

use of com.google.security.zynamics.binnavi.Exceptions.MaybeNullException in project binnavi by google.

the class CCrossReferencesPanel method processRemovedNode.

/**
 * Processes a removed node and updates the references list accordingly.
 *
 * @param node The node to remove.
 *
 * @return True, if the removed node was the last node with its parent function in the graph.
 */
private boolean processRemovedNode(final INaviViewNode node) {
    if (node instanceof INaviCodeNode) {
        final INaviCodeNode cnode = (INaviCodeNode) node;
        try {
            final INaviFunction targetFunction = cnode.getParentFunction();
            if (m_nodeCounter.containsKey(targetFunction)) {
                final int newCounter = m_nodeCounter.get(targetFunction) - 1;
                if (newCounter == 0) {
                    m_nodeCounter.remove(targetFunction);
                    final Set<CCrossReference> toDelete = new HashSet<CCrossReference>();
                    for (final CCrossReference reference : m_crossReferences) {
                        if (reference.getCalledFunction() == targetFunction) {
                            toDelete.add(reference);
                        }
                    }
                    m_crossReferences.removeAll(toDelete);
                    return true;
                } else {
                    m_nodeCounter.put(targetFunction, newCounter);
                }
            }
        // else
        // {
        // TODO: How is this even possible?
        // }
        } catch (final MaybeNullException exception) {
        // Code nodes that do not have a parent function can obviously not be called.
        }
    }
    return false;
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) MaybeNullException(com.google.security.zynamics.binnavi.Exceptions.MaybeNullException) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) HashSet(java.util.HashSet)

Example 42 with MaybeNullException

use of com.google.security.zynamics.binnavi.Exceptions.MaybeNullException in project binnavi by google.

the class CCodeNodeUpdater method removeListeners.

/**
 * Removes all listeners this class has attached.
 */
private void removeListeners() {
    try {
        codeNode.getParentFunction().removeListener(functionUpdater);
        codeNode.getParentFunction().getModule().removeListener(moduleUpdater);
    } catch (final MaybeNullException exception) {
    // The code nodes does not have a parent function, therefore the information
    // about the parent function is not shown in the code and does not have to
    // be processed when updating.
    }
    codeNode.removeListener(codeNodeListener);
    for (final INaviInstruction instruction : codeNode.getInstructions()) {
        instruction.removeListener(instructionUpdater);
    }
    final Iterator<CTag> it = codeNode.getTagsIterator();
    while (it.hasNext()) {
        it.next().removeListener(tagUpdater);
    }
    for (final IDebugger debugger : provider.getDebuggers()) {
        debugger.getProcessManager().removeListener(debuggerUpdater);
    }
    provider.removeListener(debuggerProviderListener);
    graph.getSettings().getDisplaySettings().removeListener(settingsUpdater);
}
Also used : MaybeNullException(com.google.security.zynamics.binnavi.Exceptions.MaybeNullException) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

Aggregations

MaybeNullException (com.google.security.zynamics.binnavi.Exceptions.MaybeNullException)42 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)11 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)11 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)10 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)8 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)7 SQLException (java.sql.SQLException)7 ProcessManager (com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager)6 CallableStatement (java.sql.CallableStatement)6 ArrayList (java.util.ArrayList)5 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)4 INaviFunctionNode (com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode)4 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)4 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)4 CouldntDeleteException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)3 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)3 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)3 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)3 CConnection (com.google.security.zynamics.binnavi.Database.CConnection)2 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)2