@@ -195,13 +195,13 @@ void ConnectToRemote(MainLoop &mainloop,
195195 bool reverse_connect, llvm::StringRef host_and_port,
196196 const char *const progname, const char *const subcommand,
197197 const char *const named_pipe_path, pipe_t unnamed_pipe,
198- int connection_fd) {
198+ shared_fd_t connection_fd) {
199199 Status error;
200200
201201 std::unique_ptr<Connection> connection_up;
202202 std::string url;
203203
204- if (connection_fd != - 1 ) {
204+ if (connection_fd != SharedSocket:: kInvalidFD ) {
205205 url = llvm::formatv (" fd://{0}" , connection_fd).str ();
206206
207207 // Create the connection.
@@ -338,7 +338,7 @@ int main_gdbserver(int argc, char *argv[]) {
338338 log_channels; // e.g. "lldb process threads:gdb-remote default:linux all"
339339 lldb::pipe_t unnamed_pipe = LLDB_INVALID_PIPE;
340340 bool reverse_connect = false ;
341- int connection_fd = - 1 ;
341+ shared_fd_t connection_fd = SharedSocket:: kInvalidFD ;
342342
343343 // ProcessLaunchInfo launch_info;
344344 ProcessAttachInfo attach_info;
@@ -404,10 +404,12 @@ int main_gdbserver(int argc, char *argv[]) {
404404 unnamed_pipe = (pipe_t )Arg;
405405 }
406406 if (Args.hasArg (OPT_fd)) {
407- if (!llvm::to_integer (Args.getLastArgValue (OPT_fd), connection_fd)) {
407+ int64_t fd;
408+ if (!llvm::to_integer (Args.getLastArgValue (OPT_fd), fd)) {
408409 WithColor::error () << " invalid '--fd' argument\n " << HelpText;
409410 return 1 ;
410411 }
412+ connection_fd = (shared_fd_t )fd;
411413 }
412414
413415 if (!LLDBServerUtilities::SetupLogging (
@@ -423,7 +425,7 @@ int main_gdbserver(int argc, char *argv[]) {
423425 for (const char *Val : Arg->getValues ())
424426 Inputs.push_back (Val);
425427 }
426- if (Inputs.empty () && connection_fd == - 1 ) {
428+ if (Inputs.empty () && connection_fd == SharedSocket:: kInvalidFD ) {
427429 WithColor::error () << " no connection arguments\n " << HelpText;
428430 return 1 ;
429431 }
@@ -432,7 +434,7 @@ int main_gdbserver(int argc, char *argv[]) {
432434 GDBRemoteCommunicationServerLLGS gdb_server (mainloop, manager);
433435
434436 llvm::StringRef host_and_port;
435- if (!Inputs.empty ()) {
437+ if (!Inputs.empty () && connection_fd == SharedSocket:: kInvalidFD ) {
436438 host_and_port = Inputs.front ();
437439 Inputs.erase (Inputs.begin ());
438440 }
0 commit comments