summaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectProtocolServer.cpp
diff options
context:
space:
mode:
authorFlorian Mayer <fmayer@google.com>2025-10-13 13:23:20 -0700
committerFlorian Mayer <fmayer@google.com>2025-10-13 13:23:20 -0700
commitccc6fad8951b12dbe5fde7d8d00b9c959e36fa00 (patch)
treeb17aad8d549af17c7f8411ecd5ccc6ecfd4b1499 /lldb/source/Commands/CommandObjectProtocolServer.cpp
parent82a427702eb2c83ff571670a73071420f0b31546 (diff)
parent55d4e92c8821d5543469118a76fe38db866377b7 (diff)
[𝘀𝗽𝗿] changes introduced through rebaseusers/fmayer/spr/main.flowsensitive-statusor-2n-add-minimal-model
Created using spr 1.3.4 [skip ci]
Diffstat (limited to 'lldb/source/Commands/CommandObjectProtocolServer.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectProtocolServer.cpp44
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;