diff options
Diffstat (limited to 'lldb/source/Commands/CommandObjectProtocolServer.cpp')
| -rw-r--r-- | lldb/source/Commands/CommandObjectProtocolServer.cpp | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/lldb/source/Commands/CommandObjectProtocolServer.cpp b/lldb/source/Commands/CommandObjectProtocolServer.cpp index c5ab9e9f05be..1a950899ea1c 100644 --- a/lldb/source/Commands/CommandObjectProtocolServer.cpp +++ b/lldb/source/Commands/CommandObjectProtocolServer.cpp @@ -131,15 +131,57 @@ protected: } }; +class CommandObjectProtocolServerGet : public CommandObjectParsed { +public: + CommandObjectProtocolServerGet(CommandInterpreter &interpreter) + : CommandObjectParsed(interpreter, "protocol-server get", + "get protocol server connection information", + "protocol-server get <protocol>") { + AddSimpleArgumentList(lldb::eArgTypeProtocol, eArgRepeatPlain); + } + + ~CommandObjectProtocolServerGet() override = default; + +protected: + void DoExecute(Args &args, CommandReturnObject &result) override { + if (args.GetArgumentCount() < 1) { + result.AppendError("no protocol specified"); + return; + } + + llvm::StringRef protocol = args.GetArgumentAtIndex(0); + ProtocolServer *server = ProtocolServer::GetOrCreate(protocol); + if (!server) { + result.AppendErrorWithFormatv( + "unsupported protocol: {0}. Supported protocols are: {1}", protocol, + llvm::join(ProtocolServer::GetSupportedProtocols(), ", ")); + return; + } + + Socket *socket = server->GetSocket(); + if (!socket) { + result.AppendErrorWithFormatv("{0} server is not running", protocol); + return; + } + + std::string address = llvm::join(socket->GetListeningConnectionURI(), ", "); + result.AppendMessageWithFormatv("{0} server connection listeners: {1}", + protocol, address); + result.SetStatus(eReturnStatusSuccessFinishNoResult); + } +}; + CommandObjectProtocolServer::CommandObjectProtocolServer( CommandInterpreter &interpreter) : CommandObjectMultiword(interpreter, "protocol-server", - "Start and stop a protocol server.", + "Start, stop, and query protocol servers.", "protocol-server") { LoadSubCommand("start", CommandObjectSP(new CommandObjectProtocolServerStart( interpreter))); LoadSubCommand("stop", CommandObjectSP( new CommandObjectProtocolServerStop(interpreter))); + LoadSubCommand( + "get", CommandObjectSP(new CommandObjectProtocolServerGet(interpreter))); } CommandObjectProtocolServer::~CommandObjectProtocolServer() = default; |
