================
@@ -8,27 +8,72 @@
#include "Variables.h"
#include "JSONUtils.h"
+#include "Protocol/ProtocolTypes.h"
+#include "lldb/API/SBFrame.h"
+#include "lldb/API/SBValue.h"
+#include "lldb/API/SBValueList.h"
+#include <cstdint>
+#include <optional>
+#include <vector>
using namespace lldb_dap;
+namespace lldb_dap {
+
+protocol::Scope CreateScope(const eScopeKind kind, int64_t variablesReference,
+ int64_t namedVariables, bool expensive) {
+ protocol::Scope scope;
+
+ // TODO: Support "arguments" and "return value" scope.
+ // At the moment lldb-dap includes the arguments and return_value into the
+ // "locals" scope.
+ // vscode only expands the first non-expensive scope, this causes friction
+ // if we add the arguments above the local scope as the locals scope will not
+ // be expanded if we enter a function with arguments. It becomes more
+ // annoying when the scope has arguments, return_value and locals.
+ switch (kind) {
+ case eScopeKind::Locals:
+ scope.presentationHint = protocol::Scope::eScopePresentationHintLocals;
+ scope.name = "Locals";
+ break;
+ case eScopeKind::Globals:
+ scope.name = "Globals";
+ break;
+ case eScopeKind::Registers:
+ scope.presentationHint = protocol::Scope::eScopePresentationHintRegisters;
+ scope.name = "Registers";
+ break;
+ }
+
+ scope.variablesReference = variablesReference;
+ scope.namedVariables = namedVariables;
+ scope.expensive = expensive;
+
+ return scope;
+}
+
lldb::SBValueList *Variables::GetTopLevelScope(int64_t variablesReference) {
- switch (variablesReference) {
- case VARREF_LOCALS:
- return &locals;
- case VARREF_GLOBALS:
- return &globals;
- case VARREF_REGS:
- return ®isters;
- default:
+ auto iter = m_scope_kinds.find(variablesReference);
+ if (iter == m_scope_kinds.end()) {
+ return nullptr;
+ }
+
+ eScopeKind scope_kind = iter->second.first;
+ uint64_t dap_frame_id = iter->second.second;
+
+ auto frame_iter = m_frames.find(dap_frame_id);
+ if (frame_iter == m_frames.end()) {
return nullptr;
}
----------------
JDevlieghere wrote:
```suggestion
if (frame_iter == m_frames.end())
return nullptr;
```
https://github.com/llvm/llvm-project/pull/124232
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits