[Lldb-commits] [lldb] lldb-dap: Stop using replicated variable ids (PR #124232)

John Harrison via lldb-commits lldb-commits at lists.llvm.org
Fri Aug 29 09:08:35 PDT 2025


================
@@ -103,3 +120,76 @@ lldb::SBValue Variables::FindVariable(uint64_t variablesReference,
   }
   return variable;
 }
+
+std::optional<ScopeData>
+Variables::GetScopeKind(const int64_t variablesReference) {
+  auto scope_kind_iter = m_scope_kinds.find(variablesReference);
+  if (scope_kind_iter == m_scope_kinds.end()) {
+    return std::nullopt;
+  }
+
+  auto scope_iter = m_frames.find(scope_kind_iter->second.second);
+  if (scope_iter == m_frames.end()) {
+    return std::nullopt;
+  }
+
+  switch (scope_kind_iter->second.first) {
+  case lldb_dap::ScopeKind::Locals:
+    return ScopeData(scope_kind_iter->second.first,
+                     std::get<0>(scope_iter->second));
+  case lldb_dap::ScopeKind::Globals:
+    return ScopeData(scope_kind_iter->second.first,
+                     std::get<1>(scope_iter->second));
+  case lldb_dap::ScopeKind::Registers:
+    return ScopeData(scope_kind_iter->second.first,
+                     std::get<2>(scope_iter->second));
+  }
+
+  return std::nullopt;
+}
+
+lldb::SBValueList *Variables::GetScope(const uint32_t frame_id,
+                                       const ScopeKind kind) {
+
+  auto frame = m_frames.find(frame_id);
+  if (m_frames.find(frame_id) == m_frames.end()) {
+    return nullptr;
+  }
+
+  switch (kind) {
+  case ScopeKind::Locals:
+    return &std::get<0>(frame->second);
+  case ScopeKind::Globals:
+    return &std::get<1>(frame->second);
+  case ScopeKind::Registers:
+    return &std::get<2>(frame->second);
+  }
+
+  return nullptr;
+}
+
+void Variables::ReadyFrame(uint32_t frame_id, lldb::SBFrame &frame) {
----------------
ashgti wrote:

We could have this return a `std::vector<Scope>` for the local/global/register scope.

https://github.com/llvm/llvm-project/pull/124232


More information about the lldb-commits mailing list