IDEA-142157 - show dumps as sub tabs of the process run tab

This commit is contained in:
Egor Ushakov
2018-10-23 12:03:22 +03:00
parent 2c1da471a5
commit c01597dda8
5 changed files with 27 additions and 13 deletions
@@ -52,7 +52,7 @@ public class ThreadDumpAction extends AnAction implements AnAction.TransparentUp
ApplicationManager.getApplication().invokeLater(() -> {
XDebugSession xSession = session.getXDebugSession();
if (xSession != null) {
DebuggerUtilsEx.addThreadDump(project, threads, xSession.getUI(), session);
DebuggerUtilsEx.addThreadDump(project, threads, xSession.getUI(), session.getSearchScope());
}
}, ModalityState.NON_MODAL);
}
@@ -44,6 +44,7 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.Navigatable;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.ui.classFilter.ClassFilter;
import com.intellij.ui.content.Content;
@@ -398,9 +399,9 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
private static int myThreadDumpsCount = 0;
public static void addThreadDump(Project project, List<ThreadState> threads, final RunnerLayoutUi ui, DebuggerSession session) {
public static void addThreadDump(Project project, List<ThreadState> threads, RunnerLayoutUi ui, GlobalSearchScope searchScope) {
final TextConsoleBuilder consoleBuilder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
consoleBuilder.filters(ExceptionFilters.getFilters(session.getSearchScope()));
consoleBuilder.filters(ExceptionFilters.getFilters(searchScope));
final ConsoleView consoleView = consoleBuilder.getConsole();
final DefaultActionGroup toolbarActions = new DefaultActionGroup();
consoleView.allowHeavyFilters();
@@ -3,6 +3,7 @@ package com.intellij.execution.impl;
import com.intellij.concurrency.JobScheduler;
import com.intellij.debugger.engine.JavaDebugProcess;
import com.intellij.debugger.impl.DebuggerUtilsEx;
import com.intellij.debugger.impl.attach.JavaDebuggerAttachUtil;
import com.intellij.debugger.impl.attach.PidRemoteConnection;
import com.intellij.debugger.settings.DebuggerSettings;
@@ -15,6 +16,7 @@ import com.intellij.execution.process.*;
import com.intellij.execution.runners.*;
import com.intellij.execution.ui.ExecutionConsole;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.execution.ui.layout.impl.RunnerContentUi;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
@@ -29,6 +31,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.io.StreamUtil;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.vfs.CharsetToolkit;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.unscramble.AnalyzeStacktraceUtil;
import com.intellij.unscramble.ThreadDumpConsoleFactory;
import com.intellij.unscramble.ThreadDumpParser;
@@ -146,7 +149,7 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
final JComponent consoleComponent = executionConsole != null ? executionConsole.getComponent() : null;
ProcessHandler processHandler = executionResult.getProcessHandler();
assert processHandler != null : executionResult;
final ControlBreakAction controlBreakAction = new ControlBreakAction(processHandler);
final ControlBreakAction controlBreakAction = new ControlBreakAction(processHandler, contentBuilder.getSearchScope());
if (consoleComponent != null) {
controlBreakAction.registerCustomShortcutSet(controlBreakAction.getShortcutSet(), consoleComponent);
processHandler.addProcessListener(new ProcessAdapter() {
@@ -198,8 +201,11 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
}
protected static class ControlBreakAction extends ProxyBasedAction {
public ControlBreakAction(final ProcessHandler processHandler) {
private final GlobalSearchScope mySearchScope;
public ControlBreakAction(final ProcessHandler processHandler, GlobalSearchScope searchScope) {
super(ExecutionBundle.message("run.configuration.dump.threads.action.name"), null, AllIcons.Actions.Dump, processHandler);
mySearchScope = searchScope;
setShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_CANCEL, InputEvent.CTRL_DOWN_MASK)));
}
@@ -210,7 +216,12 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
@Override
protected void perform(AnActionEvent event, ProcessProxy proxy) {
if (Registry.is("execution.dump.threads.using.attach") && myProcessHandler instanceof BaseProcessHandler) {
Project project = event.getProject();
if (project == null) {
return;
}
RunnerContentUi runnerContentUi = event.getData(RunnerContentUi.KEY);
if (Registry.is("execution.dump.threads.using.attach") && myProcessHandler instanceof BaseProcessHandler && runnerContentUi != null) {
// try vm attach first
VirtualMachine vm = null;
try {
@@ -218,7 +229,7 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
InputStream inputStream = ((HotSpotVirtualMachine)vm).remoteDataDump();
String text = StreamUtil.readText(inputStream, CharsetToolkit.UTF8_CHARSET);
List<ThreadState> threads = ThreadDumpParser.parse(text);
showThreadDump(text, threads, event.getProject());
DebuggerUtilsEx.addThreadDump(project, threads, runnerContentUi.getRunnerLayoutUi(), mySearchScope);
return;
}
catch (AttachNotSupportedException e) {
@@ -239,7 +250,7 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
}
boolean wise = Boolean.getBoolean(ourWiseThreadDumpProperty);
WiseDumpThreadsListener wiseListener = wise ? new WiseDumpThreadsListener(event.getProject(), myProcessHandler) : null;
WiseDumpThreadsListener wiseListener = wise ? new WiseDumpThreadsListener(project, myProcessHandler) : null;
proxy.sendBreak();
@@ -1,6 +1,4 @@
/*
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.runners;
import com.intellij.execution.ExecutionManager;
@@ -10,13 +8,13 @@ import com.intellij.execution.configurations.RunConfigurationBase;
import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.impl.ConsoleViewImpl;
import com.intellij.execution.ui.*;
import com.intellij.execution.ui.actions.CloseAction;
import com.intellij.execution.ui.layout.PlaceInGrid;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.tabs.PinToolwindowTabAction;
import com.intellij.util.SmartList;
@@ -194,4 +192,8 @@ public class RunContentBuilder extends RunTab {
}
}
}
public GlobalSearchScope getSearchScope() {
return mySearchScope;
}
}
@@ -31,7 +31,7 @@ public abstract class RunTab implements DataProvider, Disposable {
protected ExecutionEnvironment myEnvironment;
protected final Project myProject;
private final GlobalSearchScope mySearchScope;
protected final GlobalSearchScope mySearchScope;
private LogConsoleManagerBase logConsoleManager;