Skip to content

Commit 2e054a4

Browse files
committed
properly fixes the LLDB pretty printer
1 parent cf66e89 commit 2e054a4

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

lldb/examples/synthetic/libcxx.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,24 @@ def get_buffer_endcap(parent, buffer, begin, has_compressed_pair_layout, is_size
104104
map_endcap = parent._get_value_of_compressed_pair(
105105
buffer.GetChildMemberWithName("__end_cap_")
106106
)
107+
elif buffer.GetType().GetNumberOfDirectBaseClasses() == 1:
108+
# LLVM 22's __split_buffer is derived from a base class that describes its layout. When the
109+
# compressed pair ABI is required, we also use an anonymous struct. Per [#158131], LLDB
110+
# is unable to access members of an anonymous struct to a base class, through the derived
111+
# class. This means that in order to access the compressed pair's pointer, we need to first
112+
# get to its base class.
113+
#
114+
# [#158131]: https://github.com/llvm/llvm-project/issues/158131
115+
buffer = buffer.GetChildAtIndex(0)
116+
if is_size_based:
117+
map_endcap = buffer.GetChildMemberWithName("__cap_")
118+
else:
119+
map_endcap = buffer.GetChildMemberWithName("__back_cap_")
120+
map_endcap = map_endcap.GetValueAsUnsigned(0)
107121
else:
108122
map_endcap = buffer.GetChildMemberWithName("__cap_")
109123
if not map_endcap.IsValid():
110124
map_endcap = buffer.GetChildMemberWithName("__end_cap_")
111-
if not map_endcap.IsValid():
112-
map_endcap = buffer.GetChildMemberWithName("__back_cap_")
113125
map_endcap = map_endcap.GetValueAsUnsigned(0)
114126

115127
if is_size_based:
@@ -804,11 +816,11 @@ def update(self):
804816
map_ = self.valobj.GetChildMemberWithName("__map_")
805817
is_size_based = map_.GetChildMemberWithName("__size_").IsValid()
806818
first = map_.GetChildMemberWithName("__first_")
819+
# LLVM 22 renames __map_.__begin_ to __map_.__front_cap_
820+
if not first:
821+
first = map_.GetChildMemberWithName("__front_cap_")
807822
map_first = first.GetValueAsUnsigned(0)
808823
self.map_begin = map_.GetChildMemberWithName("__begin_")
809-
# LLVM 22 renames __map_.__begin_ to __map_.__front_cap_
810-
if not self.map_begin:
811-
self.map_begin = map_.GetChildMemberWithName("__front_cap_")
812824
map_begin = self.map_begin.GetValueAsUnsigned(0)
813825
map_end = get_buffer_end(map_, map_begin)
814826
map_endcap = get_buffer_endcap(

0 commit comments

Comments
 (0)