use of com.jetbrains.cidr.execution.debugger.remote.CidrRemoteDebugParameters 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;
}
Aggregations