20struct CommandToolArguments {
22 std::string arguments;
25bool fromJSON(
const llvm::json::Value &V, CommandToolArguments &A,
27 llvm::json::ObjectMapper O(V, P);
28 return O && O.map(
"debugger_id", A.debugger_id) &&
29 O.mapOptional(
"arguments", A.arguments);
34createTextResult(std::string output,
bool is_error =
false) {
36 text_result.
content.emplace_back(
44llvm::Expected<lldb_protocol::mcp::CallToolResult>
46 if (!std::holds_alternative<json::Value>(args))
49 json::Path::Root root;
51 CommandToolArguments arguments;
52 if (!
fromJSON(std::get<json::Value>(args), arguments, root))
53 return root.getError();
59 llvm::formatv(
"no debugger with id {0}", arguments.debugger_id));
63 debugger_sp->GetCommandInterpreter().HandleCommand(
68 if (!output_str.empty())
69 output += output_str.str();
72 if (!err_str.empty()) {
78 return createTextResult(output, !result.
Succeeded());
82 llvm::json::Object id_type{{
"type",
"number"}};
83 llvm::json::Object str_type{{
"type",
"string"}};
84 llvm::json::Object properties{{
"debugger_id", std::move(id_type)},
85 {
"arguments", std::move(str_type)}};
86 llvm::json::Array required{
"debugger_id"};
87 llvm::json::Object schema{{
"type",
"object"},
88 {
"properties", std::move(properties)},
89 {
"required", std::move(required)}};
static llvm::Error createStringError(const char *format, Args &&...args)
std::string GetErrorString(bool with_diagnostics=true) const
Return the errors as a string.
llvm::StringRef GetOutputString() const
static lldb::DebuggerSP FindDebuggerWithID(lldb::user_id_t id)
A class that represents a running process on the host machine.
bool fromJSON(const llvm::json::Value &value, TraceSupportedResponse &info, llvm::json::Path path)
std::variant< std::monostate, llvm::json::Value > ToolArguments
std::shared_ptr< lldb_private::Debugger > DebuggerSP
Text provided to or from an LLM.