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
|
||||
- Debugger
|
||||
- Zig compilation will no longer cause random IDE freezes
|
||||
- Debugging with GDB no longer causes random internal IDE warnings
|
||||
- LSP
|
||||
- Rare error when checking LSP presence
|
||||
|
||||
|
|
|
@ -31,12 +31,11 @@ public interface ZigDebuggerDriverConfigurationProvider {
|
|||
ExtensionPointName<ZigDebuggerDriverConfigurationProvider> EXTENSION_POINT_NAME = ExtensionPointName.create("com.falsepattern.zigbrains.debuggerDriverProvider");
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static @NotNull Stream<DebuggerDriverConfiguration> findDebuggerConfigurations(Project project, boolean isElevated, boolean emulateTerminal) {
|
||||
return (Stream<DebuggerDriverConfiguration>) EXTENSION_POINT_NAME.getExtensionList()
|
||||
static @NotNull Stream<Supplier<DebuggerDriverConfiguration>> findDebuggerConfigurations(Project project, boolean isElevated, boolean emulateTerminal) {
|
||||
return EXTENSION_POINT_NAME.getExtensionList()
|
||||
.stream()
|
||||
.map(it -> it.getDebuggerConfiguration(project, isElevated, emulateTerminal))
|
||||
.filter(Objects::nonNull)
|
||||
.map((Function<? super Supplier<DebuggerDriverConfiguration>, ?>) Supplier::get);
|
||||
.filter(Objects::nonNull);
|
||||
}
|
||||
|
||||
@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.RunContentDescriptor;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.util.concurrency.AppExecutorUtil;
|
||||
import com.intellij.xdebugger.XDebugProcess;
|
||||
import com.intellij.xdebugger.XDebugProcessStarter;
|
||||
import com.intellij.xdebugger.XDebugSession;
|
||||
|
@ -44,27 +45,24 @@ import org.jetbrains.annotations.NotNull;
|
|||
import org.jetbrains.annotations.Nullable;
|
||||
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 ZigDebugRunnerBase() {
|
||||
super(DefaultDebugExecutor.EXECUTOR_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecuteAsync(ProfileState state,
|
||||
private boolean doExecuteAsyncWithDriver(ProfileState state,
|
||||
AbstractZigToolchain toolchain,
|
||||
ExecutionEnvironment environment,
|
||||
AsyncPromise<@Nullable RunContentDescriptor> runContentDescriptorPromise)
|
||||
throws ExecutionException {
|
||||
val project = environment.getProject();
|
||||
val drivers = ZigDebuggerDriverConfigurationProvider.findDebuggerConfigurations(project, false, false)
|
||||
.toList();
|
||||
|
||||
for (val debuggerDriver: drivers) {
|
||||
if (debuggerDriver == null)
|
||||
continue;
|
||||
AsyncPromise<@Nullable RunContentDescriptor> runContentDescriptorPromise,
|
||||
DebuggerDriverConfiguration debuggerDriver) throws ExecutionException {
|
||||
ZigDebugParametersBase<ProfileState> runParameters = getDebugParameters(state, environment, debuggerDriver, toolchain);
|
||||
if (runParameters == null) {
|
||||
continue;
|
||||
return false;
|
||||
}
|
||||
val console = state.getConsoleBuilder().getConsole();
|
||||
if (runParameters instanceof PreLaunchAware pla) {
|
||||
|
@ -77,7 +75,7 @@ public abstract class ZigDebugRunnerBase<ProfileState extends ProfileStateBase<?
|
|||
val runContentDescriptor = runContentBuilder.showRunContent(null);
|
||||
runContentDescriptorPromise.setResult(runContentDescriptor);
|
||||
});
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
|
@ -100,9 +98,43 @@ public abstract class ZigDebugRunnerBase<ProfileState extends ProfileStateBase<?
|
|||
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;
|
||||
}
|
||||
runContentDescriptorPromise.setResult(null);
|
||||
|
||||
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
|
||||
protected void doExecuteAsync(ProfileState state,
|
||||
AbstractZigToolchain toolchain,
|
||||
ExecutionEnvironment environment,
|
||||
AsyncPromise<@Nullable RunContentDescriptor> runContentDescriptorPromise) {
|
||||
val project = environment.getProject();
|
||||
val drivers = ZigDebuggerDriverConfigurationProvider.findDebuggerConfigurations(project, false, false)
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
ApplicationManager.getApplication()
|
||||
.invokeLater(() -> doExecuteAsyncFetchNextDriver(state, toolchain, environment, runContentDescriptorPromise, drivers));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue