aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/python
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2024-01-10 10:53:43 +0000
committerJonathan Wakely <jwakely@redhat.com>2024-01-11 17:35:57 +0000
commitcd2022f39297198adad0e284f8780cb3d83d0f85 (patch)
tree8dbe2f04ab0787d04376fc0f4fb7c91c22b0084a /libstdc++-v3/python
parentf50f2efae9fb0965d8ccdb62cfdb698336d5a933 (diff)
downloadgcc-cd2022f39297198adad0e284f8780cb3d83d0f85.zip
gcc-cd2022f39297198adad0e284f8780cb3d83d0f85.tar.gz
gcc-cd2022f39297198adad0e284f8780cb3d83d0f85.tar.bz2
libstdc++: Add GDB printer for std::integral_constant
libstdc++-v3/ChangeLog: * python/libstdcxx/v6/printers.py (StdIntegralConstantPrinter): Add printer for std::integral_constant. * testsuite/libstdc++-prettyprinters/cxx11.cc: Test it.
Diffstat (limited to 'libstdc++-v3/python')
-rw-r--r--libstdc++-v3/python/libstdcxx/v6/printers.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index bf0dc52..032a7aa 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -2306,6 +2306,23 @@ class StdLocalePrinter(printer_base):
mod = ' with "{}={}"'.format(cat, other)
return 'std::locale = "{}"{}'.format(name, mod)
+class StdIntegralConstantPrinter(printer_base):
+ """Print a std::true_type or std::false_type."""
+
+ def __init__(self, typename, val):
+ self._val = val
+ self._typename = typename
+
+ def to_string(self):
+ value_type = self._val.type.template_argument(0)
+ value = self._val.type.template_argument(1)
+ if value_type.code == gdb.TYPE_CODE_BOOL:
+ if value:
+ return "std::true_type"
+ else:
+ return "std::false_type"
+ typename = strip_versioned_namespace(self._typename)
+ return "{}<{}, {}>".format(typename, value_type, value)
# A "regular expression" printer which conforms to the
# "SubPrettyPrinter" protocol from gdb.printing.
@@ -2788,6 +2805,9 @@ def build_libstdcxx_dictionary():
# vector<bool>
libstdcxx_printer.add_version('std::', 'locale', StdLocalePrinter)
+ libstdcxx_printer.add_version('std::', 'integral_constant',
+ StdIntegralConstantPrinter)
+
if hasattr(gdb.Value, 'dynamic_type'):
libstdcxx_printer.add_version('std::', 'error_code',
StdErrorCodePrinter)