diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-11-22 21:53:18 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-11-22 21:53:18 (GMT) |
commit | eae64fda5beb687ec3fd51e98ca78dac00d06db7 (patch) | |
tree | cbe7563e982b36e929649b680051b589f878f5b2 /Tools/gdb | |
parent | cb9ab0f50b844ca92c074328a140f67d3690dd9a (diff) | |
download | cpython-eae64fda5beb687ec3fd51e98ca78dac00d06db7.zip cpython-eae64fda5beb687ec3fd51e98ca78dac00d06db7.tar.gz cpython-eae64fda5beb687ec3fd51e98ca78dac00d06db7.tar.bz2 |
Issue #28770: Update python-gdb.py for fastcalls
Frame.is_other_python_frame() now also handles _PyCFunction_FastCallDict()
frames.
Thanks to the new code to handle fast calls, python-gdb.py is now also able to
detect the <built-in id method of module ...> frame.
Diffstat (limited to 'Tools/gdb')
-rwxr-xr-x | Tools/gdb/libpython.py | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/Tools/gdb/libpython.py b/Tools/gdb/libpython.py index e4d2c1e..798b062 100755 --- a/Tools/gdb/libpython.py +++ b/Tools/gdb/libpython.py @@ -1492,23 +1492,38 @@ class Frame(object): ''' if self.is_waiting_for_gil(): return 'Waiting for the GIL' - elif self.is_gc_collect(): + + if self.is_gc_collect(): return 'Garbage-collecting' - else: - # Detect invocations of PyCFunction instances: - older = self.older() - if older and older._gdbframe.name() == 'PyCFunction_Call': - # Within that frame: - # "func" is the local containing the PyObject* of the - # PyCFunctionObject instance - # "f" is the same value, but cast to (PyCFunctionObject*) - # "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")' + + # Detect invocations of PyCFunction instances: + older = self.older() + if not older: + return False + + caller = older._gdbframe.name() + if not caller: + return False + + if caller == 'PyCFunction_Call': + # Within that frame: + # "func" is the local containing the PyObject* of the + # PyCFunctionObject instance + # "f" is the same value, but cast to (PyCFunctionObject*) + # "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 == '_PyCFunction_FastCallDict': + 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: return False |