[Lldb-commits] [lldb] 984e2f4 - [lldb] Prints error using WithColor::error in lldb-platform
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Mon Mar 29 15:45:42 PDT 2021
Author: Jonas Devlieghere
Date: 2021-03-29T15:45:33-07:00
New Revision: 984e2f440aa4c9c3603840e4f8f09073a54e4849
URL: https://github.com/llvm/llvm-project/commit/984e2f440aa4c9c3603840e4f8f09073a54e4849
DIFF: https://github.com/llvm/llvm-project/commit/984e2f440aa4c9c3603840e4f8f09073a54e4849.diff
LOG: [lldb] Prints error using WithColor::error in lldb-platform
Added:
Modified:
lldb/tools/lldb-server/lldb-platform.cpp
Removed:
################################################################################
diff --git a/lldb/tools/lldb-server/lldb-platform.cpp b/lldb/tools/lldb-server/lldb-platform.cpp
index a5d4ecfa3f29..131387c662eb 100644
--- a/lldb/tools/lldb-server/lldb-platform.cpp
+++ b/lldb/tools/lldb-server/lldb-platform.cpp
@@ -22,6 +22,7 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FileUtilities.h"
+#include "llvm/Support/WithColor.h"
#include "llvm/Support/raw_ostream.h"
#include "Acceptor.h"
@@ -202,14 +203,15 @@ int main_platform(int argc, char *argv[]) {
case 'p': {
if (!llvm::to_integer(optarg, port_offset)) {
- llvm::errs() << "error: invalid port offset string " << optarg << "\n";
+ WithColor::error() << "invalid port offset string " << optarg << "\n";
option_error = 4;
break;
}
if (port_offset < LOW_PORT || port_offset > HIGH_PORT) {
- llvm::errs() << llvm::formatv("error: port offset {0} is not in the "
- "valid user port range of {1} - {2}\n",
- port_offset, LOW_PORT, HIGH_PORT);
+ WithColor::error() << llvm::formatv(
+ "port offset {0} is not in the "
+ "valid user port range of {1} - {2}\n",
+ port_offset, LOW_PORT, HIGH_PORT);
option_error = 5;
}
} break;
@@ -219,14 +221,15 @@ int main_platform(int argc, char *argv[]) {
case 'M': {
uint16_t portnum;
if (!llvm::to_integer(optarg, portnum)) {
- llvm::errs() << "error: invalid port number string " << optarg << "\n";
+ WithColor::error() << "invalid port number string " << optarg << "\n";
option_error = 2;
break;
}
if (portnum < LOW_PORT || portnum > HIGH_PORT) {
- llvm::errs() << llvm::formatv("error: port number {0} is not in the "
- "valid user port range of {1} - {2}\n",
- portnum, LOW_PORT, HIGH_PORT);
+ WithColor::error() << llvm::formatv(
+ "port number {0} is not in the "
+ "valid user port range of {1} - {2}\n",
+ portnum, LOW_PORT, HIGH_PORT);
option_error = 1;
break;
}
@@ -253,9 +256,10 @@ int main_platform(int argc, char *argv[]) {
gdbserver_portmap = GDBRemoteCommunicationServerPlatform::PortMap(
min_gdbserver_port, max_gdbserver_port);
} 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);
+ WithColor::error() << llvm::formatv(
+ "--min-gdbserver-port ({0}) is not lower than "
+ "--max-gdbserver-port ({1})\n",
+ min_gdbserver_port, max_gdbserver_port);
option_error = 3;
}
@@ -317,7 +321,7 @@ int main_platform(int argc, char *argv[]) {
Connection *conn = nullptr;
error = acceptor_up->Accept(children_inherit_accept_socket, conn);
if (error.Fail()) {
- printf("error: %s\n", error.AsCString());
+ WithColor::error() << error.AsCString() << '\n';
exit(socket_error);
}
printf("Connection established.\n");
@@ -372,10 +376,10 @@ int main_platform(int argc, char *argv[]) {
}
if (error.Fail()) {
- fprintf(stderr, "error: %s\n", error.AsCString());
+ WithColor::error() << error.AsCString() << '\n';
}
} else {
- fprintf(stderr, "error: handshake with client failed\n");
+ WithColor::error() << "handshake with client failed\n";
}
}
} while (g_server);
More information about the lldb-commits
mailing list