sdedic commented on a change in pull request #2913:
URL: https://github.com/apache/netbeans/pull/2913#discussion_r620079021



##########
File path: 
cpplite/cpplite.debugger/src/org/netbeans/modules/cpplite/debugger/ni/NIDebuggerProviderImpl.java
##########
@@ -119,9 +121,15 @@ public void finished() {
                     completed.complete(null);
                 }
             });
+            started.release();
             debugger.execRun();
             return engineProcess.second();
         }, executionDescriptor, displayName).run();
+        // Wait for the debugger to actually start up.
+        // This is necessary to be able to safely call other methods on the 
NIDebuggerProvider.
+        try {
+            started.acquire();
+        } catch (InterruptedException ex) {}

Review comment:
       Nitpick: if thread's `interrupted` status happen to be true, `started` 
won't be acquired (waited for) but the code will continue. OK ?

##########
File path: 
java/java.nativeimage.debugger/src/org/netbeans/modules/java/nativeimage/debugger/api/NIDebugRunner.java
##########
@@ -68,18 +72,55 @@ public static NIDebugger start(File niFile, List<String> 
arguments, String debug
         JPDABreakpointsHandler breakpointsHandler = new 
JPDABreakpointsHandler(niFile, debugger);
         File workingDirectory = new File(System.getProperty("user.dir"));
         List<String> command = arguments.isEmpty() ? 
Collections.singletonList(niFile.getAbsolutePath()) : 
join(niFile.getAbsolutePath(), arguments);
+        DialogDisplayer displayer = DialogDisplayer.getDefault(); // The 
launcher might provide a special displayer in the lookup. This is why we grab 
it eagerly.
         debugger.start(
                 command,
                 workingDirectory,
                 debuggerCommand,
                 COMMAND_DEBUG + " " + niFile.getName(),
                 executionDescriptor,
-                startedEngine).thenRun(() -> {
+                (engine) -> {
+                    checkVersion(debugger.getVersion(), displayer);
+                    if (startedEngine != null) {
+                        startedEngine.accept(engine);
+                    }
+                }).thenRun(() -> {
                     breakpointsHandler.dispose();
                 });
         return debugger;
     }
 
+    @NbBundle.Messages("MSG_GDBVersionBug=gdb bug #26139 will affect the 
debugging.\nWe recommend to upgrade to version 10.1 or newer.")
+    private static void checkVersion(String version, DialogDisplayer 
displayer) {
+        String gdbVersion = "GNU gdb";
+        int i = version.indexOf(gdbVersion);
+        if (i >= 0) {
+            i += gdbVersion.length();
+            i = skipParanthesis(version, i);
+            int eol = version.indexOf("\\n", i);
+            if (eol > 0) {
+                String v = version.substring(i, eol).trim();
+                if (v.startsWith("8.") && !v.startsWith("8.0") || 
v.startsWith("9.")) {
+                    NotifyDescriptor descriptor = new 
NotifyDescriptor.Message(Bundle.MSG_GDBVersionBug(), 
NotifyDescriptor.WARNING_MESSAGE);
+                    displayer.notifyLater(descriptor);
+                }
+            }
+        }

Review comment:
       GDB version not identified => no message ... OK ?

##########
File path: 
java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/LspSession.java
##########
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.netbeans.modules.java.lsp.server;
+
+import java.util.concurrent.Future;
+
+import org.netbeans.api.annotations.common.CheckForNull;
+import org.netbeans.modules.java.lsp.server.debugging.NbProtocolServer;
+import org.netbeans.modules.java.lsp.server.protocol.NbLspServer;
+
+import org.openide.util.Lookup;
+import org.openide.util.lookup.ProxyLookup;
+
+/**
+ * A session that provides associated LSP and DAP servers.
+ *
+ * @author martin
+ */
+public final class LspSession {
+
+    private final ProxyLookup.Controller lspServices = new 
ProxyLookup.Controller();
+    private final ProxyLookup.Controller dapServices = new 
ProxyLookup.Controller();
+    private final Lookup sessionLookup;
+
+    private volatile NbLspServer lspServer;
+    private volatile NbProtocolServer dapServer;
+
+    LspSession() {
+        sessionLookup = new ProxyLookup(
+                new ProxyLookup(lspServices),
+                new ProxyLookup(dapServices),
+                Lookup.getDefault()
+        );
+    }
+
+    /**
+     * Set the launched LSP server.
+     */
+    void setLspServer(NbLspServer lspServer) {
+        if (lspServer != null && this.lspServer != null) {
+            throw new IllegalStateException("LSP server is set already");
+        }
+        setServerLookup(lspServer, lspServices);
+        this.lspServer = lspServer;
+    }
+
+    /**
+     * Set the launched DAP server.
+     */
+    void setDapServer(NbProtocolServer dapServer) {
+        if (dapServer != null && this.dapServer != null) {
+            throw new IllegalStateException("DAP server is set already");
+        }
+        setServerLookup(dapServer, dapServices);
+        this.dapServer = dapServer;
+    }
+
+    private static void setServerLookup(ScheduledServer server, 
ProxyLookup.Controller lookupControler) {

Review comment:
       Q: if this is called first for DAP, then for LSP - will the 
`server.getServerLookup()` contain both DAP + LSP services ?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to