[libcxx-commits] [libcxx] [libc++] Index from 0 in GDB pretty printers (PR #110881)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Oct 3 06:07:09 PDT 2024
https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/110881
>From a3626dba6c4d1e3c1fb502c3882d56ff4fc88477 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Wed, 2 Oct 2024 12:32:21 -0400
Subject: [PATCH 1/2] [libc++] Index from 0 in GDB pretty printers
Fixes #62168
---
libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp | 2 +-
libcxx/utils/gdb/libcxx/printers.py | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
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..f4b097613baf3c 100644
--- a/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp
+++ b/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp
@@ -234,7 +234,7 @@ void tuple_test() {
std::tuple<int, int, int> test0(2, 3, 4);
ComparePrettyPrintToChars(
test0,
- "std::tuple containing = {[1] = 2, [2] = 3, [3] = 4}");
+ "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.
>From e942b44aecbeb79044c36f2a5a03ce83a716ccce Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Thu, 3 Oct 2024 09:06:57 -0400
Subject: [PATCH 2/2] Format
---
libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
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 f4b097613baf3c..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 = {[0] = 2, [1] = 3, [2] = 4}");
+ ComparePrettyPrintToChars(test0, "std::tuple containing = {[0] = 2, [1] = 3, [2] = 4}");
std::tuple<> test1;
ComparePrettyPrintToChars(
More information about the libcxx-commits
mailing list