This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Fix GDB pretty printers when GDB uses Python 2.7
ClosedPublic

Authored by arichardson on Jan 17 2022, 5:50 AM.

Details

Summary

The gdb_pretty_printer_test.sh fails if GDB was built against Python 2.7
since Python 2 expects iterators to have a next() method rather than
using next. To make the pretty printers work with both Python 2 and 3
we can simply set next to next in the iterator classes.

Python 2.7 support was removed in f46f93b4786377dd7ee704ef2beedadfe4f05adf,
so this effectively reverts that commit. While Python 2.7 is EOL, it
appears there are still many GDB installations that are linked against
Python 2.7, so we may want to keep this tiny amount of compat code
around for a while longer.

Without this commit the tests fails with errors such as:

GDB printed:
   u"std::tuple containingTypeError: iter() returned non-iterator of type '_Children'\n"
Value should match:
   u'std::tuple containing = {[1] = 2, [2] = 3, [3] = 4}'

Diff Detail

Event Timeline

arichardson requested review of this revision.Jan 17 2022, 5:50 AM
arichardson created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJan 17 2022, 5:50 AM
Herald added 1 blocking reviewer(s): Restricted Project. · View Herald Transcript
ldionne accepted this revision.Jan 17 2022, 5:59 AM

This seems like a small workaround to prevent serious headaches from people trying to use this, so LGTM.

This revision is now accepted and ready to land.Jan 17 2022, 5:59 AM