[Lldb-commits] [lldb] Bugfix: Not showing the synthetic children of values behind pointers (PR #117755)
@@ -4028,6 +4032,9 @@ void request_variables(DAP &dap, const llvm::json::Object &request) { dap.enable_synthetic_child_debugging, /*is_name_duplicated=*/false, custom_name)); }; + if (variable.GetType().IsPointerType() || variable.GetType().IsReferenceType()) { +variable = variable.Dereference(); + } skuznetsov wrote: The first change is more than enough. To be on the safe side, I overcomplicated it a little. https://github.com/llvm/llvm-project/pull/117755 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Bugfix: Not showing the synthetic children of values behind pointers (PR #117755)
https://github.com/skuznetsov edited https://github.com/llvm/llvm-project/pull/117755 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Bugfix: Not showing the synthetic children of values behind pointers (PR #117755)
skuznetsov wrote: @clayborg This is what puzzles me, too. As I provided the examples in the Discourse thread, it works in the CLI lldb but not when used in lldb-dap. It works only if it is dereferenced. https://github.com/llvm/llvm-project/pull/117755 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Bugfix: Not showing the synthetic children of values behind pointers (PR #117755)
https://github.com/skuznetsov created https://github.com/llvm/llvm-project/pull/117755 This bug fix for the situation that was extensively discussed at LLVM Discourse thread: https://discourse.llvm.org/t/synthetic-data-providers-and-lldb-dap/ >From 82a3bc3aaf57f25a1041cda4082b24bd8cdf8919 Mon Sep 17 00:00:00 2001 From: Sergey Kuznetsov Date: Tue, 26 Nov 2024 12:54:30 -0500 Subject: [PATCH] Bugfix: Not showing the synthetic children of values behind pointers --- lldb/tools/lldb-dap/lldb-dap.cpp | 7 +++ 1 file changed, 7 insertions(+) diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp index 3bfc578806021e..b86994f60f04e5 100644 --- a/lldb/tools/lldb-dap/lldb-dap.cpp +++ b/lldb/tools/lldb-dap/lldb-dap.cpp @@ -4020,6 +4020,10 @@ void request_variables(DAP &dap, const llvm::json::Object &request) { std::optional custom_name = {}) { if (!child.IsValid()) return; +if (child.IsSynthetic() && (child.GetType().IsPointerType() || child.GetType().IsReferenceType())) { + // Dereference to access synthetic children behind pointers/references + child = child.Dereference(); +} bool is_permanent = dap.variables.IsPermanentVariableReference(variablesReference); int64_t var_ref = dap.variables.InsertVariable(child, is_permanent); @@ -4028,6 +4032,9 @@ void request_variables(DAP &dap, const llvm::json::Object &request) { dap.enable_synthetic_child_debugging, /*is_name_duplicated=*/false, custom_name)); }; + if (variable.GetType().IsPointerType() || variable.GetType().IsReferenceType()) { +variable = variable.Dereference(); + } const int64_t num_children = variable.GetNumChildren(); int64_t end_idx = start + ((count == 0) ? num_children : count); int64_t i = start; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Bugfix: Not showing the synthetic children of values behind pointers (PR #117755)
skuznetsov wrote: > Can you post a copy of a the python code for the synthetic child provider you > are creating and also how you are registering it with LLDB? Here it is: ``` # Hash(K,V) class support providers class CrystalHashSyntheticProvider: def __init__(self, valobj, internal_dict): self.valobj = valobj self.extract_entries() def has_children(self): return True def num_children(self): size = self.valobj.GetChildMemberWithName("size").unsigned return size def get_child_index(self, name): name = name.lstrip('[').rstrip(']') if name == "size": return len(self._entries) + 1 if self._entries else 1 try: idx = next((index for index, obj in enumerate(self._entries) if getattr(self._entries, "key") == name), -1) return idx except: return -1 def get_child_at_index(self, index): if index > len(self.entries): return None if index == len(self.entries): return self.valobj.GetChildMemberWithName("size") entry = self.entries[index] key = entry.GetChildMemberWithName("key").GetSummary() value = entry.GetChildMemberWithName("value").deref return value.CreateChildAtOffset("[%s]" % key, 0, value.type) # return entry.CreateChildAtOffset("[%d]" % index, 0, entry.type) def extract_entries(self): if self.valobj.type.is_pointer: self.valobj = self.valobj.Dereference() self.size = 0 if self.valobj.GetChildMemberWithName("size").value is None else self.valobj.GetChildMemberWithName("size").unsigned self.entries = [] for index in range(self.size): try: valuePath = "entries[%d]" % index value = self.valobj.EvaluateExpression(valuePath) if value.type.is_pointer: value = value.deref self.entries.append(value) except Exception as e: print('Got exception %s' % (str(e))) return None print ("Created %d entries." % len(self.entries)) ``` https://github.com/llvm/llvm-project/pull/117755 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Bugfix: Not showing the synthetic children of values behind pointers (PR #117755)
skuznetsov wrote: > src="https://private-user-images.githubusercontent.com/4421997/391664786-b7dbb80c-5f7d-4dd8-a0db-d0b8fe10cf21.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzMxNjQxODMsIm5iZiI6MTczMzE2Mzg4MywicGF0aCI6Ii80NDIxOTk3LzM5MTY2NDc4Ni1iN2RiYjgwYy01ZjdkLTRkZDgtYTBkYi1kMGI4ZmUxMGNmMjEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MTIwMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDEyMDJUMTgyNDQzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZTRkODk3NjRhNThjZmE2ZGE5Yzg0YjQxMzgyMDY2NWMxZGE4OGI1NDM0ZGRjZWJhMDVkZjg3ZmMxNzE2YjJlMiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.hjCRHnWRytRb8EiK6D5omVOi7WWXogpogZzsG_NswF0";> > Still works inside of a structure. Anything else I can try? I tried your example and modified it in a similar way: embedded pointer to another vector, and it was working as expected. So, I am still investigating what can be wrong here. I am digging through the ll file for the code to find the debug declarations to recover the type. I tried to do it via lldb, but when I type 'type lookup LavinMQ::VHostStore', it does not find it. I suspect due to the special characters "::" that are used for namespace separation. https://github.com/llvm/llvm-project/pull/117755 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Bugfix: Not showing the synthetic children of values behind pointers (PR #117755)
skuznetsov wrote: @clayborg Thank you, Greg! Lots of that info is not described anywhere, no wonder I missed it. Let me try your fixes in my provider, and I will get back to you. By some reason my provider works in CLI lldb, but not in lldb-dap, but I will check if your suggestions will help to fix that. https://github.com/llvm/llvm-project/pull/117755 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Bugfix: Not showing the synthetic children of values behind pointers (PR #117755)
skuznetsov wrote: > > @clayborg Thank you, Greg! Lots of that info is not described anywhere, no > > wonder I missed it. Let me try your fixes in my provider, and I will get > > back to you. > > By some reason my provider works in CLI lldb, but not in lldb-dap, but I > > will check if your suggestions will help to fix that. > > Let me know if this fixes things. I believe it will. I tried your approach and your recommended code changes, but it does not work without my patch for some strange reason. :( https://github.com/llvm/llvm-project/pull/117755 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits