gdbhooks.py: Fix UnicodeDecodeErrors when printing trees with corrupt codes.
authorEugene Sharygin <eush@ispras.ru>
Fri, 26 Apr 2019 15:48:43 +0000 (15:48 +0000)
committerJeff Law <law@gcc.gnu.org>
Fri, 26 Apr 2019 15:48:43 +0000 (09:48 -0600)
* gdbhooks.py: Fix UnicodeDecodeErrors when printing trees with
corrupt codes.

From-SVN: r270607

gcc/ChangeLog
gcc/gdbhooks.py

index 3330d1c8905f3521215c49f5aa6885ffe3e93dbd..4434ba5648328ecfb1f0d202db1478a5e0c3d37c 100644 (file)
@@ -1,3 +1,8 @@
+2018-04-26  Eugene Sharygin  <eush@ispras.ru>
+
+       * gdbhooks.py: Fix UnicodeDecodeErrors when printing trees with
+       corrupt codes.
+
 2019-04-26  Richard Sandiford  <richard.sandiford@arm.com>
 
        * tree.h (TYPE_VECTOR_SUBPARTS, SET_TYPE_VECTOR_SUBPARTS): Add
index bbe7618e299a9ed233d7d60443f538ffee7c4dc1..7b1a7be0002d68ca045fc5646ee8f4edaf40fc4d 100644 (file)
@@ -229,7 +229,10 @@ class TreePrinter:
         val_code_name = val_tree_code_name[intptr(val_TREE_CODE)]
         #print(val_code_name.string())
 
-        result = '<%s 0x%x' % (val_code_name.string(), intptr(self.gdbval))
+        try:
+            result = '<%s 0x%x' % (val_code_name.string(), intptr(self.gdbval))
+        except:
+            return '<tree 0x%x>' % intptr(self.gdbval)
         if intptr(val_tclass) == tcc_declaration:
             tree_DECL_NAME = self.node.DECL_NAME()
             if tree_DECL_NAME.is_nonnull():