mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Update and enhance python-gdb.py
Issue #29259: * Detect PyCFunction is the current frame, not only in the older frame * Ignore PyCFunction_Call() since it now calls _PyCFunction_FastCallDict(), and _PyCFunction_FastCallDict() is already detected
This commit is contained in:
parent
e69f0e6111
commit
fa025f112f
2 changed files with 11 additions and 17 deletions
|
@ -845,7 +845,7 @@ id(42)
|
||||||
breakpoint='time_gmtime',
|
breakpoint='time_gmtime',
|
||||||
cmds_after_breakpoint=['py-bt-full'],
|
cmds_after_breakpoint=['py-bt-full'],
|
||||||
)
|
)
|
||||||
self.assertIn('#0 <built-in method gmtime', gdb_output)
|
self.assertIn('#1 <built-in method gmtime', gdb_output)
|
||||||
|
|
||||||
|
|
||||||
class PyPrintTests(DebuggerTests):
|
class PyPrintTests(DebuggerTests):
|
||||||
|
|
|
@ -1497,15 +1497,17 @@ class Frame(object):
|
||||||
return 'Garbage-collecting'
|
return 'Garbage-collecting'
|
||||||
|
|
||||||
# Detect invocations of PyCFunction instances:
|
# Detect invocations of PyCFunction instances:
|
||||||
older = self.older()
|
frame = self._gdbframe
|
||||||
if not older:
|
caller = frame.name()
|
||||||
return False
|
|
||||||
|
|
||||||
caller = older._gdbframe.name()
|
|
||||||
if not caller:
|
if not caller:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if caller == 'PyCFunction_Call':
|
if caller in ('_PyCFunction_FastCallDict',
|
||||||
|
'_PyCFunction_FastCallKeywords'):
|
||||||
|
if caller == '_PyCFunction_FastCallKeywords':
|
||||||
|
arg_name = 'func_obj'
|
||||||
|
else:
|
||||||
|
arg_name = 'func'
|
||||||
# Within that frame:
|
# Within that frame:
|
||||||
# "func" is the local containing the PyObject* of the
|
# "func" is the local containing the PyObject* of the
|
||||||
# PyCFunctionObject instance
|
# PyCFunctionObject instance
|
||||||
|
@ -1513,18 +1515,10 @@ class Frame(object):
|
||||||
# "self" is the (PyObject*) of the 'self'
|
# "self" is the (PyObject*) of the 'self'
|
||||||
try:
|
try:
|
||||||
# Use the prettyprinter for the func:
|
# Use the prettyprinter for the func:
|
||||||
func = older._gdbframe.read_var('func')
|
func = frame.read_var(arg_name)
|
||||||
return str(func)
|
return str(func)
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
return 'PyCFunction invocation (unable to read "func")'
|
return 'PyCFunction invocation (unable to read %s)' % arg_name
|
||||||
|
|
||||||
elif caller in ('_PyCFunction_FastCallDict',
|
|
||||||
'_PyCFunction_FastCallKeywords'):
|
|
||||||
try:
|
|
||||||
func = older._gdbframe.read_var('func_obj')
|
|
||||||
return str(func)
|
|
||||||
except RuntimeError:
|
|
||||||
return 'PyCFunction invocation (unable to read "func_obj")'
|
|
||||||
|
|
||||||
# This frame isn't worth reporting:
|
# This frame isn't worth reporting:
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue