[libcxx-commits] [libcxx] [llvm] [libcxx][lldb] Add initial LLDB data-formatters (PR #187677)
Dave Lee via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Mar 20 09:25:33 PDT 2026
================
@@ -0,0 +1,263 @@
+"""
+Python LLDB data formatter for libc++ std::vector
+
+1-to-1 translation from the LLDB builtin std::vector formatter.
+
+Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+See https://llvm.org/LICENSE.txt for license information.
+SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+"""
+
+import lldb
+
+
+def get_data_pointer(root):
+ """Get the data pointer from a vector, handling compressed pair layout."""
+ # Try new layout
+ cap_sp = root.GetChildMemberWithName("__cap_")
+ if cap_sp and cap_sp.IsValid():
+ return cap_sp
+
+ # Try old compressed pair layout
+ end_cap_sp = root.GetChildMemberWithName("__end_cap_")
+ if not end_cap_sp or not end_cap_sp.IsValid():
+ return None
+
+ # Get first value of compressed pair
+ value_sp = end_cap_sp.GetChildMemberWithName("__value_")
+ if value_sp and value_sp.IsValid():
+ return value_sp
+
+ first_sp = end_cap_sp.GetChildMemberWithName("__first_")
+ if first_sp and first_sp.IsValid():
+ return first_sp
+
+ return None
+
+
+class LibCxxStdVectorSyntheticFrontEnd:
+ """Synthetic children frontend for libc++ std::vector."""
+
+ def __init__(self, valobj, internal_dict):
+ self.valobj = valobj
+ self.m_start = None
+ self.m_finish = None
+ self.m_element_type = None
+ self.m_element_size = 0
+ self.update()
----------------
kastiglione wrote:
It's not a big deal, but in my synthetic formatters, I never include a `self.update()` call in `__init__` because `update` gets called on the synthetic anyway.
https://github.com/llvm/llvm-project/pull/187677
More information about the libcxx-commits
mailing list