[libcxx-commits] [libcxx] bfb3a44 - [libc++] Index from 0 in GDB pretty printers (#110881)

via libcxx-commits libcxx-commits at lists.llvm.org
Thu Oct 3 06:07:11 PDT 2024


Author: Louis Dionne
Date: 2024-10-03T09:07:08-04:00
New Revision: bfb3a442b83a5e9fc4b3d3919d845dc8bded810f

URL: https://github.com/llvm/llvm-project/commit/bfb3a442b83a5e9fc4b3d3919d845dc8bded810f
DIFF: https://github.com/llvm/llvm-project/commit/bfb3a442b83a5e9fc4b3d3919d845dc8bded810f.diff

LOG: [libc++] Index from 0 in GDB pretty printers (#110881)

Fixes #62168

Added: 
    

Modified: 
    libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp
    libcxx/utils/gdb/libcxx/printers.py

Removed: 
    


################################################################################
diff  --git a/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp b/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp
index 2c8534977febc7..9d4b7039402a49 100644
--- a/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp
+++ b/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp
@@ -232,9 +232,7 @@ void u32string_test() {
 
 void tuple_test() {
   std::tuple<int, int, int> test0(2, 3, 4);
-  ComparePrettyPrintToChars(
-      test0,
-      "std::tuple containing = {[1] = 2, [2] = 3, [3] = 4}");
+  ComparePrettyPrintToChars(test0, "std::tuple containing = {[0] = 2, [1] = 3, [2] = 4}");
 
   std::tuple<> test1;
   ComparePrettyPrintToChars(

diff  --git a/libcxx/utils/gdb/libcxx/printers.py b/libcxx/utils/gdb/libcxx/printers.py
index 49087f94c06265..8e74b93e7b121f 100644
--- a/libcxx/utils/gdb/libcxx/printers.py
+++ b/libcxx/utils/gdb/libcxx/printers.py
@@ -173,7 +173,7 @@ def __next__(self):
             field_name = next(self.child_iter)
             child = self.val["__base_"][field_name]["__value_"]
             self.count += 1
-            return ("[%d]" % self.count, child)
+            return ("[%d]" % (self.count - 1), child)
 
         next = __next__  # Needed for GDB built against Python 2.7.
 
@@ -331,7 +331,7 @@ def __next__(self):
             if self.offset >= self.bits_per_word:
                 self.item += 1
                 self.offset = 0
-            return ("[%d]" % self.count, outbit)
+            return ("[%d]" % (self.count - 1), outbit)
 
         next = __next__  # Needed for GDB built against Python 2.7.
 
@@ -352,7 +352,7 @@ def __next__(self):
                 raise StopIteration
             entry = self.item.dereference()
             self.item += 1
-            return ("[%d]" % self.count, entry)
+            return ("[%d]" % (self.count - 1), entry)
 
         next = __next__  # Needed for GDB built against Python 2.7.
 


        


More information about the libcxx-commits mailing list