[Lldb-commits] [lldb] [lldb-dap] Refactor variablesReference storage and scope management. (PR #179262)
Ebuka Ezike via lldb-commits
lldb-commits at lists.llvm.org
Sun Feb 15 02:41:19 PST 2026
================
@@ -51,155 +59,310 @@ protocol::Scope CreateScope(const ScopeKind kind, int64_t variablesReference,
return scope;
}
-std::optional<ScopeData>
-Variables::GetTopLevelScope(int64_t variablesReference) {
- auto scope_kind_iter = m_scope_kinds.find(variablesReference);
- if (scope_kind_iter == m_scope_kinds.end())
- return std::nullopt;
+std::vector<Variable>
+ScopeStore::GetVariables(VariableReferenceStorage &storage,
+ const Configuration &config,
+ const VariablesArguments &args) {
+ LoadVariables();
+ if (m_kind == lldb_dap::eScopeKindRegisters)
+ SetRegistersFormat();
- ScopeKind scope_kind = scope_kind_iter->second.first;
- uint64_t dap_frame_id = scope_kind_iter->second.second;
+ const bool format_hex = args.format ? args.format->hex : false;
+ std::vector<Variable> variables;
+ if (m_kind == eScopeKindLocals)
+ AddReturnValue(storage, config, variables, format_hex);
- auto frame_iter = m_frames.find(dap_frame_id);
- if (frame_iter == m_frames.end())
- return std::nullopt;
+ const uint64_t count = args.count;
+ const uint32_t start_idx = 0;
+ const uint32_t num_children = m_children.GetSize();
+ const uint32_t end_idx = start_idx + ((count == 0) ? num_children : count);
- lldb::SBValueList *scope = frame_iter->second.GetScope(scope_kind);
- if (scope == nullptr)
- return std::nullopt;
+ // We first find out which variable names are duplicated.
+ std::map<llvm::StringRef, uint32_t> variable_name_counts;
+ for (auto i = start_idx; i < end_idx; ++i) {
----------------
da-viper wrote:
I don't see the need as we are not looping over the entire range.
https://github.com/llvm/llvm-project/pull/179262
More information about the lldb-commits
mailing list