debugger agent: added a setting to enable/disable the agent

This commit is contained in:
Egor.Ushakov
2017-10-04 15:19:54 +03:00
parent 7c793ce173
commit cda282008c
6 changed files with 30 additions and 36 deletions
@@ -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 {
@@ -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();
@@ -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();
@@ -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<Ele
private ClassFilter[] mySteppingFilters = ClassFilter.EMPTY_ARRAY;
public boolean INSTRUMENTING_AGENT = true;
private List<CapturePoint> myCapturePoints = new ArrayList<>();
public boolean CAPTURE_VARIABLES;
private final EventDispatcher<CapturePointsSettingsListener> myDispatcher = EventDispatcher.create(CapturePointsSettingsListener.class);
@@ -150,7 +150,7 @@ public class StackCapturingLineBreakpoint extends WildcardMethodBreakpoint {
DebuggerManagerThreadImpl.assertIsManagerThread();
if (Registry.is("debugger.capture.points")) {
StreamEx<CapturePoint> 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<Object, List<StackFrameItem>> capturedStacks = debugProcess.getUserData(CAPTURED_STACKS);
if (ContainerUtil.isEmpty(capturedStacks) && !Registry.is("debugger.capture.points.agent")) {
if (ContainerUtil.isEmpty(capturedStacks) && !isAgentEnabled()) {
return null;
}
List<StackCapturingLineBreakpoint> 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;
}
}
@@ -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