Search in sources :

Example 1 with DebuggerCommandException

use of com.jetbrains.cidr.execution.debugger.backend.DebuggerCommandException in project intellij-plugins by JetBrains.

the class MotionValueRendererFactory method createRenderer.

@Nullable
@Override
public ValueRenderer createRenderer(@NotNull FactoryContext context) throws ExecutionException, DebuggerCommandException {
    try {
        LLValueData data = context.getLLValueData();
        if (data.isValidPointer()) {
            context.getEvaluationContext().evaluate(EvaluationContext.cast("rb_inspect(" + EvaluationContext.cast(data.getPointer(), "id") + ")", "id"));
            // we want ObjC renderers for our collections
            // Ruby collections are inheriting from native ones and don't have any useful instance variables
            final ValueRenderer collectionRenderer = new NSCollectionValueRenderer.Factory().createRenderer(context);
            return collectionRenderer != null ? collectionRenderer : new MotionObjectRenderer(context.getPhysicalValue());
        }
    } catch (DebuggerCommandException ignored) {
    }
    return null;
}
Also used : LLValueData(com.jetbrains.cidr.execution.debugger.backend.LLValueData) DebuggerCommandException(com.jetbrains.cidr.execution.debugger.backend.DebuggerCommandException) NSCollectionValueRenderer(com.jetbrains.cidr.execution.debugger.evaluation.renderers.NSCollectionValueRenderer) NSCollectionValueRenderer(com.jetbrains.cidr.execution.debugger.evaluation.renderers.NSCollectionValueRenderer) ValueRenderer(com.jetbrains.cidr.execution.debugger.evaluation.renderers.ValueRenderer) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with DebuggerCommandException

use of com.jetbrains.cidr.execution.debugger.backend.DebuggerCommandException in project clion-embedded-arm by elmot.

the class OpenOcdLauncher method createDebugProcess.

@NotNull
@Override
protected CidrDebugProcess createDebugProcess(@NotNull CommandLineState commandLineState, @NotNull XDebugSession xDebugSession) throws ExecutionException {
    Project project = commandLineState.getEnvironment().getProject();
    OpenOcdSettingsState ocdSettings = project.getComponent(OpenOcdSettingsState.class);
    CidrRemoteDebugParameters remoteDebugParameters = new CidrRemoteDebugParameters();
    remoteDebugParameters.setSymbolFile(findRunFile(commandLineState).getAbsolutePath());
    remoteDebugParameters.setRemoteCommand("tcp:localhost:" + ocdSettings.gdbPort);
    CPPToolchains.Toolchain toolchain = CPPToolchains.getInstance().getDefaultToolchain();
    if (toolchain == null) {
        throw new ExecutionException("Project toolchain is not defined. Please define it in the project settings.");
    }
    String gdbPath;
    toolchain = toolchain.copy();
    if (ocdSettings.shippedGdb) {
        gdbPath = PathManager.findBinFile("gdb/bin/gdb" + (OS.isWindows() ? ".exe" : "")).getAbsolutePath();
    } else {
        gdbPath = ocdSettings.gdbLocation;
    }
    CPPDebugger cppDebugger = CPPDebugger.create(CPPDebugger.Kind.CUSTOM_GDB, gdbPath);
    toolchain.setDebugger(cppDebugger);
    GDBDriverConfiguration gdbDriverConfiguration = new GDBDriverConfiguration(getProject(), toolchain);
    xDebugSession.stop();
    CidrRemoteGDBDebugProcess debugProcess = new CidrRemoteGDBDebugProcess(gdbDriverConfiguration, remoteDebugParameters, xDebugSession, commandLineState.getConsoleBuilder(), project1 -> new Filter[0]);
    debugProcess.getProcessHandler().addProcessListener(new ProcessAdapter() {

        @Override
        public void processWillTerminate(@NotNull ProcessEvent event, boolean willBeDestroyed) {
            super.processWillTerminate(event, willBeDestroyed);
            findOpenOcdAction(project).stopOpenOcd();
        }
    });
    debugProcess.getProcessHandler().putUserData(RESTART_KEY, new AnAction("Reset", "MCU Reset", IconLoader.findIcon("reset.png", OpenOcdLauncher.class)) {

        @Override
        public void actionPerformed(AnActionEvent e) {
            XDebugSession session = debugProcess.getSession();
            session.pause();
            debugProcess.postCommand(drv -> {
                try {
                    ProgressManager.getInstance().runProcess(() -> {
                        while (drv.getState() != DebuggerDriver.TargetState.SUSPENDED) {
                            Thread.yield();
                        }
                    }, null);
                    drv.executeConsoleCommand("monitor reset init");
                    session.resume();
                } catch (DebuggerCommandException exception) {
                    Informational.showFailedDownloadNotification(e.getProject());
                }
            });
        }
    });
    return debugProcess;
}
Also used : ExecutionConsole(com.intellij.execution.ui.ExecutionConsole) CPPDebugger(com.jetbrains.cidr.cpp.toolchains.CPPDebugger) ExecutionException(com.intellij.execution.ExecutionException) OSProcessHandler(com.intellij.execution.process.OSProcessHandler) PathManager(com.intellij.openapi.application.PathManager) TimeoutException(java.util.concurrent.TimeoutException) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) CidrDebugProcess(com.jetbrains.cidr.execution.debugger.CidrDebugProcess) CidrRemoteGDBDebugProcess(com.jetbrains.cidr.execution.debugger.remote.CidrRemoteGDBDebugProcess) DebuggerCommandException(com.jetbrains.cidr.execution.debugger.backend.DebuggerCommandException) Future(java.util.concurrent.Future) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) Project(com.intellij.openapi.project.Project) Messages(com.intellij.openapi.ui.Messages) CidrRemoteDebugParameters(com.jetbrains.cidr.execution.debugger.remote.CidrRemoteDebugParameters) XDebugSession(com.intellij.xdebugger.XDebugSession) OS(org.jdesktop.swingx.util.OS) CMakeAppRunConfiguration(com.jetbrains.cidr.cpp.execution.CMakeAppRunConfiguration) ProgressManager(com.intellij.openapi.progress.ProgressManager) CidrLauncher(com.jetbrains.cidr.execution.testing.CidrLauncher) GDBDriverConfiguration(com.jetbrains.cidr.cpp.execution.debugger.backend.GDBDriverConfiguration) CommandLineState(com.intellij.execution.configurations.CommandLineState) CPPToolchains(com.jetbrains.cidr.cpp.toolchains.CPPToolchains) Filter(com.intellij.execution.filters.Filter) Key(com.intellij.openapi.util.Key) DebuggerDriver(com.jetbrains.cidr.execution.debugger.backend.DebuggerDriver) AnAction(com.intellij.openapi.actionSystem.AnAction) File(java.io.File) ProcessHandler(com.intellij.execution.process.ProcessHandler) TimeUnit(java.util.concurrent.TimeUnit) ThrowableComputable(com.intellij.openapi.util.ThrowableComputable) List(java.util.List) IconLoader(com.intellij.openapi.util.IconLoader) STATUS(xyz.elmot.clion.openocd.OpenOcdComponent.STATUS) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) ProcessEvent(com.intellij.execution.process.ProcessEvent) ConfigurationException(com.intellij.openapi.options.ConfigurationException) NotNull(org.jetbrains.annotations.NotNull) XDebugSession(com.intellij.xdebugger.XDebugSession) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent) DebuggerCommandException(com.jetbrains.cidr.execution.debugger.backend.DebuggerCommandException) CPPToolchains(com.jetbrains.cidr.cpp.toolchains.CPPToolchains) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) CidrRemoteDebugParameters(com.jetbrains.cidr.execution.debugger.remote.CidrRemoteDebugParameters) AnAction(com.intellij.openapi.actionSystem.AnAction) GDBDriverConfiguration(com.jetbrains.cidr.cpp.execution.debugger.backend.GDBDriverConfiguration) CidrRemoteGDBDebugProcess(com.jetbrains.cidr.execution.debugger.remote.CidrRemoteGDBDebugProcess) Project(com.intellij.openapi.project.Project) CPPDebugger(com.jetbrains.cidr.cpp.toolchains.CPPDebugger) ExecutionException(com.intellij.execution.ExecutionException) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

DebuggerCommandException (com.jetbrains.cidr.execution.debugger.backend.DebuggerCommandException)2 ExecutionException (com.intellij.execution.ExecutionException)1 CommandLineState (com.intellij.execution.configurations.CommandLineState)1 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)1 Filter (com.intellij.execution.filters.Filter)1 OSProcessHandler (com.intellij.execution.process.OSProcessHandler)1 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)1 ProcessEvent (com.intellij.execution.process.ProcessEvent)1 ProcessHandler (com.intellij.execution.process.ProcessHandler)1 ExecutionConsole (com.intellij.execution.ui.ExecutionConsole)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 PathManager (com.intellij.openapi.application.PathManager)1 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 ProgressManager (com.intellij.openapi.progress.ProgressManager)1 Project (com.intellij.openapi.project.Project)1 Messages (com.intellij.openapi.ui.Messages)1 IconLoader (com.intellij.openapi.util.IconLoader)1 Key (com.intellij.openapi.util.Key)1 ThrowableComputable (com.intellij.openapi.util.ThrowableComputable)1