[Lldb-commits] [lldb] [lldb-dap] Add readOnly attribute for variables (PR #151884)

Druzhkov Sergei via lldb-commits lldb-commits at lists.llvm.org
Wed Aug 6 04:03:06 PDT 2025


================
@@ -301,6 +301,14 @@ Variable CreateVariable(lldb::SBValue v, int64_t var_ref, bool format_hex,
   if (lldb::addr_t addr = v.GetLoadAddress(); addr != LLDB_INVALID_ADDRESS)
     var.memoryReference = addr;
 
+  bool is_readonly = v.GetType().IsAggregateType() ||
----------------
DrSergei wrote:

I agree with you, for example, a const global integer variable and a const local integer variable. I don't want to add anything to the SB API because there are a lot of corner cases (and also it looks like `SetData` has less preconditions than `SetValueFromCString`, so we need two different versions of `IsWritable` for both functions). I added simple heuristics at the lldb-dap level to avoid confusing users in most cases. CodeLLDB uses different [heuristics](https://github.com/vadimcn/codelldb/blob/bc1fee16be7451cb0a4fe63dfad5476a1cd11d66/adapter/codelldb/src/debug_session/variables.rs#L231) for that. I think the better solution is to place the check here.

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


More information about the lldb-commits mailing list