[Lldb-commits] [lldb] [lldb] Have lldb-server assign ports to children in platform mode (PR #88845)

David Spickett via lldb-commits lldb-commits at lists.llvm.org
Tue Apr 16 06:09:16 PDT 2024


================
@@ -324,6 +335,10 @@ int main_platform(int argc, char *argv[]) {
       // connections while a connection is active.
       acceptor_up.reset();
     }
+
+    GDBRemoteCommunicationServerPlatform::PortMap portmap_for_child;
+    portmap_for_child.AllowPort(*port);
----------------
DavidSpickett wrote:

This will fail at runtime if the optional is empty. Are we 100% sure there is no path to get here that leaves the optional empty?

If it is expected that we get here with port empty, the code should be:
```
if (port) // Which means "is the optional empty?", not "is the value in the optional true in a boolean sense
  portmap_for_child.AllowPort(*port);
```

Given that we're setting a port for a child I assume we'll always have some valid port by this point. Though the code is quite complex, so the free assert given by `operator*` on the optional does add some safety.

https://github.com/llvm/llvm-project/pull/88845


More information about the lldb-commits mailing list