Search in sources :

Example 11 with IDebugger

use of com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger in project binnavi by google.

the class CStepIntoAction method actionPerformed.

@Override
public void actionPerformed(final ActionEvent event) {
    final IDebugger debugger = m_debugger.getCurrentSelectedDebugger();
    final TargetProcessThread activeThread = debugger == null ? null : debugger.getProcessManager().getActiveThread();
    if ((debugger != null) && (activeThread != null)) {
        CDebuggerFunctions.stepInto(m_parent, debugger);
    }
}
Also used : TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)

Example 12 with IDebugger

use of com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger in project binnavi by google.

the class CDebuggerToolbar method updateGui.

/**
 * Updates the GUI according to the currently available information about the target process.
 */
public void updateGui() {
    // Note: There is a reason for why we have to update the toolbar
    // from the outside. The toolbar can not update itself because
    // the toolbar state depends on the state of the TID box in the
    // debug panel.
    final IDebugger debugger = m_debugger.getCurrentSelectedDebugger();
    final TargetProcessThread activeThread = debugger == null ? null : debugger.getProcessManager().getActiveThread();
    final boolean connected = (debugger != null) && debugger.isConnected();
    final boolean suspended = connected && (activeThread != null);
    m_startAction.setEnabled(!connected);
    final boolean haltBeforeCommunicating = (debugger != null) && connected && (debugger.getProcessManager().getTargetInformation() != null) && debugger.getProcessManager().getTargetInformation().getDebuggerOptions().mustHaltBeforeCommunicating();
    m_detachAction.setEnabled(connected && (!haltBeforeCommunicating || suspended));
    m_terminateAction.setEnabled(connected);
    m_stepIntoAction.setEnabled(connected && suspended);
    m_stepIntoAction.setEnabled(connected && suspended);
    m_stepOverAction.setEnabled(connected && suspended);
    m_stepBlockAction.setEnabled(connected && suspended);
    m_stepEndAction.setEnabled(connected && suspended);
    m_resumeAction.setEnabled(connected && suspended);
    m_haltAction.setEnabled(connected && !suspended);
    final boolean tracing = (debugger != null) && m_debugger.getTraceLogger(debugger).hasEchoBreakpoints();
    m_startTraceAction.setEnabled(connected && (!haltBeforeCommunicating || suspended));
    m_stopTraceAction.setEnabled(connected && tracing && (!haltBeforeCommunicating || suspended));
}
Also used : TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)

Example 13 with IDebugger

use of com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger 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 14 with IDebugger

use of com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger in project binnavi by google.

the class CCodeNodeUpdater method initializeListeners.

/**
 * Initializes the listeners that are responsible for updating the code node.
 */
private void initializeListeners() {
    try {
        codeNode.getParentFunction().addListener(functionUpdater);
        codeNode.getParentFunction().getModule().addListener(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.
    }
    final HashMap<INaviInstruction, INaviFunction> referenceMap = CReferenceFinder.getCodeReferenceMap(codeNode);
    for (final INaviFunction functionReference : Sets.newHashSet(referenceMap.values())) {
        functionReference.addListener(functionUpdater);
    }
    codeNode.addListener(codeNodeListener);
    for (final INaviInstruction instruction : codeNode.getInstructions()) {
        instruction.addListener(instructionUpdater);
        for (final COperandTree tree : instruction.getOperands()) {
            for (final INaviOperandTreeNode currentNode : tree.getNodes()) {
                currentNode.addListener(operandTreeUpdater);
            }
        }
    }
    final Iterator<CTag> it = codeNode.getTagsIterator();
    while (it.hasNext()) {
        it.next().addListener(tagUpdater);
    }
    for (final IDebugger debugger : provider.getDebuggers()) {
        debugger.getProcessManager().addListener(debuggerUpdater);
    }
    provider.addListener(debuggerProviderListener);
    graph.getSettings().getDisplaySettings().addListener(settingsUpdater);
    try {
        codeNode.getParentFunction().getModule().getTypeManager().addListener(substitutionsUpdater);
    } catch (final MaybeNullException exception) {
    // If the code node doesn't have a a parent function, it is not in the database and therefore
    // cannot receive type substitutions.
    }
}
Also used : INaviOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode) MaybeNullException(com.google.security.zynamics.binnavi.Exceptions.MaybeNullException) COperandTree(com.google.security.zynamics.binnavi.disassembly.COperandTree) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

Example 15 with IDebugger

use of com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger in project binnavi by google.

the class CThreadInformationPanelTest method test3.

/**
 * This test makes sure that going from no debugger to a debugger to more threads works fine.
 */
@Test
public void test3() throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    // CGraphModelFactory.get(database,
    final IGraphModel graphModel = new MockGraphModel();
    // viewContainer);
    final CDebugPerspectiveModel model = CDebugPerspectiveModelFactory.get(graphModel);
    final CThreadInformationPanel panel = new CThreadInformationPanel(model);
    final IDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    final LinkedHashSet<?> perspectiveListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(model, "m_listeners"), "m_listeners");
    final LinkedHashSet<?> debuggerListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(ReflectionHelpers.getField(AbstractDebugger.class, debugger, "processManager"), "listeners"), "m_listeners");
    assertEquals(1, perspectiveListeners.size());
    assertEquals(1, debuggerListeners.size());
    model.setActiveDebugger(debugger);
    final TargetProcessThread thread = new TargetProcessThread(0, ThreadState.RUNNING);
    debugger.getProcessManager().addThread(thread);
    final LinkedHashSet<?> threadListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(thread, "listeners"), "m_listeners");
    assertEquals(2, threadListeners.size());
    assertEquals(2, threadListeners.size());
    assertEquals(2, debuggerListeners.size());
    debugger.getProcessManager().removeThread(thread);
    assertEquals(0, threadListeners.size());
    panel.dispose();
    assertEquals(0, threadListeners.size());
    assertEquals(1, debuggerListeners.size());
    assertEquals(0, perspectiveListeners.size());
}
Also used : LinkedHashSet(java.util.LinkedHashSet) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) CDebugPerspectiveModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.Panels.CDebugPerspectiveModel) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) AbstractDebugger(com.google.security.zynamics.binnavi.debug.debugger.AbstractDebugger) IGraphModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphModel) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) MockGraphModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.MockGraphModel) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) Test(org.junit.Test)

Aggregations

IDebugger (com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)62 BreakpointManager (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager)16 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)16 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)6 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)6 Breakpoint (com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint)6 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)6 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)6 Test (org.junit.Test)6 MemorySection (com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection)5 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)5 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)5 CDebugPerspectiveModel (com.google.security.zynamics.binnavi.Gui.GraphWindows.Panels.CDebugPerspectiveModel)4 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)4 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)4 BookmarkManager (com.google.security.zynamics.binnavi.models.Bookmarks.memory.BookmarkManager)4 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)4 Pair (com.google.security.zynamics.zylib.general.Pair)4 ArrayList (java.util.ArrayList)4 IGraphModel (com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphModel)3