[3.7] bpo-32962: Backport python-gdb.py and test_gdb.py from master (… · python/cpython@ca4cb84 (original) (raw)
`@@ -270,12 +270,13 @@ def is_optimized_out(self):
`
270
270
``
271
271
`def safe_tp_name(self):
`
272
272
`try:
`
273
``
`-
return self.type().field('tp_name').string()
`
274
``
`-
except NullPyObjectPtr:
`
275
``
`-
NULL tp_name?
`
276
``
`-
return 'unknown'
`
277
``
`-
except RuntimeError:
`
278
``
`-
Can't even read the object at all?
`
``
273
`+
ob_type = self.type()
`
``
274
`+
tp_name = ob_type.field('tp_name')
`
``
275
`+
return tp_name.string()
`
``
276
`+
NullPyObjectPtr: NULL tp_name?
`
``
277
`+
RuntimeError: Can't even read the object at all?
`
``
278
`+
UnicodeDecodeError: Failed to decode tp_name bytestring
`
``
279
`+
except (NullPyObjectPtr, RuntimeError, UnicodeDecodeError):
`
279
280
`return 'unknown'
`
280
281
``
281
282
`def proxyval(self, visited):
`
`@@ -349,7 +350,9 @@ def subclass_from_type(cls, t):
`
349
350
`try:
`
350
351
`tp_name = t.field('tp_name').string()
`
351
352
`tp_flags = int(t.field('tp_flags'))
`
352
``
`-
except RuntimeError:
`
``
353
`+
RuntimeError: NULL pointers
`
``
354
`+
UnicodeDecodeError: string() fails to decode the bytestring
`
``
355
`+
except (RuntimeError, UnicodeDecodeError):
`
353
356
`# Handle any kind of error e.g. NULL ptrs by simply using the base
`
354
357
`# class
`
355
358
`return cls
`
`@@ -617,7 +620,10 @@ class PyCFunctionObjectPtr(PyObjectPtr):
`
617
620
``
618
621
`def proxyval(self, visited):
`
619
622
`m_ml = self.field('m_ml') # m_ml is a (PyMethodDef*)
`
620
``
`-
ml_name = m_ml['ml_name'].string()
`
``
623
`+
try:
`
``
624
`+
ml_name = m_ml['ml_name'].string()
`
``
625
`+
except UnicodeDecodeError:
`
``
626
`+
ml_name = '<ml_name:UnicodeDecodeError>'
`
621
627
``
622
628
`pyop_m_self = self.pyop_field('m_self')
`
623
629
`if pyop_m_self.is_null():
`
`@@ -1340,13 +1346,13 @@ def safe_name(self):
`
1340
1346
`try:
`
1341
1347
`name = self.field('descr')['d_base']['name'].string()
`
1342
1348
`return repr(name)
`
1343
``
`-
except (NullPyObjectPtr, RuntimeError):
`
``
1349
`+
except (NullPyObjectPtr, RuntimeError, UnicodeDecodeError):
`
1344
1350
`return ''
`
1345
1351
``
1346
1352
`def safe_tp_name(self):
`
1347
1353
`try:
`
1348
1354
`return self.field('self')['ob_type']['tp_name'].string()
`
1349
``
`-
except (NullPyObjectPtr, RuntimeError):
`
``
1355
`+
except (NullPyObjectPtr, RuntimeError, UnicodeDecodeError):
`
1350
1356
`return ''
`
1351
1357
``
1352
1358
`def safe_self_addresss(self):
`
`@@ -1552,15 +1558,22 @@ def is_other_python_frame(self):
`
1552
1558
`# Use the prettyprinter for the func:
`
1553
1559
`func = frame.read_var(arg_name)
`
1554
1560
`return str(func)
`
``
1561
`+
except ValueError:
`
``
1562
`+
return ('PyCFunction invocation (unable to read %s: '
`
``
1563
`+
'missing debuginfos?)' % arg_name)
`
1555
1564
`except RuntimeError:
`
1556
1565
`return 'PyCFunction invocation (unable to read %s)' % arg_name
`
1557
1566
``
1558
1567
`if caller == 'wrapper_call':
`
``
1568
`+
arg_name = 'wp'
`
1559
1569
`try:
`
1560
``
`-
func = frame.read_var('wp')
`
``
1570
`+
func = frame.read_var(arg_name)
`
1561
1571
`return str(func)
`
``
1572
`+
except ValueError:
`
``
1573
`+
return ('<wrapper_call invocation (unable to read %s: '
`
``
1574
`+
'missing debuginfos?)>' % arg_name)
`
1562
1575
`except RuntimeError:
`
1563
``
`-
return ''
`
``
1576
`+
return '<wrapper_call invocation (unable to read %s)>' % arg_name
`
1564
1577
``
1565
1578
`# This frame isn't worth reporting:
`
1566
1579
`return False
`