diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/AsyncStacksToggleAction.kt b/java/debugger/impl/src/com/intellij/debugger/actions/AsyncStacksToggleAction.kt index 36505d6c83f7..6050ddd9e0c9 100644 --- a/java/debugger/impl/src/com/intellij/debugger/actions/AsyncStacksToggleAction.kt +++ b/java/debugger/impl/src/com/intellij/debugger/actions/AsyncStacksToggleAction.kt @@ -25,7 +25,7 @@ class AsyncStacksToggleAction : ToggleAction() { override fun update(e: AnActionEvent) { super.update(e) - e.presentation.isEnabledAndVisible = Registry.`is`("debugger.capture.points.agent") && DebuggerUtilsEx.isInJavaSession(e) + e.presentation.isEnabledAndVisible = DebuggerUtilsEx.isInJavaSession(e) } companion object { diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerManagerImpl.java b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerManagerImpl.java index 8ffa5546eba1..6623ec4d1a13 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerManagerImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerManagerImpl.java @@ -8,6 +8,7 @@ import com.intellij.debugger.settings.CaptureSettingsProvider; import com.intellij.debugger.settings.DebuggerSettings; import com.intellij.debugger.ui.GetJPDADialog; import com.intellij.debugger.ui.breakpoints.BreakpointManager; +import com.intellij.debugger.ui.breakpoints.StackCapturingLineBreakpoint; import com.intellij.debugger.ui.tree.render.BatchEvaluator; import com.intellij.execution.ExecutionException; import com.intellij.execution.ExecutionResult; @@ -499,7 +500,7 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent } private static void addDebuggerAgent(JavaParameters parameters) { - if (Registry.is("debugger.capture.points.agent")) { + if (StackCapturingLineBreakpoint.isAgentEnabled()) { String prefix = "-javaagent:"; String agentName = "debugger-agent.jar"; ParametersList parametersList = parameters.getVMParametersList(); diff --git a/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java b/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java index a3b62b557316..c969d6132bc1 100644 --- a/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java +++ b/java/debugger/impl/src/com/intellij/debugger/settings/CaptureConfigurable.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// 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. package com.intellij.debugger.settings; import com.intellij.debugger.DebuggerBundle; @@ -73,6 +59,7 @@ import java.util.List; public class CaptureConfigurable implements SearchableConfigurable { private static final Logger LOG = Logger.getInstance(CaptureConfigurable.class); + private JCheckBox myDebuggerAgent; private MyTableModel myTableModel; private JCheckBox myCaptureVariables; @@ -251,10 +238,21 @@ public class CaptureConfigurable implements SearchableConfigurable { }); BorderLayoutPanel panel = JBUI.Panels.simplePanel(); - panel.addToCenter(decorator.createPanel()); + myDebuggerAgent = new JCheckBox(DebuggerBundle.message("label.capture.configurable.debugger.agent")); + if (Registry.is("debugger.capture.points.agent")) { + panel.addToTop(myDebuggerAgent); + } + + BorderLayoutPanel debuggerPanel = JBUI.Panels.simplePanel(); + if (Registry.is("debugger.capture.points.agent")) { + debuggerPanel.setBorder(IdeBorderFactory.createTitledBorder("Breakpoints based", false)); + } + debuggerPanel.addToCenter(decorator.createPanel()); myCaptureVariables = new JCheckBox(DebuggerBundle.message("label.capture.configurable.capture.variables")); - panel.addToBottom(myCaptureVariables); + debuggerPanel.addToBottom(myCaptureVariables); + + panel.addToCenter(debuggerPanel); return panel; } @@ -494,6 +492,7 @@ public class CaptureConfigurable implements SearchableConfigurable { @Override public boolean isModified() { return DebuggerSettings.getInstance().CAPTURE_VARIABLES != myCaptureVariables.isSelected() || + DebuggerSettings.getInstance().INSTRUMENTING_AGENT != myDebuggerAgent.isSelected() || !DebuggerSettings.getInstance().getCapturePoints().equals(myTableModel.myCapturePoints); } @@ -501,11 +500,13 @@ public class CaptureConfigurable implements SearchableConfigurable { public void apply() throws ConfigurationException { DebuggerSettings.getInstance().setCapturePoints(myTableModel.myCapturePoints); DebuggerSettings.getInstance().CAPTURE_VARIABLES = myCaptureVariables.isSelected(); + DebuggerSettings.getInstance().INSTRUMENTING_AGENT = myDebuggerAgent.isSelected(); } @Override public void reset() { myCaptureVariables.setSelected(DebuggerSettings.getInstance().CAPTURE_VARIABLES); + myDebuggerAgent.setSelected(DebuggerSettings.getInstance().INSTRUMENTING_AGENT); myTableModel.myCapturePoints = DebuggerSettings.getInstance().cloneCapturePoints(); myTableModel.scanPoints(); myTableModel.fireTableDataChanged(); diff --git a/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerSettings.java b/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerSettings.java index af70ba8e1ca0..0ea7e96130f7 100644 --- a/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerSettings.java +++ b/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerSettings.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// 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. package com.intellij.debugger.settings; import com.intellij.debugger.impl.DebuggerUtilsEx; @@ -90,6 +76,7 @@ public class DebuggerSettings implements Cloneable, PersistentStateComponent myCapturePoints = new ArrayList<>(); public boolean CAPTURE_VARIABLES; private final EventDispatcher myDispatcher = EventDispatcher.create(CapturePointsSettingsListener.class); diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/StackCapturingLineBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/StackCapturingLineBreakpoint.java index a2d7202bb531..c44b60575e4c 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/StackCapturingLineBreakpoint.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/StackCapturingLineBreakpoint.java @@ -150,7 +150,7 @@ public class StackCapturingLineBreakpoint extends WildcardMethodBreakpoint { DebuggerManagerThreadImpl.assertIsManagerThread(); if (Registry.is("debugger.capture.points")) { StreamEx points = StreamEx.of(DebuggerSettings.getInstance().getCapturePoints()).filter(c -> c.myEnabled); - if (Registry.is("debugger.capture.points.agent")) { + if (isAgentEnabled()) { points = points.append(CaptureSettingsProvider.getIdeInsertPoints()); } points.forEach(c -> track(debugProcess, c)); @@ -240,7 +240,7 @@ public class StackCapturingLineBreakpoint extends WildcardMethodBreakpoint { boolean checkInProcessData) { DebugProcessImpl debugProcess = suspendContext.getDebugProcess(); Map> capturedStacks = debugProcess.getUserData(CAPTURED_STACKS); - if (ContainerUtil.isEmpty(capturedStacks) && !Registry.is("debugger.capture.points.agent")) { + if (ContainerUtil.isEmpty(capturedStacks) && !isAgentEnabled()) { return null; } List captureBreakpoints = debugProcess.getUserData(CAPTURE_BREAKPOINTS); @@ -443,4 +443,8 @@ public class StackCapturingLineBreakpoint extends WildcardMethodBreakpoint { myEvaluatorCache.clear(); } } + + public static boolean isAgentEnabled() { + return Registry.is("debugger.capture.points.agent") && DebuggerSettings.getInstance().INSTRUMENTING_AGENT; + } } diff --git a/resources-en/src/messages/DebuggerBundle.properties b/resources-en/src/messages/DebuggerBundle.properties index 291e8d4c578a..5fedb92836a2 100644 --- a/resources-en/src/messages/DebuggerBundle.properties +++ b/resources-en/src/messages/DebuggerBundle.properties @@ -258,6 +258,7 @@ label.threads.view.configurable.current.thread.on.top=Move current thread to the label.threads.view.configurable.show.stack.frames.for.synthetic.methods=Show stack &frames for synthetic methods label.threads.view.configurable.show.thread.groups=Show thread &groups label.capture.configurable.capture.variables=Capture local variables (may greatly slow down the execution) +label.capture.configurable.debugger.agent=Instrumenting agent (requires debugger restart) threads.view.configurable.display.name=Customize Threads View user.renderers.configurable.display.name=Java Type Renderers async.stacktraces.configurable.display.name=Async Stacktraces