mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
continue debug NodeJs child processes as threads
This commit is contained in:
+6
-5
@@ -150,17 +150,18 @@ public class ToggleFieldBreakpointAction extends AnAction {
|
||||
if(selectedNode != null && selectedNode.getDescriptor() instanceof FieldDescriptorImpl) {
|
||||
final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(dataContext);
|
||||
final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
|
||||
if (debugProcess != null) { // if there is an active debugsession
|
||||
if (debugProcess != null) { // if there is an active debug session
|
||||
final Ref<SourcePosition> positionRef = new Ref<>(null);
|
||||
debugProcess.getManagerThread().invokeAndWait(new DebuggerContextCommandImpl(debuggerContext) {
|
||||
@Override
|
||||
public Priority getPriority() {
|
||||
return Priority.HIGH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void threadAction() {
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
public void run() {
|
||||
positionRef.set(SourcePositionProvider.getSourcePosition(selectedNode.getDescriptor(), project, debuggerContext));
|
||||
}
|
||||
ApplicationManager.getApplication().runReadAction(() -> {
|
||||
positionRef.set(SourcePositionProvider.getSourcePosition(selectedNode.getDescriptor(), project, debuggerContext));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
+121
-151
@@ -25,7 +25,10 @@ import com.intellij.debugger.DebuggerInvocationUtil;
|
||||
import com.intellij.debugger.engine.BreakpointStepMethodFilter;
|
||||
import com.intellij.debugger.engine.DebugProcessImpl;
|
||||
import com.intellij.debugger.engine.requests.RequestManagerImpl;
|
||||
import com.intellij.debugger.impl.*;
|
||||
import com.intellij.debugger.impl.DebuggerContextImpl;
|
||||
import com.intellij.debugger.impl.DebuggerContextListener;
|
||||
import com.intellij.debugger.impl.DebuggerManagerImpl;
|
||||
import com.intellij.debugger.impl.DebuggerSession;
|
||||
import com.intellij.debugger.ui.JavaDebuggerSupport;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -74,8 +77,8 @@ import java.util.Map;
|
||||
public class BreakpointManager {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.ui.breakpoints.BreakpointManager");
|
||||
|
||||
@NonNls private static final String MASTER_BREAKPOINT_TAGNAME = "master_breakpoint";
|
||||
@NonNls private static final String SLAVE_BREAKPOINT_TAGNAME = "slave_breakpoint";
|
||||
@NonNls private static final String MASTER_BREAKPOINT_TAG_NAME = "master_breakpoint";
|
||||
@NonNls private static final String SLAVE_BREAKPOINT_TAG_NAME = "slave_breakpoint";
|
||||
@NonNls private static final String DEFAULT_SUSPEND_POLICY_ATTRIBUTE_NAME = "default_suspend_policy";
|
||||
@NonNls private static final String DEFAULT_CONDITION_STATE_ATTRIBUTE_NAME = "default_condition_enabled";
|
||||
|
||||
@@ -144,19 +147,16 @@ public class BreakpointManager {
|
||||
}
|
||||
|
||||
public void editBreakpoint(final Breakpoint breakpoint, final Editor editor) {
|
||||
DebuggerInvocationUtil.swingInvokeLater(myProject, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
XBreakpoint xBreakpoint = breakpoint.myXBreakpoint;
|
||||
if (xBreakpoint instanceof XLineBreakpointImpl) {
|
||||
RangeHighlighter highlighter = ((XLineBreakpointImpl)xBreakpoint).getHighlighter();
|
||||
if (highlighter != null) {
|
||||
GutterIconRenderer renderer = highlighter.getGutterIconRenderer();
|
||||
if (renderer != null) {
|
||||
DebuggerSupport.getDebuggerSupport(JavaDebuggerSupport.class).getEditBreakpointAction().editBreakpoint(
|
||||
myProject, editor, breakpoint.myXBreakpoint, renderer
|
||||
);
|
||||
}
|
||||
DebuggerInvocationUtil.swingInvokeLater(myProject, () -> {
|
||||
XBreakpoint xBreakpoint = breakpoint.myXBreakpoint;
|
||||
if (xBreakpoint instanceof XLineBreakpointImpl) {
|
||||
RangeHighlighter highlighter = ((XLineBreakpointImpl)xBreakpoint).getHighlighter();
|
||||
if (highlighter != null) {
|
||||
GutterIconRenderer renderer = highlighter.getGutterIconRenderer();
|
||||
if (renderer != null) {
|
||||
DebuggerSupport.getDebuggerSupport(JavaDebuggerSupport.class).getEditBreakpointAction().editBreakpoint(
|
||||
myProject, editor, breakpoint.myXBreakpoint, renderer
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -242,24 +242,21 @@ public class BreakpointManager {
|
||||
public ExceptionBreakpoint addExceptionBreakpoint(@NotNull final String exceptionClassName, final String packageName) {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
final JavaExceptionBreakpointType type = XDebuggerUtil.getInstance().findBreakpointType(JavaExceptionBreakpointType.class);
|
||||
return ApplicationManager.getApplication().runWriteAction(new Computable<ExceptionBreakpoint>() {
|
||||
@Override
|
||||
public ExceptionBreakpoint compute() {
|
||||
XBreakpoint<JavaExceptionBreakpointProperties> xBreakpoint = XDebuggerManager.getInstance(myProject).getBreakpointManager()
|
||||
.addBreakpoint(type, new JavaExceptionBreakpointProperties(exceptionClassName, packageName));
|
||||
Breakpoint javaBreakpoint = getJavaBreakpoint(xBreakpoint);
|
||||
if (javaBreakpoint instanceof ExceptionBreakpoint) {
|
||||
ExceptionBreakpoint exceptionBreakpoint = (ExceptionBreakpoint)javaBreakpoint;
|
||||
exceptionBreakpoint.setQualifiedName(exceptionClassName);
|
||||
exceptionBreakpoint.setPackageName(packageName);
|
||||
addBreakpoint(exceptionBreakpoint);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("ExceptionBreakpoint Added");
|
||||
}
|
||||
return exceptionBreakpoint;
|
||||
return ApplicationManager.getApplication().runWriteAction((Computable<ExceptionBreakpoint>)() -> {
|
||||
XBreakpoint<JavaExceptionBreakpointProperties> xBreakpoint = XDebuggerManager.getInstance(myProject).getBreakpointManager()
|
||||
.addBreakpoint(type, new JavaExceptionBreakpointProperties(exceptionClassName, packageName));
|
||||
Breakpoint javaBreakpoint = getJavaBreakpoint(xBreakpoint);
|
||||
if (javaBreakpoint instanceof ExceptionBreakpoint) {
|
||||
ExceptionBreakpoint exceptionBreakpoint = (ExceptionBreakpoint)javaBreakpoint;
|
||||
exceptionBreakpoint.setQualifiedName(exceptionClassName);
|
||||
exceptionBreakpoint.setPackageName(packageName);
|
||||
addBreakpoint(exceptionBreakpoint);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("ExceptionBreakpoint Added");
|
||||
}
|
||||
return null;
|
||||
return exceptionBreakpoint;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -279,14 +276,9 @@ public class BreakpointManager {
|
||||
private <B extends XBreakpoint<?>> XLineBreakpoint addXLineBreakpoint(Class<? extends XBreakpointType<B,?>> typeCls, Document document, final int lineIndex) {
|
||||
final XBreakpointType<B, ?> type = XDebuggerUtil.getInstance().findBreakpointType(typeCls);
|
||||
final VirtualFile file = FileDocumentManager.getInstance().getFile(document);
|
||||
return ApplicationManager.getApplication().runWriteAction(new Computable<XLineBreakpoint>() {
|
||||
@Override
|
||||
public XLineBreakpoint compute() {
|
||||
return XDebuggerManager.getInstance(myProject).getBreakpointManager()
|
||||
.addLineBreakpoint((XLineBreakpointType)type, file.getUrl(), lineIndex,
|
||||
((XLineBreakpointType)type).createBreakpointProperties(file, lineIndex));
|
||||
}
|
||||
});
|
||||
return ApplicationManager.getApplication().runWriteAction((Computable<XLineBreakpoint>)() -> XDebuggerManager.getInstance(myProject).getBreakpointManager()
|
||||
.addLineBreakpoint((XLineBreakpointType)type, file.getUrl(), lineIndex,
|
||||
((XLineBreakpointType)type).createBreakpointProperties(file, lineIndex)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -317,107 +309,98 @@ public class BreakpointManager {
|
||||
doRead(parentNode);
|
||||
}
|
||||
else {
|
||||
myStartupManager.registerPostStartupActivity(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
doRead(parentNode);
|
||||
}
|
||||
});
|
||||
myStartupManager.registerPostStartupActivity(() -> doRead(parentNode));
|
||||
}
|
||||
}
|
||||
|
||||
private void doRead(@NotNull final Element parentNode) {
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
@Override
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public void run() {
|
||||
final Map<String, Breakpoint> nameToBreakpointMap = new THashMap<>();
|
||||
try {
|
||||
final List groups = parentNode.getChildren();
|
||||
for (final Object group1 : groups) {
|
||||
final Element group = (Element)group1;
|
||||
if (group.getName().equals(RULES_GROUP_NAME)) {
|
||||
continue;
|
||||
}
|
||||
// skip already converted
|
||||
if (group.getAttribute(CONVERTED_PARAM) != null) {
|
||||
continue;
|
||||
}
|
||||
final String categoryName = group.getName();
|
||||
final Key<Breakpoint> breakpointCategory = BreakpointCategory.lookup(categoryName);
|
||||
final String defaultPolicy = group.getAttributeValue(DEFAULT_SUSPEND_POLICY_ATTRIBUTE_NAME);
|
||||
final boolean conditionEnabled = Boolean.parseBoolean(group.getAttributeValue(DEFAULT_CONDITION_STATE_ATTRIBUTE_NAME, "true"));
|
||||
setBreakpointDefaults(breakpointCategory, new BreakpointDefaults(defaultPolicy, conditionEnabled));
|
||||
Element anyExceptionBreakpointGroup;
|
||||
if (!AnyExceptionBreakpoint.ANY_EXCEPTION_BREAKPOINT.equals(breakpointCategory)) {
|
||||
// for compatibility with previous format
|
||||
anyExceptionBreakpointGroup = group.getChild(AnyExceptionBreakpoint.ANY_EXCEPTION_BREAKPOINT.toString());
|
||||
//final BreakpointFactory factory = BreakpointFactory.getInstance(breakpointCategory);
|
||||
//if (factory != null) {
|
||||
for (Element breakpointNode : group.getChildren("breakpoint")) {
|
||||
//Breakpoint breakpoint = factory.createBreakpoint(myProject, breakpointNode);
|
||||
Breakpoint breakpoint = createBreakpoint(categoryName, breakpointNode);
|
||||
breakpoint.readExternal(breakpointNode);
|
||||
nameToBreakpointMap.put(breakpoint.getDisplayName(), breakpoint);
|
||||
}
|
||||
//}
|
||||
}
|
||||
else {
|
||||
anyExceptionBreakpointGroup = group;
|
||||
}
|
||||
ApplicationManager.getApplication().runReadAction(() -> {
|
||||
final Map<String, Breakpoint> nameToBreakpointMap = new THashMap<>();
|
||||
try {
|
||||
final List groups = parentNode.getChildren();
|
||||
for (final Object group1 : groups) {
|
||||
final Element group = (Element)group1;
|
||||
if (group.getName().equals(RULES_GROUP_NAME)) {
|
||||
continue;
|
||||
}
|
||||
// skip already converted
|
||||
if (group.getAttribute(CONVERTED_PARAM) != null) {
|
||||
continue;
|
||||
}
|
||||
final String categoryName = group.getName();
|
||||
final Key<Breakpoint> breakpointCategory = BreakpointCategory.lookup(categoryName);
|
||||
final String defaultPolicy = group.getAttributeValue(DEFAULT_SUSPEND_POLICY_ATTRIBUTE_NAME);
|
||||
final boolean conditionEnabled = Boolean.parseBoolean(group.getAttributeValue(DEFAULT_CONDITION_STATE_ATTRIBUTE_NAME, "true"));
|
||||
setBreakpointDefaults(breakpointCategory, new BreakpointDefaults(defaultPolicy, conditionEnabled));
|
||||
Element anyExceptionBreakpointGroup;
|
||||
if (!AnyExceptionBreakpoint.ANY_EXCEPTION_BREAKPOINT.equals(breakpointCategory)) {
|
||||
// for compatibility with previous format
|
||||
anyExceptionBreakpointGroup = group.getChild(AnyExceptionBreakpoint.ANY_EXCEPTION_BREAKPOINT.toString());
|
||||
//final BreakpointFactory factory = BreakpointFactory.getInstance(breakpointCategory);
|
||||
//if (factory != null) {
|
||||
for (Element breakpointNode : group.getChildren("breakpoint")) {
|
||||
//Breakpoint breakpoint = factory.createBreakpoint(myProject, breakpointNode);
|
||||
Breakpoint breakpoint = createBreakpoint(categoryName, breakpointNode);
|
||||
breakpoint.readExternal(breakpointNode);
|
||||
nameToBreakpointMap.put(breakpoint.getDisplayName(), breakpoint);
|
||||
}
|
||||
//}
|
||||
}
|
||||
else {
|
||||
anyExceptionBreakpointGroup = group;
|
||||
}
|
||||
|
||||
if (anyExceptionBreakpointGroup != null) {
|
||||
final Element breakpointElement = group.getChild("breakpoint");
|
||||
if (breakpointElement != null) {
|
||||
XBreakpointManager manager = XDebuggerManager.getInstance(myProject).getBreakpointManager();
|
||||
JavaExceptionBreakpointType type = XDebuggerUtil.getInstance().findBreakpointType(JavaExceptionBreakpointType.class);
|
||||
XBreakpoint<JavaExceptionBreakpointProperties> xBreakpoint = manager.getDefaultBreakpoint(type);
|
||||
Breakpoint breakpoint = getJavaBreakpoint(xBreakpoint);
|
||||
if (breakpoint != null) {
|
||||
breakpoint.readExternal(breakpointElement);
|
||||
addBreakpoint(breakpoint);
|
||||
}
|
||||
if (anyExceptionBreakpointGroup != null) {
|
||||
final Element breakpointElement = group.getChild("breakpoint");
|
||||
if (breakpointElement != null) {
|
||||
XBreakpointManager manager = XDebuggerManager.getInstance(myProject).getBreakpointManager();
|
||||
JavaExceptionBreakpointType type = XDebuggerUtil.getInstance().findBreakpointType(JavaExceptionBreakpointType.class);
|
||||
XBreakpoint<JavaExceptionBreakpointProperties> xBreakpoint = manager.getDefaultBreakpoint(type);
|
||||
Breakpoint breakpoint = getJavaBreakpoint(xBreakpoint);
|
||||
if (breakpoint != null) {
|
||||
breakpoint.readExternal(breakpointElement);
|
||||
addBreakpoint(breakpoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (InvalidDataException ignored) {
|
||||
}
|
||||
|
||||
final Element rulesGroup = parentNode.getChild(RULES_GROUP_NAME);
|
||||
if (rulesGroup != null) {
|
||||
final List<Element> rules = rulesGroup.getChildren("rule");
|
||||
for (Element rule : rules) {
|
||||
// skip already converted
|
||||
if (rule.getAttribute(CONVERTED_PARAM) != null) {
|
||||
continue;
|
||||
}
|
||||
final Element master = rule.getChild(MASTER_BREAKPOINT_TAGNAME);
|
||||
if (master == null) {
|
||||
continue;
|
||||
}
|
||||
final Element slave = rule.getChild(SLAVE_BREAKPOINT_TAGNAME);
|
||||
if (slave == null) {
|
||||
continue;
|
||||
}
|
||||
final Breakpoint masterBreakpoint = nameToBreakpointMap.get(master.getAttributeValue("name"));
|
||||
if (masterBreakpoint == null) {
|
||||
continue;
|
||||
}
|
||||
final Breakpoint slaveBreakpoint = nameToBreakpointMap.get(slave.getAttributeValue("name"));
|
||||
if (slaveBreakpoint == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean leaveEnabled = "true".equalsIgnoreCase(rule.getAttributeValue("leaveEnabled"));
|
||||
XDependentBreakpointManager dependentBreakpointManager = ((XBreakpointManagerImpl)getXBreakpointManager()).getDependentBreakpointManager();
|
||||
dependentBreakpointManager.setMasterBreakpoint(slaveBreakpoint.myXBreakpoint, masterBreakpoint.myXBreakpoint, leaveEnabled);
|
||||
//addBreakpointRule(new EnableBreakpointRule(BreakpointManager.this, masterBreakpoint, slaveBreakpoint, leaveEnabled));
|
||||
}
|
||||
}
|
||||
|
||||
DebuggerInvocationUtil.invokeLater(myProject, BreakpointManager.this::updateBreakpointsUI);
|
||||
}
|
||||
catch (InvalidDataException ignored) {
|
||||
}
|
||||
|
||||
final Element rulesGroup = parentNode.getChild(RULES_GROUP_NAME);
|
||||
if (rulesGroup != null) {
|
||||
final List<Element> rules = rulesGroup.getChildren("rule");
|
||||
for (Element rule : rules) {
|
||||
// skip already converted
|
||||
if (rule.getAttribute(CONVERTED_PARAM) != null) {
|
||||
continue;
|
||||
}
|
||||
final Element master = rule.getChild(MASTER_BREAKPOINT_TAG_NAME);
|
||||
if (master == null) {
|
||||
continue;
|
||||
}
|
||||
final Element slave = rule.getChild(SLAVE_BREAKPOINT_TAG_NAME);
|
||||
if (slave == null) {
|
||||
continue;
|
||||
}
|
||||
final Breakpoint masterBreakpoint = nameToBreakpointMap.get(master.getAttributeValue("name"));
|
||||
if (masterBreakpoint == null) {
|
||||
continue;
|
||||
}
|
||||
final Breakpoint slaveBreakpoint = nameToBreakpointMap.get(slave.getAttributeValue("name"));
|
||||
if (slaveBreakpoint == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean leaveEnabled = "true".equalsIgnoreCase(rule.getAttributeValue("leaveEnabled"));
|
||||
XDependentBreakpointManager dependentBreakpointManager = ((XBreakpointManagerImpl)getXBreakpointManager()).getDependentBreakpointManager();
|
||||
dependentBreakpointManager.setMasterBreakpoint(slaveBreakpoint.myXBreakpoint, masterBreakpoint.myXBreakpoint, leaveEnabled);
|
||||
//addBreakpointRule(new EnableBreakpointRule(BreakpointManager.this, masterBreakpoint, slaveBreakpoint, leaveEnabled));
|
||||
}
|
||||
}
|
||||
|
||||
DebuggerInvocationUtil.invokeLater(myProject, this::updateBreakpointsUI);
|
||||
});
|
||||
|
||||
myUIProperties.clear();
|
||||
@@ -462,12 +445,7 @@ public class BreakpointManager {
|
||||
|
||||
private <B extends XBreakpoint<?>> XBreakpoint createXBreakpoint(Class<? extends XBreakpointType<B, ?>> typeCls) {
|
||||
final XBreakpointType<B, ?> type = XDebuggerUtil.getInstance().findBreakpointType(typeCls);
|
||||
return ApplicationManager.getApplication().runWriteAction(new Computable<XBreakpoint>() {
|
||||
@Override
|
||||
public XBreakpoint compute() {
|
||||
return XDebuggerManager.getInstance(myProject).getBreakpointManager().addBreakpoint((XBreakpointType)type, type.createProperties());
|
||||
}
|
||||
});
|
||||
return ApplicationManager.getApplication().runWriteAction((Computable<XBreakpoint>)() -> XDebuggerManager.getInstance(myProject).getBreakpointManager().addBreakpoint((XBreakpointType)type, type.createProperties()));
|
||||
}
|
||||
|
||||
private <B extends XBreakpoint<?>> XLineBreakpoint createXLineBreakpoint(Class<? extends XBreakpointType<B, ?>> typeCls,
|
||||
@@ -503,11 +481,8 @@ public class BreakpointManager {
|
||||
if (breakpoint == null) {
|
||||
return;
|
||||
}
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
getXBreakpointManager().removeBreakpoint(breakpoint.myXBreakpoint);
|
||||
}
|
||||
ApplicationManager.getApplication().runWriteAction(() -> {
|
||||
getXBreakpointManager().removeBreakpoint(breakpoint.myXBreakpoint);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -523,17 +498,12 @@ public class BreakpointManager {
|
||||
|
||||
@NotNull
|
||||
public List<Breakpoint> getBreakpoints() {
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<List<Breakpoint>>() {
|
||||
return ApplicationManager.getApplication().runReadAction((Computable<List<Breakpoint>>)() -> ContainerUtil.mapNotNull(getXBreakpointManager().getAllBreakpoints(), new Function<XBreakpoint<?>, Breakpoint>() {
|
||||
@Override
|
||||
public List<Breakpoint> compute() {
|
||||
return ContainerUtil.mapNotNull(getXBreakpointManager().getAllBreakpoints(), new Function<XBreakpoint<?>, Breakpoint>() {
|
||||
@Override
|
||||
public Breakpoint fun(XBreakpoint<?> xBreakpoint) {
|
||||
return getJavaBreakpoint(xBreakpoint);
|
||||
}
|
||||
});
|
||||
public Breakpoint fun(XBreakpoint<?> xBreakpoint) {
|
||||
return getJavaBreakpoint(xBreakpoint);
|
||||
}
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+39
-6
@@ -17,6 +17,7 @@ package org.jetbrains.debugger
|
||||
|
||||
import com.intellij.execution.ExecutionResult
|
||||
import com.intellij.execution.process.ProcessHandler
|
||||
import com.intellij.openapi.application.runReadAction
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.util.Url
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
@@ -24,6 +25,7 @@ import com.intellij.util.io.socketConnection.ConnectionStatus
|
||||
import com.intellij.xdebugger.DefaultDebugProcessHandler
|
||||
import com.intellij.xdebugger.XDebugProcess
|
||||
import com.intellij.xdebugger.XDebugSession
|
||||
import com.intellij.xdebugger.XDebuggerManager
|
||||
import com.intellij.xdebugger.breakpoints.XBreakpointHandler
|
||||
import com.intellij.xdebugger.breakpoints.XBreakpointType
|
||||
import com.intellij.xdebugger.breakpoints.XLineBreakpoint
|
||||
@@ -184,29 +186,60 @@ abstract class DebugProcessImpl<C : VmConnection<*>>(session: XDebugSession,
|
||||
override fun checkCanInitBreakpoints(): Boolean {
|
||||
if (connection.state.status == ConnectionStatus.CONNECTED) {
|
||||
// breakpointsInitiated could be set in another thread and at this point work (init breakpoints) could be not yet performed
|
||||
return setBreakpoints(false)
|
||||
return initBreakpoints(false)
|
||||
}
|
||||
|
||||
if (connectedListenerAdded.compareAndSet(false, true)) {
|
||||
connection.stateChanged {
|
||||
if (it.status == ConnectionStatus.CONNECTED) {
|
||||
setBreakpoints(true)
|
||||
initBreakpoints(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
open protected fun setBreakpoints(setBreakpoints: Boolean): Boolean {
|
||||
return breakpointsInitiated.compareAndSet(false, true)
|
||||
protected fun initBreakpoints(setBreakpoints: Boolean): Boolean {
|
||||
if (breakpointsInitiated.compareAndSet(false, true)) {
|
||||
doInitBreakpoints(setBreakpoints)
|
||||
return true
|
||||
}
|
||||
else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun doInitBreakpoints(setBreakpoints: Boolean) {
|
||||
if (setBreakpoints) {
|
||||
beforeInitBreakpoints(vm!!)
|
||||
runReadAction { session.initBreakpoints() }
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun beforeInitBreakpoints(vm: Vm) {
|
||||
}
|
||||
|
||||
protected fun addChildVm(vm: Vm) {
|
||||
beforeInitBreakpoints(vm)
|
||||
|
||||
val breakpointManager = XDebuggerManager.getInstance(session.project).breakpointManager
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
for (breakpointHandler in breakpointHandlers) {
|
||||
if (breakpointHandler is LineBreakpointHandler) {
|
||||
val breakpoints = runReadAction { breakpointManager.getBreakpoints(breakpointHandler.breakpointTypeClass) }
|
||||
for (breakpoint in breakpoints) {
|
||||
breakpointHandler.manager.setBreakpoint(vm, breakpoint)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
class LineBreakpointHandler(breakpointTypeClass: Class<out XBreakpointType<out XLineBreakpoint<*>, *>>, private val manager: LineBreakpointManager)
|
||||
class LineBreakpointHandler(breakpointTypeClass: Class<out XBreakpointType<out XLineBreakpoint<*>, *>>, internal val manager: LineBreakpointManager)
|
||||
: XBreakpointHandler<XLineBreakpoint<*>>(breakpointTypeClass as Class<out XBreakpointType<XLineBreakpoint<*>, *>>) {
|
||||
override fun registerBreakpoint(breakpoint: XLineBreakpoint<*>) {
|
||||
manager.setBreakpoint(breakpoint)
|
||||
manager.setBreakpoint(manager.debugProcess.vm!!, breakpoint)
|
||||
}
|
||||
|
||||
override fun unregisterBreakpoint(breakpoint: XLineBreakpoint<*>, temporary: Boolean) {
|
||||
|
||||
+18
-20
@@ -28,38 +28,36 @@ import org.jetbrains.concurrency.Promise
|
||||
import org.jetbrains.concurrency.resolvedPromise
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
abstract class LineBreakpointManager(private val debugProcess: DebugProcessImpl<*>) {
|
||||
abstract class LineBreakpointManager(internal val debugProcess: DebugProcessImpl<*>) {
|
||||
private val ideToVmBreakpoints = THashMap<XLineBreakpoint<*>, MutableList<Breakpoint>>()
|
||||
protected val vmToIdeBreakpoints = THashMap<Breakpoint, MutableList<XLineBreakpoint<*>>>()
|
||||
|
||||
private val runToLocationBreakpoints = THashSet<Breakpoint>()
|
||||
private val lock = Object()
|
||||
|
||||
private val breakpointManager: BreakpointManager
|
||||
get() = debugProcess.vm!!.breakpointManager
|
||||
|
||||
open fun isAnyFirstLineBreakpoint(breakpoint: Breakpoint) = false
|
||||
|
||||
private val breakpointResolvedListenerAdded = AtomicBoolean()
|
||||
|
||||
fun setBreakpoint(breakpoint: XLineBreakpoint<*>) {
|
||||
fun setBreakpoint(vm: Vm, breakpoint: XLineBreakpoint<*>) {
|
||||
val target = synchronized (lock) { ideToVmBreakpoints[breakpoint] }
|
||||
if (target == null) {
|
||||
setBreakpoint(breakpoint, debugProcess.getLocationsForBreakpoint(breakpoint))
|
||||
setBreakpoint(vm, breakpoint, debugProcess.getLocationsForBreakpoint(breakpoint))
|
||||
}
|
||||
else {
|
||||
val breakpointManager = breakpointManager
|
||||
val breakpointManager = vm.breakpointManager
|
||||
for (vmBreakpoint in target) {
|
||||
if (!vmBreakpoint.enabled) {
|
||||
vmBreakpoint.enabled = true
|
||||
breakpointManager.flush(vmBreakpoint).rejected { debugProcess.session.updateBreakpointPresentation(breakpoint, AllIcons.Debugger.Db_invalid_breakpoint, it.message) }
|
||||
breakpointManager.flush(vmBreakpoint)
|
||||
.rejected { debugProcess.session.updateBreakpointPresentation(breakpoint, AllIcons.Debugger.Db_invalid_breakpoint, it.message) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun removeBreakpoint(breakpoint: XLineBreakpoint<*>, temporary: Boolean): Promise<*> {
|
||||
val disable = temporary && breakpointManager.getMuteMode() !== BreakpointManager.MUTE_MODE.NONE
|
||||
val disable = temporary && debugProcess.vm!!.breakpointManager.getMuteMode() !== BreakpointManager.MUTE_MODE.NONE
|
||||
beforeBreakpointRemoved(breakpoint, disable)
|
||||
return doRemoveBreakpoint(breakpoint, disable)
|
||||
}
|
||||
@@ -100,7 +98,7 @@ abstract class LineBreakpointManager(private val debugProcess: DebugProcessImpl<
|
||||
return resolvedPromise()
|
||||
}
|
||||
|
||||
val breakpointManager = breakpointManager
|
||||
val breakpointManager = debugProcess.vm!!.breakpointManager
|
||||
val promises = SmartList<Promise<*>>()
|
||||
if (disable) {
|
||||
for (vmBreakpoint in vmBreakpoints) {
|
||||
@@ -116,14 +114,14 @@ abstract class LineBreakpointManager(private val debugProcess: DebugProcessImpl<
|
||||
return Promise.all(promises)
|
||||
}
|
||||
|
||||
fun setBreakpoint(breakpoint: XLineBreakpoint<*>, locations: List<Location>, promiseRef: Ref<Promise<out Breakpoint>>? = null) {
|
||||
fun setBreakpoint(vm: Vm, breakpoint: XLineBreakpoint<*>, locations: List<Location>, promiseRef: Ref<Promise<out Breakpoint>>? = null) {
|
||||
if (locations.isEmpty()) {
|
||||
return
|
||||
}
|
||||
|
||||
val vmBreakpoints = SmartList<Breakpoint>()
|
||||
for (location in locations) {
|
||||
doSetBreakpoint(breakpoint, location, false, promiseRef)?.let { vmBreakpoints.add(it) }
|
||||
doSetBreakpoint(vm, breakpoint, location, false, promiseRef)?.let { vmBreakpoints.add(it) }
|
||||
}
|
||||
synchronized (lock) {
|
||||
ideToVmBreakpoints.put(breakpoint, vmBreakpoints)
|
||||
@@ -133,9 +131,9 @@ abstract class LineBreakpointManager(private val debugProcess: DebugProcessImpl<
|
||||
}
|
||||
}
|
||||
|
||||
protected fun doSetBreakpoint(breakpoint: XLineBreakpoint<*>?, location: Location, isTemporary: Boolean, promiseRef: Ref<Promise<out Breakpoint>>? = null): Breakpoint? {
|
||||
protected fun doSetBreakpoint(vm: Vm, breakpoint: XLineBreakpoint<*>?, location: Location, isTemporary: Boolean, promiseRef: Ref<Promise<out Breakpoint>>? = null): Breakpoint? {
|
||||
if (breakpointResolvedListenerAdded.compareAndSet(false, true)) {
|
||||
breakpointManager.addBreakpointListener(object : BreakpointListener {
|
||||
vm.breakpointManager.addBreakpointListener(object : BreakpointListener {
|
||||
override fun resolved(breakpoint: Breakpoint) {
|
||||
synchronized (lock) { vmToIdeBreakpoints[breakpoint] }?.let {
|
||||
for (ideBreakpoint in it) {
|
||||
@@ -173,7 +171,7 @@ abstract class LineBreakpointManager(private val debugProcess: DebugProcessImpl<
|
||||
}
|
||||
?.let {
|
||||
for (ideBreakpoint in it) {
|
||||
setBreakpoint(ideBreakpoint, debugProcess.getLocationsForBreakpoint(ideBreakpoint))
|
||||
setBreakpoint(vm, ideBreakpoint, debugProcess.getLocationsForBreakpoint(ideBreakpoint))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -217,20 +215,20 @@ abstract class LineBreakpointManager(private val debugProcess: DebugProcessImpl<
|
||||
var array = synchronized (lock) { ideToVmBreakpoints.keys.toTypedArray() }
|
||||
for (breakpoint in array) {
|
||||
removeBreakpoint(breakpoint, false)
|
||||
setBreakpoint(breakpoint)
|
||||
debugProcess.vm?.let { setBreakpoint(it, breakpoint) }
|
||||
}
|
||||
}
|
||||
|
||||
fun removeAllBreakpoints(): org.jetbrains.concurrency.Promise<*> {
|
||||
fun removeAllBreakpoints(): Promise<*> {
|
||||
synchronized (lock) {
|
||||
ideToVmBreakpoints.clear()
|
||||
vmToIdeBreakpoints.clear()
|
||||
runToLocationBreakpoints.clear()
|
||||
}
|
||||
return breakpointManager.removeAll()
|
||||
return debugProcess.vm!!.breakpointManager.removeAll()
|
||||
}
|
||||
|
||||
fun clearRunToLocationBreakpoints() {
|
||||
fun clearRunToLocationBreakpoints(vm: Vm) {
|
||||
var breakpoints = synchronized (lock) {
|
||||
if (runToLocationBreakpoints.isEmpty) {
|
||||
return@clearRunToLocationBreakpoints
|
||||
@@ -240,7 +238,7 @@ abstract class LineBreakpointManager(private val debugProcess: DebugProcessImpl<
|
||||
breakpoints
|
||||
}
|
||||
|
||||
val breakpointManager = breakpointManager
|
||||
val breakpointManager = vm.breakpointManager
|
||||
for (breakpoint in breakpoints) {
|
||||
breakpointManager.remove(breakpoint)
|
||||
}
|
||||
|
||||
+18
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -36,20 +36,23 @@ import java.net.InetSocketAddress
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
abstract class RemoteVmConnection : VmConnection<Vm>() {
|
||||
var port = -1
|
||||
|
||||
private val connectCancelHandler = AtomicReference<() -> Unit>()
|
||||
|
||||
abstract fun createBootstrap(address: InetSocketAddress, vmResult: org.jetbrains.concurrency.AsyncPromise<Vm>): Bootstrap
|
||||
|
||||
@JvmOverloads
|
||||
fun open(address: InetSocketAddress, stopCondition: Condition<Void>? = null) {
|
||||
setState(ConnectionStatus.WAITING_FOR_CONNECTION, "Connecting to ${address.hostName}:${address.port}")
|
||||
fun open(address: InetSocketAddress, stopCondition: Condition<Void>? = null): Promise<Vm> {
|
||||
port = address.port
|
||||
setState(ConnectionStatus.WAITING_FOR_CONNECTION, "Connecting to ${address.hostName}:${port}")
|
||||
val result = AsyncPromise<Vm>()
|
||||
val future = ApplicationManager.getApplication().executeOnPooledThread {
|
||||
if (Thread.interrupted()) {
|
||||
return@executeOnPooledThread
|
||||
}
|
||||
|
||||
val result = AsyncPromise<Vm>()
|
||||
connectCancelHandler.set({ result.setError("Closed explicitly") })
|
||||
connectCancelHandler.set { result.setError("Closed explicitly") }
|
||||
|
||||
val connectionPromise = AsyncPromise<Any?>()
|
||||
connectionPromise.rejected { result.setError(it) }
|
||||
@@ -70,7 +73,16 @@ abstract class RemoteVmConnection : VmConnection<Vm>() {
|
||||
|
||||
createBootstrap(address, result).connect(address, connectionPromise, maxAttemptCount = if (stopCondition == null) NettyUtil.DEFAULT_CONNECT_ATTEMPT_COUNT else -1, stopCondition = stopCondition)
|
||||
}
|
||||
connectCancelHandler.set { future.cancel(true) }
|
||||
|
||||
connectCancelHandler.set {
|
||||
try {
|
||||
future.cancel(true)
|
||||
}
|
||||
finally {
|
||||
result.setError("Cancelled")
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
protected open fun connectedAddressToPresentation(address: InetSocketAddress, vm: Vm): String = "${address.hostName}:${address.port}"
|
||||
|
||||
@@ -548,7 +548,6 @@ js.debugger.name.mappings.by.source.code=false
|
||||
js.debugger.v8.log=
|
||||
js.debugger.wip.log=
|
||||
js.debugger.member.filter.prefer.vm.source=false
|
||||
js.debugger.slave.node.as.thread=false
|
||||
|
||||
js.index.node.submodules=false
|
||||
|
||||
|
||||
Reference in New Issue
Block a user