init debug NodeJs child processes as threads appcode/146.110 clion/146.111
authorVladimir Krivosheev <vladimir.krivosheev@jetbrains.com>
Mon, 22 Feb 2016 11:48:26 +0000 (12:48 +0100)
committerVladimir Krivosheev <vladimir.krivosheev@jetbrains.com>
Mon, 22 Feb 2016 11:51:37 +0000 (12:51 +0100)
platform/built-in-server/src/net.kt [deleted file]
platform/platform-impl/src/com/intellij/util/net/net.kt [new file with mode: 0644]
platform/script-debugger/backend/src/org/jetbrains/debugger/ScriptRegExpBreakpointTarget.kt [moved from platform/script-debugger/backend/src/org/jetbrains/debugger/ScriptRegExpBreakpointTarget.java with 100% similarity]
platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebugProcessImpl.kt
platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/LineBreakpointManager.kt
platform/util/resources/misc/registry.properties

diff --git a/platform/built-in-server/src/net.kt b/platform/built-in-server/src/net.kt
deleted file mode 100644 (file)
index 64cbc78..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.intellij.util.net
-
-import java.net.InetAddress
-import java.net.InetSocketAddress
-
-@JvmOverloads
-fun loopbackSocketAddress(port: Int = -1) = InetSocketAddress(InetAddress.getLoopbackAddress(), if (port == -1) NetUtils.findAvailableSocketPort() else port)
\ No newline at end of file
diff --git a/platform/platform-impl/src/com/intellij/util/net/net.kt b/platform/platform-impl/src/com/intellij/util/net/net.kt
new file mode 100644 (file)
index 0000000..7259047
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ * 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.
+ */
+package com.intellij.util.net
+
+import java.net.InetAddress
+import java.net.InetSocketAddress
+
+@JvmOverloads
+fun loopbackSocketAddress(port: Int = -1) = InetSocketAddress(InetAddress.getLoopbackAddress(), if (port == -1) NetUtils.findAvailableSocketPort() else port)
\ No newline at end of file
index 7978189bbdbd615ebe51a980b90e638f6c0c8d20..0256aeecb147c5a6d63b91dce66d76a543a873cd 100644 (file)
@@ -24,7 +24,9 @@ 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.breakpoints.*
+import com.intellij.xdebugger.breakpoints.XBreakpointHandler
+import com.intellij.xdebugger.breakpoints.XBreakpointType
+import com.intellij.xdebugger.breakpoints.XLineBreakpoint
 import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider
 import com.intellij.xdebugger.stepping.XSmartStepIntoHandler
 import org.jetbrains.concurrency.Promise
@@ -47,6 +49,9 @@ abstract class DebugProcessImpl<C : VmConnection<*>>(session: XDebugSession,
 
   var processBreakpointConditionsAtIdeSide: Boolean = false
 
+  private val connectedListenerAdded = AtomicBoolean()
+  private val breakpointsInitiated = AtomicBoolean()
+
   private val _breakpointHandlers: Array<XBreakpointHandler<*>> by lazy(LazyThreadSafetyMode.NONE) { createBreakpointHandlers() }
 
   init {
@@ -174,10 +179,32 @@ abstract class DebugProcessImpl<C : VmConnection<*>>(session: XDebugSession,
   open fun getLocationsForBreakpoint(breakpoint: XLineBreakpoint<*>): List<Location> = throw UnsupportedOperationException()
 
   override fun isLibraryFrameFilterSupported() = true
+
+  // todo make final (go plugin compatibility)
+  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)
+    }
+
+    if (connectedListenerAdded.compareAndSet(false, true)) {
+      connection.stateChanged {
+        if (it.status == ConnectionStatus.CONNECTED) {
+          setBreakpoints(true)
+        }
+      }
+    }
+    return false
+  }
+
+  open protected fun setBreakpoints(setBreakpoints: Boolean): Boolean {
+    return breakpointsInitiated.compareAndSet(false, true)
+  }
 }
 
-class LineBreakpointHandler(breakpointTypeClass: Class<out XLineBreakpointType<*>>, private val manager: LineBreakpointManager)
-    : XBreakpointHandler<XLineBreakpoint<*>>(breakpointTypeClass as Class<out XBreakpointType<XLineBreakpoint<*>, out XBreakpointProperties<*>>>) {
+@Suppress("UNCHECKED_CAST")
+class LineBreakpointHandler(breakpointTypeClass: Class<out XBreakpointType<out XLineBreakpoint<*>, *>>, private val manager: LineBreakpointManager)
+    : XBreakpointHandler<XLineBreakpoint<*>>(breakpointTypeClass as Class<out XBreakpointType<XLineBreakpoint<*>, *>>) {
   override fun registerBreakpoint(breakpoint: XLineBreakpoint<*>) {
     manager.setBreakpoint(breakpoint)
   }
index 344444e70b1598d20f068a4e7fce9e446767c6f6..99aa12ce5c428e5b817303450e21be4a2a5e759a 100644 (file)
@@ -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.
@@ -43,7 +43,7 @@ abstract class LineBreakpointManager(private val debugProcess: DebugProcessImpl<
   private val breakpointResolvedListenerAdded = AtomicBoolean()
 
   fun setBreakpoint(breakpoint: XLineBreakpoint<*>) {
-    var target = synchronized (lock) { ideToVmBreakpoints[breakpoint] }
+    val target = synchronized (lock) { ideToVmBreakpoints[breakpoint] }
     if (target == null) {
       setBreakpoint(breakpoint, debugProcess.getLocationsForBreakpoint(breakpoint))
     }
index c35e2c2250792abb8b4d5f255fe0bd35e03bd00f..adee765833e38aff3fc4530ef69463468f2750a4 100644 (file)
@@ -548,6 +548,7 @@ 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