[Lldb-commits] [PATCH] D58962: Sanity check --max-gdbserver-port

Jan Kratochvil via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Mar 5 05:54:12 PST 2019


jankratochvil created this revision.
jankratochvil added a reviewer: LLDB.
jankratochvil added a project: LLDB.
Herald added subscribers: jdoerfert, abidh.

In mail lldb-dev: Remote debugging a docker process <https://lists.llvm.org/pipermail/lldb-dev/2019-March/014795.html> user was confused by `--min-gdbserver-port` and `--max-gdbserver-port` options being ignored.  I think there is even a bug that `--max-gdbserver-port` is upper exclusive limit (and not upper inclusive limit appropriate for `max`).
At least this patch should catch such mistake by an error message. The question is whether `--max-gdbserver-port` should not be changed to really be `max` and not `max+1` but that would break backward compatibility.
Now the mail example does produce:

  error: --min-gdbserver-port (5001) is not lower than --max-gdbserver-port (5001)


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D58962

Files:
  lldb/tools/lldb-server/lldb-platform.cpp


Index: lldb/tools/lldb-server/lldb-platform.cpp
===================================================================
--- lldb/tools/lldb-server/lldb-platform.cpp
+++ lldb/tools/lldb-server/lldb-platform.cpp
@@ -241,11 +241,11 @@
     return -1;
 
   // Make a port map for a port range that was specified.
-  if (min_gdbserver_port < max_gdbserver_port) {
+  if (min_gdbserver_port && min_gdbserver_port < max_gdbserver_port) {
     for (uint16_t port = min_gdbserver_port; port < max_gdbserver_port; ++port)
       gdbserver_portmap[port] = LLDB_INVALID_PROCESS_ID;
-  } else if (min_gdbserver_port != max_gdbserver_port) {
-    fprintf(stderr, "error: --min-gdbserver-port (%u) is greater than "
+  } else if (min_gdbserver_port || max_gdbserver_port) {
+    fprintf(stderr, "error: --min-gdbserver-port (%u) is not lower than "
                     "--max-gdbserver-port (%u)\n",
             min_gdbserver_port, max_gdbserver_port);
     option_error = 3;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58962.189308.patch
Type: text/x-patch
Size: 959 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190305/51d69d26/attachment.bin>


More information about the lldb-commits mailing list