[mlir] Fix TypeID lookup in GDB pretty printers.
authorChristian Sigg <csigg@google.com>
Mon, 26 Oct 2020 21:13:59 +0000 (22:13 +0100)
committerChristian Sigg <csigg@google.com>
Tue, 27 Oct 2020 06:12:32 +0000 (07:12 +0100)
The TypeID instance was moved in D89153.

It wasn't caught that it broke MLIR pretty printers because pre-merge checks don't run check-debuginfo.

Avoid disabling all MLIR printers in case this happens again by catching the exception.

Reviewed By: stellaraccident

Differential Revision: https://reviews.llvm.org/D90191

mlir/utils/gdb-scripts/prettyprinters.py

index 39246bf..6dd97c6 100644 (file)
@@ -103,8 +103,12 @@ class StorageTypeMap:
     self.map = {}
     for type_name in self.type_names:
       concrete_type = gdb.lookup_type(type_name)
-      storage = gdb.parse_and_eval(
-          "&'mlir::TypeID::get<%s>()::instance'" % type_name)
+      try:
+        storage = gdb.parse_and_eval(
+            "&'mlir::detail::TypeIDExported::get<%s>()::instance'" % type_name)
+      except gdb.error:
+        # Skip when TypeID instance cannot be found in current context.
+        continue
       if concrete_type and storage:
         self.map[int(storage)] = concrete_type