[Lldb-commits] [lldb] r355554 - Sanity check --max-gdbserver-port
Jan Kratochvil via lldb-commits
lldb-commits at lists.llvm.org
Wed Mar 6 13:52:19 PST 2019
Author: jankratochvil
Date: Wed Mar 6 13:52:19 2019
New Revision: 355554
URL: http://llvm.org/viewvc/llvm-project?rev=355554&view=rev
Log:
Sanity check --max-gdbserver-port
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)
Differential Revision: https://reviews.llvm.org/D58962
Added:
lldb/trunk/lit/tools/lldb-server/
lldb/trunk/lit/tools/lldb-server/TestGdbserverPort.test
Modified:
lldb/trunk/lit/helper/toolchain.py
lldb/trunk/tools/lldb-server/lldb-platform.cpp
Modified: lldb/trunk/lit/helper/toolchain.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/helper/toolchain.py?rev=355554&r1=355553&r2=355554&view=diff
==============================================================================
--- lldb/trunk/lit/helper/toolchain.py (original)
+++ lldb/trunk/lit/helper/toolchain.py Wed Mar 6 13:52:19 2019
@@ -45,6 +45,10 @@ def use_lldb_substitutions(config):
command=FindTool(dsname),
extra_args=dsargs,
unresolved='ignore'),
+ ToolSubst('%platformserver',
+ command=FindTool('lldb-server'),
+ extra_args=['platform'],
+ unresolved='ignore'),
'lldb-test',
'lldb-instr',
ToolSubst('%build',
Added: lldb/trunk/lit/tools/lldb-server/TestGdbserverPort.test
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/tools/lldb-server/TestGdbserverPort.test?rev=355554&view=auto
==============================================================================
--- lldb/trunk/lit/tools/lldb-server/TestGdbserverPort.test (added)
+++ lldb/trunk/lit/tools/lldb-server/TestGdbserverPort.test Wed Mar 6 13:52:19 2019
@@ -0,0 +1,2 @@
+# RUN: %platformserver p --server --listen :1234 --min-gdbserver-port 1234 --max-gdbserver-port 1234 2>&1 | FileCheck %s
+# CHECK: error: --min-gdbserver-port (1234) is not lower than --max-gdbserver-port (1234)
Modified: lldb/trunk/tools/lldb-server/lldb-platform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-server/lldb-platform.cpp?rev=355554&r1=355553&r2=355554&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-server/lldb-platform.cpp (original)
+++ lldb/trunk/tools/lldb-server/lldb-platform.cpp Wed Mar 6 13:52:19 2019
@@ -241,11 +241,11 @@ int main_platform(int argc, char *argv[]
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;
More information about the lldb-commits
mailing list