================
@@ -0,0 +1,72 @@
+//===- Tool.cpp 
-----------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "Tool.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
+
+using namespace lldb_private::mcp;
+using namespace llvm;
+
+Tool::Tool(std::string name, std::string description)
+    : m_name(std::move(name)), m_description(std::move(description)) {}
+
+protocol::ToolDefinition Tool::GetDefinition() const {
+  protocol::ToolDefinition definition;
+  definition.name = m_name;
+  definition.description.emplace(m_description);
+
+  if (std::optional<llvm::json::Value> input_schema = GetSchema())
+    definition.inputSchema = *input_schema;
+
+  if (m_annotations)
+    definition.annotations = m_annotations;
+
+  return definition;
+}
+
+LLDBCommandTool::LLDBCommandTool(std::string name, std::string description,
+                                 Debugger &debugger)
+    : Tool(std::move(name), std::move(description)), m_debugger(debugger) {}
+
+protocol::TextResult LLDBCommandTool::Call(const llvm::json::Value &args) {
+  std::string arguments;
+  if (const json::Object *args_obj = args.getAsObject()) {
+    if (const json::Value *s = args_obj->get("arguments")) {
+      arguments = s->getAsString().value_or("");
+    }
+  }
+
+  CommandReturnObject result(/*colors=*/false);
+  m_debugger.GetCommandInterpreter().HandleCommand(arguments.c_str(),
----------------
JDevlieghere wrote:

I've added a FIXME for now. 

https://github.com/llvm/llvm-project/pull/143628
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to