summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-01-18 17:20:01 +0100
committerVictor Stinner <victor.stinner@gmail.com>2017-01-18 17:20:01 +0100
commit9674949696574bee9ae2bc3b9b56c30ea12285c0 (patch)
tree61889de9b3f41f3cb0cacafa4ab3691ecff138a9
parentc4ed3158f8d9458a38a5985eb8e30ac7209fbaf9 (diff)
downloadcpython-9674949696574bee9ae2bc3b9b56c30ea12285c0.tar.gz
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
-rw-r--r--Lib/test/test_gdb.py2
-rwxr-xr-xTools/gdb/libpython.py26
2 files changed, 11 insertions, 17 deletions
diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py
index 60f1d92846..557591f76c 100644
--- a/Lib/test/test_gdb.py
+++ b/Lib/test/test_gdb.py
@@ -845,7 +845,7 @@ id(42)
breakpoint='time_gmtime',
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):
diff --git a/Tools/gdb/libpython.py b/Tools/gdb/libpython.py
index 5c59b99942..0903c01766 100755
--- a/Tools/gdb/libpython.py
+++ b/Tools/gdb/libpython.py
@@ -1497,15 +1497,17 @@ class Frame(object):
return 'Garbage-collecting'
# Detect invocations of PyCFunction instances:
- older = self.older()
- if not older:
- return False
-
- caller = older._gdbframe.name()
+ frame = self._gdbframe
+ caller = frame.name()
if not caller:
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:
# "func" is the local containing the PyObject* of the
# PyCFunctionObject instance
@@ -1513,18 +1515,10 @@ class Frame(object):
# "self" is the (PyObject*) of the 'self'
try:
# Use the prettyprinter for the func:
- func = older._gdbframe.read_var('func')
- return str(func)
- except RuntimeError:
- return 'PyCFunction invocation (unable to read "func")'
-
- elif caller in ('_PyCFunction_FastCallDict',
- '_PyCFunction_FastCallKeywords'):
- try:
- func = older._gdbframe.read_var('func_obj')
+ func = frame.read_var(arg_name)
return str(func)
except RuntimeError:
- return 'PyCFunction invocation (unable to read "func_obj")'
+ return 'PyCFunction invocation (unable to read %s)' % arg_name
# This frame isn't worth reporting:
return False