[Lldb-commits] [lldb] bbcb4d6 - Revert "[lldb server] Tidy up LLDB server return codes and associated tests"
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Thu Sep 2 06:28:30 PDT 2021
Author: Raphael Isemann
Date: 2021-09-02T15:27:39+02:00
New Revision: bbcb4d6bc0db612698ab8938ce209029cd8551e0
URL: https://github.com/llvm/llvm-project/commit/bbcb4d6bc0db612698ab8938ce209029cd8551e0
DIFF: https://github.com/llvm/llvm-project/commit/bbcb4d6bc0db612698ab8938ce209029cd8551e0.diff
LOG: Revert "[lldb server] Tidy up LLDB server return codes and associated tests"
This reverts commit e387c8c413e2127bc93950fb6d786290237b4a9f. The
TestErrorMessages.test is failing on the Linux bots.
Added:
Modified:
lldb/test/Shell/lldb-server/TestErrorMessages.test
lldb/test/Shell/lldb-server/TestGdbserverPort.test
lldb/tools/lldb-server/lldb-platform.cpp
lldb/tools/lldb-server/lldb-server.cpp
Removed:
################################################################################
diff --git a/lldb/test/Shell/lldb-server/TestErrorMessages.test b/lldb/test/Shell/lldb-server/TestErrorMessages.test
index 799c65904f6b7..b9689fb1e4673 100644
--- a/lldb/test/Shell/lldb-server/TestErrorMessages.test
+++ b/lldb/test/Shell/lldb-server/TestErrorMessages.test
@@ -1,26 +1,14 @@
-RUN: not %lldb-server gdbserver --fd 2>&1 | FileCheck --check-prefixes=FD1,GDB_REMOTE_ALL %s
+RUN: %lldb-server gdbserver --fd 2>&1 | FileCheck --check-prefixes=FD1,ALL %s
FD1: error: --fd: missing argument
-RUN: not %lldb-server gdbserver --fd three 2>&1 | FileCheck --check-prefixes=FD2,GDB_REMOTE_ALL %s
+RUN: %lldb-server gdbserver --fd three 2>&1 | FileCheck --check-prefixes=FD2,ALL %s
FD2: error: invalid '--fd' argument
-RUN: not %lldb-server gdbserver --bogus 2>&1 | FileCheck --check-prefixes=BOGUS,GDB_REMOTE_ALL %s
+RUN: %lldb-server gdbserver --bogus 2>&1 | FileCheck --check-prefixes=BOGUS,ALL %s
BOGUS: error: unknown argument '--bogus'
-RUN: not %lldb-server gdbserver 2>&1 | FileCheck --check-prefixes=CONN,GDB_REMOTE_ALL %s
+RUN: %lldb-server gdbserver 2>&1 | FileCheck --check-prefixes=CONN,ALL %s
CONN: error: no connection arguments
-RUN: %lldb-server platform 2>&1 | FileCheck --check-prefixes=LLDB_PLATFORM_ALL %s
-
-RUN: %lldb-server platform --fd 2>&1 | FileCheck --check-prefixes=FD3,LLDB_PLATFORM_ALL %s
-FD3: lldb-server: unrecognized option `--fd'
-
-RUN: not %lldb-server platform --min-gdbserver-port 42 --max-gdbserver-port 43 2>&1 | FileCheck --check-prefixes=PORT1,LLDB_PLATFORM_ALL %s
-PORT1: error: port number 42 is not in the valid user port range of 1024 - 49152
-
-RUN: %lldb-server version 2>&1 | FileCheck --check-prefixes=VERSION %s
-VERSION: lldb version
-
-GDB_REMOTE_ALL: Use '{{.*}} g[dbserver] --help' for a complete list of options.
-LLDB_PLATFORM_ALL: lldb-server platform [--log-file log-file-name] [--log-channels log-channel-list] [--port-file port-file-path] --server --listen port
+ALL: Use '{{.*}} g[dbserver] --help' for a complete list of options.
diff --git a/lldb/test/Shell/lldb-server/TestGdbserverPort.test b/lldb/test/Shell/lldb-server/TestGdbserverPort.test
index a3dd1af44f356..04facfec831ca 100644
--- a/lldb/test/Shell/lldb-server/TestGdbserverPort.test
+++ b/lldb/test/Shell/lldb-server/TestGdbserverPort.test
@@ -1,4 +1,4 @@
# Windows does not build lldb-server.
# UNSUPPORTED: system-windows
-# RUN: not %platformserver --server --listen :1234 --min-gdbserver-port 1234 --max-gdbserver-port 1234 2>&1 | FileCheck %s
+# RUN: %platformserver --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)
diff --git a/lldb/tools/lldb-server/lldb-platform.cpp b/lldb/tools/lldb-server/lldb-platform.cpp
index 3cf8613786eca..d4b54362bb468 100644
--- a/lldb/tools/lldb-server/lldb-platform.cpp
+++ b/lldb/tools/lldb-server/lldb-platform.cpp
@@ -92,6 +92,7 @@ static void display_usage(const char *progname, const char *subcommand) {
"log-channel-list] [--port-file port-file-path] --server "
"--listen port\n",
progname, subcommand);
+ exit(0);
}
static Status save_socket_id_to_file(const std::string &socket_id,
@@ -164,6 +165,7 @@ int main_platform(int argc, char *argv[]) {
FileSpec socket_file;
bool show_usage = false;
int option_error = 0;
+ int socket_error = -1;
std::string short_options(OptionParser::GetShortOptionString(g_long_options));
@@ -247,7 +249,7 @@ int main_platform(int argc, char *argv[]) {
}
if (!LLDBServerUtilities::SetupLogging(log_file, log_channels, 0))
- return 1;
+ return -1;
// Make a port map for a port range that was specified.
if (min_gdbserver_port && min_gdbserver_port < max_gdbserver_port) {
@@ -267,7 +269,7 @@ int main_platform(int argc, char *argv[]) {
if (show_usage || option_error) {
display_usage(progname, subcommand);
- return option_error;
+ exit(option_error);
}
// Skip any options we consumed with getopt_long_only.
@@ -286,13 +288,13 @@ int main_platform(int argc, char *argv[]) {
listen_host_port, children_inherit_listen_socket, error));
if (error.Fail()) {
fprintf(stderr, "failed to create acceptor: %s", error.AsCString());
- return 1;
+ exit(socket_error);
}
error = acceptor_up->Listen(backlog);
if (error.Fail()) {
printf("failed to listen: %s\n", error.AsCString());
- return 1;
+ exit(socket_error);
}
if (socket_file) {
error =
@@ -320,7 +322,7 @@ int main_platform(int argc, char *argv[]) {
error = acceptor_up->Accept(children_inherit_accept_socket, conn);
if (error.Fail()) {
WithColor::error() << error.AsCString() << '\n';
- return 1;
+ exit(socket_error);
}
printf("Connection established.\n");
if (g_server) {
diff --git a/lldb/tools/lldb-server/lldb-server.cpp b/lldb/tools/lldb-server/lldb-server.cpp
index 89acb0fd60665..1e001ac7185b8 100644
--- a/lldb/tools/lldb-server/lldb-server.cpp
+++ b/lldb/tools/lldb-server/lldb-server.cpp
@@ -11,7 +11,6 @@
#include "lldb/lldb-private.h"
#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/ManagedStatic.h"
@@ -53,30 +52,29 @@ int main(int argc, char *argv[]) {
llvm::InitLLVM IL(argc, argv, /*InstallPipeSignalExitHandler=*/false);
llvm::PrettyStackTraceProgram X(argc, argv);
+ int option_error = 0;
const char *progname = argv[0];
if (argc < 2) {
display_usage(progname);
- return 1;
+ exit(option_error);
}
switch (argv[1][0]) {
- case 'g': {
+ case 'g':
llgs::initialize();
- auto deinit = llvm::make_scope_exit([]() { llgs::terminate_debugger(); });
- return main_gdbserver(argc, argv);
- }
- case 'p': {
+ main_gdbserver(argc, argv);
+ llgs::terminate_debugger();
+ break;
+ case 'p':
llgs::initialize();
- auto deinit = llvm::make_scope_exit([]() { llgs::terminate_debugger(); });
- return main_platform(argc, argv);
- }
- case 'v': {
+ main_platform(argc, argv);
+ llgs::terminate_debugger();
+ break;
+ case 'v':
fprintf(stderr, "%s\n", lldb_private::GetVersion());
- return 0;
- }
- default: {
+ break;
+ default:
display_usage(progname);
- return 1;
- }
+ exit(option_error);
}
}
More information about the lldb-commits
mailing list