Search in sources :

Example 1 with DebugExceptionWrapper

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

the class CDebuggerFunctions method stepEnd.

/**
 * Lets the debugger step to the end of the function.
 *
 * @param parent Parent window used for dialogs.
 * @param debugger The debugger that steps to the end of the function.
 * @param graph The graph where the step operation happens.
 */
public static void stepEnd(final JFrame parent, final IDebugger debugger, final ZyGraph graph) {
    checkArguments(parent, debugger, graph);
    if (!debugger.isConnected()) {
        return;
    }
    final TargetProcessThread activeThread = debugger.getProcessManager().getActiveThread();
    if (activeThread == null) {
        return;
    }
    final RelocatedAddress currentAddress = activeThread.getCurrentAddress();
    if (currentAddress == null) {
        CMessageBox.showError(parent, "Could not step because the selected thread is not suspended");
        return;
    }
    final Set<BreakpointAddress> relocatedBlockAddresses = CStepEndHelper.getEndAddresses(graph);
    if (relocatedBlockAddresses.isEmpty()) {
        CMessageBox.showError(parent, "Couldn't step to the end of the function");
        return;
    } else {
        debugger.getProcessManager().setActiveThread(null);
        debugger.getBreakpointManager().addBreakpoints(BreakpointType.STEP, relocatedBlockAddresses);
        try {
            debugger.resume();
        } catch (final DebugExceptionWrapper e) {
            debugger.getBreakpointManager().removeBreakpoints(BreakpointType.STEP, relocatedBlockAddresses);
            debugger.getProcessManager().setActiveThread(activeThread);
            CUtilityFunctions.logException(e);
            final String innerMessage = "E00086: " + "Could not send step end command to the debug client";
            final String innerDescription = CUtilityFunctions.createDescription("BinNavi could not send the step end command to the debug client.", new String[] { "There was a problem with the connection to the debug client." }, new String[] { "The state of the debugged process remains unchanged." });
            NaviErrorDialog.show(parent, innerMessage, innerDescription, e);
        }
    }
}
Also used : TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) DebugExceptionWrapper(com.google.security.zynamics.binnavi.debug.debugger.DebugExceptionWrapper) RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)

Example 2 with DebugExceptionWrapper

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

the class CDebuggerFunctions method sendDebuggerEventSettings.

public static void sendDebuggerEventSettings(final JFrame parent, final IDebugger debugger, final DebugTargetSettings debugTarget) {
    try {
        final DebuggerEventSettingsStorage eventSettingsStorage = new DebuggerEventSettingsStorage(debugger, debugTarget);
        debugger.setDebuggerEventSettings(eventSettingsStorage.deserialize());
    } catch (final DebugExceptionWrapper exception) {
        CUtilityFunctions.logException(exception);
        final String message = "Debugger event settings could not be sent to the debugger.";
        final String description = CUtilityFunctions.createDescription(String.format("BinNavi could not send the debugger event settings to the debug client."), new String[] {}, new String[] { "The default debugger event settings will be used during this session." });
        NaviErrorDialog.show(parent, message, description, exception);
    } catch (final CouldntLoadDataException exception) {
        CUtilityFunctions.logException(exception);
        final String message = "Debugger event settings could not be retrieved from the database.";
        final String description = CUtilityFunctions.createDescription(String.format("BinNavi could not send the debugger event settings to the debug client."), new String[] {}, new String[] { "The default debugger event settings will be used during this session." });
        NaviErrorDialog.show(parent, message, description, exception);
    }
}
Also used : DebuggerEventSettingsStorage(com.google.security.zynamics.binnavi.debug.models.storage.DebuggerEventSettingsStorage) DebugExceptionWrapper(com.google.security.zynamics.binnavi.debug.debugger.DebugExceptionWrapper) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)

Example 3 with DebugExceptionWrapper

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

the class ModuleUnloadedSynchronizer method handleSuccess.

@Override
protected void handleSuccess(final ModuleUnloadedReply reply) {
    final ProcessManager processManager = getDebugger().getProcessManager();
    final MemoryModule replyModule = reply.getModule();
    final MemoryModule existingModule = processManager.getModule(replyModule.getBaseAddress());
    if (existingModule == null) {
        processManager.removeNonExistingModule(replyModule);
    } else {
        processManager.removeModule(existingModule);
        CBreakpointModuleSynchronizer.disableEchoBreakpoints(getDebugger(), existingModule);
        CBreakpointModuleSynchronizer.disableRegularBreakpoints(getDebugger(), existingModule);
    }
    if (needsResume()) {
        try {
            getDebugger().resume();
        } catch (final DebugExceptionWrapper e) {
            NaviLogger.severe("Error: Could not resume the debugger. Exception: %s", e);
        }
    }
}
Also used : DebugExceptionWrapper(com.google.security.zynamics.binnavi.debug.debugger.DebugExceptionWrapper) ProcessManager(com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager) MemoryModule(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule)

Example 4 with DebugExceptionWrapper

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

the class ProcessStartSynchronizer method handleSuccess.

@Override
protected void handleSuccess(final ProcessStartReply reply) {
    final TargetProcessThread thread = reply.getProcessStart().getThread();
    final MemoryModule module = reply.getProcessStart().getModule();
    getDebugger().getProcessManager().addThread(thread);
    getDebugger().getProcessManager().setActiveThread(thread);
    refreshRegisters();
    CRelocationNotifier.relocateModule(getDebugger(), module);
    getDebugger().getProcessManager().addModule(module);
    CBreakpointModuleSynchronizer.enableRegularBreakpoints(getDebugger(), module);
    try {
        getDebugger().resume();
    } catch (final DebugExceptionWrapper e) {
        NaviLogger.severe("Error: Could not resume debugger. Exception: %s", e);
    }
}
Also used : TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) DebugExceptionWrapper(com.google.security.zynamics.binnavi.debug.debugger.DebugExceptionWrapper) MemoryModule(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule)

Example 5 with DebugExceptionWrapper

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

the class TargetInformationSynchronizer method handleSuccess.

@Override
protected void handleSuccess(final TargetInformationReply reply) {
    final IDebugger debugger = getDebugger();
    final ProcessManager processManager = getDebugger().getProcessManager();
    final TargetInformation info = reply.getTargetInformation();
    processManager.setTargetInformation(info);
    if (info.getDebuggerOptions().canMemmap()) {
        try {
            // As soon as we are attached to the target process, we
            // try to find out the memory structure of the target
            // process.
            debugger.getMemoryMap();
        } catch (final DebugExceptionWrapper e) {
            NaviLogger.severe("Error: Debugger could not get memory map. Exception %s", e);
            issueDebugException(e);
        }
    }
}
Also used : DebugExceptionWrapper(com.google.security.zynamics.binnavi.debug.debugger.DebugExceptionWrapper) TargetInformation(com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) ProcessManager(com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager)

Aggregations

DebugExceptionWrapper (com.google.security.zynamics.binnavi.debug.debugger.DebugExceptionWrapper)13 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)5 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)3 RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)3 MemoryModule (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule)2 ProcessManager (com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager)2 TargetInformation (com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation)2 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)2 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)2 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)1 CRemoteSelectionDialog (com.google.security.zynamics.binnavi.Gui.Debug.RemoteBrowser.CRemoteSelectionDialog)1 IDebugger (com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)1 ProcessDescription (com.google.security.zynamics.binnavi.debug.models.processlist.ProcessDescription)1 DebuggerEventSettingsStorage (com.google.security.zynamics.binnavi.debug.models.storage.DebuggerEventSettingsStorage)1 RegisterDescription (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription)1 File (java.io.File)1 HashSet (java.util.HashSet)1