fix: GDB warning spam fix
This commit is contained in:
parent
7f30c1aea4
commit
18adeffcce
3 changed files with 85 additions and 53 deletions
|
@ -28,6 +28,7 @@ Changelog structure reference:
|
||||||
- The process execution pipeline is now fully asynchronous
|
- The process execution pipeline is now fully asynchronous
|
||||||
- Debugger
|
- Debugger
|
||||||
- Zig compilation will no longer cause random IDE freezes
|
- Zig compilation will no longer cause random IDE freezes
|
||||||
|
- Debugging with GDB no longer causes random internal IDE warnings
|
||||||
- LSP
|
- LSP
|
||||||
- Rare error when checking LSP presence
|
- Rare error when checking LSP presence
|
||||||
|
|
||||||
|
|
|
@ -31,12 +31,11 @@ public interface ZigDebuggerDriverConfigurationProvider {
|
||||||
ExtensionPointName<ZigDebuggerDriverConfigurationProvider> EXTENSION_POINT_NAME = ExtensionPointName.create("com.falsepattern.zigbrains.debuggerDriverProvider");
|
ExtensionPointName<ZigDebuggerDriverConfigurationProvider> EXTENSION_POINT_NAME = ExtensionPointName.create("com.falsepattern.zigbrains.debuggerDriverProvider");
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
static @NotNull Stream<DebuggerDriverConfiguration> findDebuggerConfigurations(Project project, boolean isElevated, boolean emulateTerminal) {
|
static @NotNull Stream<Supplier<DebuggerDriverConfiguration>> findDebuggerConfigurations(Project project, boolean isElevated, boolean emulateTerminal) {
|
||||||
return (Stream<DebuggerDriverConfiguration>) EXTENSION_POINT_NAME.getExtensionList()
|
return EXTENSION_POINT_NAME.getExtensionList()
|
||||||
.stream()
|
.stream()
|
||||||
.map(it -> it.getDebuggerConfiguration(project, isElevated, emulateTerminal))
|
.map(it -> it.getDebuggerConfiguration(project, isElevated, emulateTerminal))
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull);
|
||||||
.map((Function<? super Supplier<DebuggerDriverConfiguration>, ?>) Supplier::get);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable Supplier<DebuggerDriverConfiguration> getDebuggerConfiguration(Project project, boolean isElevated, boolean emulateTerminal);
|
@Nullable Supplier<DebuggerDriverConfiguration> getDebuggerConfiguration(Project project, boolean isElevated, boolean emulateTerminal);
|
||||||
|
|
|
@ -33,6 +33,7 @@ import com.intellij.execution.runners.RunContentBuilder;
|
||||||
import com.intellij.execution.ui.ConsoleView;
|
import com.intellij.execution.ui.ConsoleView;
|
||||||
import com.intellij.execution.ui.RunContentDescriptor;
|
import com.intellij.execution.ui.RunContentDescriptor;
|
||||||
import com.intellij.openapi.application.ApplicationManager;
|
import com.intellij.openapi.application.ApplicationManager;
|
||||||
|
import com.intellij.util.concurrency.AppExecutorUtil;
|
||||||
import com.intellij.xdebugger.XDebugProcess;
|
import com.intellij.xdebugger.XDebugProcess;
|
||||||
import com.intellij.xdebugger.XDebugProcessStarter;
|
import com.intellij.xdebugger.XDebugProcessStarter;
|
||||||
import com.intellij.xdebugger.XDebugSession;
|
import com.intellij.xdebugger.XDebugSession;
|
||||||
|
@ -44,65 +45,96 @@ import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.concurrency.AsyncPromise;
|
import org.jetbrains.concurrency.AsyncPromise;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public abstract class ZigDebugRunnerBase<ProfileState extends ProfileStateBase<?>> extends ZigProgramRunnerBase<ProfileState> {
|
public abstract class ZigDebugRunnerBase<ProfileState extends ProfileStateBase<?>> extends ZigProgramRunnerBase<ProfileState> {
|
||||||
public ZigDebugRunnerBase() {
|
public ZigDebugRunnerBase() {
|
||||||
super(DefaultDebugExecutor.EXECUTOR_ID);
|
super(DefaultDebugExecutor.EXECUTOR_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean doExecuteAsyncWithDriver(ProfileState state,
|
||||||
|
AbstractZigToolchain toolchain,
|
||||||
|
ExecutionEnvironment environment,
|
||||||
|
AsyncPromise<@Nullable RunContentDescriptor> runContentDescriptorPromise,
|
||||||
|
DebuggerDriverConfiguration debuggerDriver) throws ExecutionException {
|
||||||
|
ZigDebugParametersBase<ProfileState> runParameters = getDebugParameters(state, environment, debuggerDriver, toolchain);
|
||||||
|
if (runParameters == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
val console = state.getConsoleBuilder().getConsole();
|
||||||
|
if (runParameters instanceof PreLaunchAware pla) {
|
||||||
|
val listener = new PreLaunchProcessListener(console);
|
||||||
|
pla.preLaunch(listener);
|
||||||
|
if (listener.isBuildFailed()) {
|
||||||
|
val executionResult = new DefaultExecutionResult(console, listener.getProcessHandler());
|
||||||
|
ApplicationManager.getApplication().invokeLater(() -> {
|
||||||
|
val runContentBuilder = new RunContentBuilder(executionResult, environment);
|
||||||
|
val runContentDescriptor = runContentBuilder.showRunContent(null);
|
||||||
|
runContentDescriptorPromise.setResult(runContentDescriptor);
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ApplicationManager.getApplication().invokeLater(() -> {
|
||||||
|
val debuggerManager = XDebuggerManager.getInstance(environment.getProject());
|
||||||
|
try {
|
||||||
|
val xDebugSession = debuggerManager.startSession(environment, new XDebugProcessStarter() {
|
||||||
|
@Override
|
||||||
|
public @NotNull XDebugProcess start(@NotNull XDebugSession session)
|
||||||
|
throws ExecutionException {
|
||||||
|
val project = session.getProject();
|
||||||
|
val textConsoleBuilder = new SharedConsoleBuilder(console);
|
||||||
|
val debugProcess = new ZigLocalDebugProcess(runParameters, session, textConsoleBuilder);
|
||||||
|
ProcessTerminatedListener.attach(debugProcess.getProcessHandler(), project);
|
||||||
|
debugProcess.start();
|
||||||
|
return debugProcess;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
runContentDescriptorPromise.setResult(xDebugSession.getRunContentDescriptor());
|
||||||
|
} catch (ExecutionException e) {
|
||||||
|
runContentDescriptorPromise.setError(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doExecuteAsyncFetchNextDriver(ProfileState state,
|
||||||
|
AbstractZigToolchain toolchain,
|
||||||
|
ExecutionEnvironment environment,
|
||||||
|
AsyncPromise<@Nullable RunContentDescriptor> runContentDescriptorPromise,
|
||||||
|
List<Supplier<DebuggerDriverConfiguration>> drivers) {
|
||||||
|
if (drivers.isEmpty()) {
|
||||||
|
runContentDescriptorPromise.setResult(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
val driverSupplier = drivers.removeFirst();
|
||||||
|
val driver = driverSupplier.get();
|
||||||
|
AppExecutorUtil.getAppExecutorService().execute(() -> {
|
||||||
|
try {
|
||||||
|
if (!doExecuteAsyncWithDriver(state, toolchain, environment, runContentDescriptorPromise, driver)) {
|
||||||
|
ApplicationManager.getApplication().invokeLater(() -> doExecuteAsyncFetchNextDriver(state, toolchain, environment, runContentDescriptorPromise, drivers));
|
||||||
|
}
|
||||||
|
} catch (ExecutionException e) {
|
||||||
|
runContentDescriptorPromise.setError(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doExecuteAsync(ProfileState state,
|
protected void doExecuteAsync(ProfileState state,
|
||||||
AbstractZigToolchain toolchain,
|
AbstractZigToolchain toolchain,
|
||||||
ExecutionEnvironment environment,
|
ExecutionEnvironment environment,
|
||||||
AsyncPromise<@Nullable RunContentDescriptor> runContentDescriptorPromise)
|
AsyncPromise<@Nullable RunContentDescriptor> runContentDescriptorPromise) {
|
||||||
throws ExecutionException {
|
|
||||||
val project = environment.getProject();
|
val project = environment.getProject();
|
||||||
val drivers = ZigDebuggerDriverConfigurationProvider.findDebuggerConfigurations(project, false, false)
|
val drivers = ZigDebuggerDriverConfigurationProvider.findDebuggerConfigurations(project, false, false)
|
||||||
.toList();
|
.collect(Collectors.toCollection(ArrayList::new));
|
||||||
|
|
||||||
for (val debuggerDriver: drivers) {
|
ApplicationManager.getApplication()
|
||||||
if (debuggerDriver == null)
|
.invokeLater(() -> doExecuteAsyncFetchNextDriver(state, toolchain, environment, runContentDescriptorPromise, drivers));
|
||||||
continue;
|
|
||||||
ZigDebugParametersBase<ProfileState> runParameters = getDebugParameters(state, environment, debuggerDriver, toolchain);
|
|
||||||
if (runParameters == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
val console = state.getConsoleBuilder().getConsole();
|
|
||||||
if (runParameters instanceof PreLaunchAware pla) {
|
|
||||||
val listener = new PreLaunchProcessListener(console);
|
|
||||||
pla.preLaunch(listener);
|
|
||||||
if (listener.isBuildFailed()) {
|
|
||||||
val executionResult = new DefaultExecutionResult(console, listener.getProcessHandler());
|
|
||||||
ApplicationManager.getApplication().invokeLater(() -> {
|
|
||||||
val runContentBuilder = new RunContentBuilder(executionResult, environment);
|
|
||||||
val runContentDescriptor = runContentBuilder.showRunContent(null);
|
|
||||||
runContentDescriptorPromise.setResult(runContentDescriptor);
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ApplicationManager.getApplication().invokeLater(() -> {
|
|
||||||
val debuggerManager = XDebuggerManager.getInstance(environment.getProject());
|
|
||||||
try {
|
|
||||||
val xDebugSession = debuggerManager.startSession(environment, new XDebugProcessStarter() {
|
|
||||||
@Override
|
|
||||||
public @NotNull XDebugProcess start(@NotNull XDebugSession session)
|
|
||||||
throws ExecutionException {
|
|
||||||
val project = session.getProject();
|
|
||||||
val textConsoleBuilder = new SharedConsoleBuilder(console);
|
|
||||||
val debugProcess = new ZigLocalDebugProcess(runParameters, session, textConsoleBuilder);
|
|
||||||
ProcessTerminatedListener.attach(debugProcess.getProcessHandler(), project);
|
|
||||||
debugProcess.start();
|
|
||||||
return debugProcess;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
runContentDescriptorPromise.setResult(xDebugSession.getRunContentDescriptor());
|
|
||||||
} catch (ExecutionException e) {
|
|
||||||
runContentDescriptorPromise.setError(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
runContentDescriptorPromise.setResult(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Reference in a new issue