Message ID | 87bm13pgye.fsf@ispras.ru |
---|---|
State | New |
Headers | show |
Series | gdbhooks.py: Fix UnicodeDecodeErrors when printing trees with corrupt codes | expand |
On 4/18/19 6:47 AM, Eugene Sharygin wrote: > Hi, > > This silences UnicodeDecodeError Python exceptions raised when trying to > print a tree with a corrupt (or uninitialized) code in Gdb: > > Python Exception <class 'UnicodeDecodeError'> 'utf-8' codec can't decode byte 0xb8 in position 0: invalid start byte: > > With this patch, TreePrinter would print such trees generically like > this (in the format it uses for null trees): > > <tree 0x7f8459c76500> > > Eugene > > 2018-04-18 Eugene Sharygin <eush@ispras.ru> > > * gdbhooks.py: Fix UnicodeDecodeErrors when printing trees with > corrupt codes. THanks. I've committed this to the trunk. jeff
diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py index bbe7618e299..7b1a7be0002 100644 --- a/gcc/gdbhooks.py +++ b/gcc/gdbhooks.py @@ -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():