[Lldb-commits] [lldb] [lldb][lldb-dap] Migrate ScopesRequest to structured types (PR #138116)
John Harrison via lldb-commits
lldb-commits at lists.llvm.org
Thu May 8 16:07:56 PDT 2025
================
@@ -98,9 +83,15 @@ void ScopesRequestHandler::operator()(const llvm::json::Object &request) const {
/*statics=*/true,
/*in_scope_only=*/true);
dap.variables.registers = frame.GetRegisters();
- body.try_emplace("scopes", dap.CreateTopLevelScopes());
- response.try_emplace("body", std::move(body));
- dap.SendJSON(llvm::json::Value(std::move(response)));
+
+ std::vector scopes = {CreateScope("Locals", VARREF_LOCALS,
+ dap.variables.locals.GetSize(), false),
+ CreateScope("Globals", VARREF_GLOBALS,
+ dap.variables.globals.GetSize(), false),
+ CreateScope("Registers", VARREF_REGS,
+ dap.variables.registers.GetSize(), false)};
+
+ return ScopesResponseBody{std::move(scopes)};
----------------
ashgti wrote:
I almost wonder if it would make more sense for some of this to move into the `Variables` helper?
Maybe `llvm::Expected<std::vector<protocol::Scope>> Variables::SetFrame(SBFrame frame);` or a `SetFrame` and `GetScopes` helper separately.
I think the intention is for the `Variables` helper to be able to handle caching and managing variable lookups. We can make it a bit more aware of its own state by moving this over there.
How does that sound to you?
https://github.com/llvm/llvm-project/pull/138116
More information about the lldb-commits
mailing list