Skip to content

Commit bfb3a44

Browse files
authored
[libc++] Index from 0 in GDB pretty printers (llvm#110881)
Fixes llvm#62168
1 parent 121ed5c commit bfb3a44

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,7 @@ void u32string_test() {
232232

233233
void tuple_test() {
234234
std::tuple<int, int, int> test0(2, 3, 4);
235-
ComparePrettyPrintToChars(
236-
test0,
237-
"std::tuple containing = {[1] = 2, [2] = 3, [3] = 4}");
235+
ComparePrettyPrintToChars(test0, "std::tuple containing = {[0] = 2, [1] = 3, [2] = 4}");
238236

239237
std::tuple<> test1;
240238
ComparePrettyPrintToChars(

libcxx/utils/gdb/libcxx/printers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def __next__(self):
173173
field_name = next(self.child_iter)
174174
child = self.val["__base_"][field_name]["__value_"]
175175
self.count += 1
176-
return ("[%d]" % self.count, child)
176+
return ("[%d]" % (self.count - 1), child)
177177

178178
next = __next__ # Needed for GDB built against Python 2.7.
179179

@@ -331,7 +331,7 @@ def __next__(self):
331331
if self.offset >= self.bits_per_word:
332332
self.item += 1
333333
self.offset = 0
334-
return ("[%d]" % self.count, outbit)
334+
return ("[%d]" % (self.count - 1), outbit)
335335

336336
next = __next__ # Needed for GDB built against Python 2.7.
337337

@@ -352,7 +352,7 @@ def __next__(self):
352352
raise StopIteration
353353
entry = self.item.dereference()
354354
self.item += 1
355-
return ("[%d]" % self.count, entry)
355+
return ("[%d]" % (self.count - 1), entry)
356356

357357
next = __next__ # Needed for GDB built against Python 2.7.
358358

0 commit comments

Comments
 (0)