[Lldb-commits] [lldb] [lldb-dap] Support inspecting memory (PR #104317)

Adrian Vogelsgesang via lldb-commits lldb-commits at lists.llvm.org
Fri Aug 16 05:13:42 PDT 2024


================
@@ -1085,6 +1084,17 @@ std::string VariableDescription::GetResult(llvm::StringRef context) {
   return description.trim().str();
 }
 
+std::optional<lldb::addr_t> GetMemoryReference(lldb::SBValue v) {
+  if (!v.GetType().IsPointerType() && !v.GetType().IsArrayType())
+    return std::nullopt;
+
----------------
vogelsgesang wrote:

The proposed code would led to `my_value` and `my_ptr` having the same `memoryReference` in the following code snippet:

```
   int my_value;
   int* my_ptr = &my_value;
```

Also, when entering `my_value` and `&my_value` into the debug console, I would get the same memory references back. As a user, I would find this very confusing.

As such, I do prefer the current semantics, where `my_value` does not have a memory reference. If users want to get to that memory location, they can use `&my_value`

(Also, I noticed that the current code did not work for arrays. Hence, I removed the `IsArrayType`)

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


More information about the lldb-commits mailing list