#include <cerrno>
#if defined(__APPLE__)
#include <netinet/in.h>
#endif
#include <csignal>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#if !defined(_WIN32)
#include <sys/wait.h>
#endif
#include <fstream>
#include <optional>
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/ScopedPrinter.h"
#include "llvm/Support/WithColor.h"
#include "llvm/Support/raw_ostream.h"
#include "Acceptor.h"
#include "LLDBServerUtilities.h"
#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h"
#include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/HostGetOpt.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Host/Socket.h"
#include "lldb/Host/common/TCPSocket.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Status.h"
usingnamespacelldb;
usingnamespacelldb_private;
usingnamespacelldb_private::lldb_server;
usingnamespacelldb_private::process_gdb_remote;
usingnamespacellvm;
static int g_debug = …;
static int g_verbose = …;
static int g_server = …;
static struct option g_long_options[] = …;
#if defined(__APPLE__)
#define LOW_PORT …
#define HIGH_PORT …
#else
#define LOW_PORT …
#define HIGH_PORT …
#endif
#if !defined(_WIN32)
static void signal_handler(int signo) { … }
#endif
static void display_usage(const char *progname, const char *subcommand) { … }
static Status save_socket_id_to_file(const std::string &socket_id,
const FileSpec &file_spec) { … }
static void client_handle(GDBRemoteCommunicationServerPlatform &platform,
const lldb_private::Args &args) { … }
static GDBRemoteCommunicationServerPlatform::PortMap gdbserver_portmap;
static std::mutex gdbserver_portmap_mutex;
static void spawn_process_reaped(lldb::pid_t pid, int signal, int status) { … }
static Status spawn_process(const char *progname, const Socket *conn_socket,
uint16_t gdb_port, uint16_t port_offset,
const lldb_private::Args &args,
const std::string &log_file,
const StringRef log_channels) { … }
int main_platform(int argc, char *argv[]) { … }