]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - gdb/testsuite/ChangeLog
gdb/python: fix FrameDecorator regression on Python 2
authorAndrew Burgess <andrew.burgess@embecosm.com>
Mon, 15 Mar 2021 14:20:13 +0000 (14:20 +0000)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Tue, 16 Mar 2021 09:31:56 +0000 (09:31 +0000)
commit7807d76a1cc193984c1bdfab456df97632ac721f
tree95e3833e8c321026d4a5064042ef7c6ddc4d99c1
parentf302f9e26e872a8da4b1d4556ea2eeebeca866e7
gdb/python: fix FrameDecorator regression on Python 2

This commit:

  commit d1cab9876d72d867b2de82688f5f5a2a4b655edb
  Date:   Tue Sep 15 11:08:56 2020 -0600

      Don't use gdb_py_long_from_ulongest

Introduced a regression when GDB is compiled with Python 2.  The frame
filter API expects the gdb.FrameDecorator.function () method to return
either a string (the name of a function) or an address, which GDB then
uses to lookup a msymbol.

If the address returned from gdb.FrameDecorator.function () comes from
gdb.Frame.pc () then before the above commit we would always expect to
see a PyLong object.

After the above commit we might (on Python 2) get a PyInt object.

The GDB code does not expect to see a PyInt, and only checks for a
PyLong, we then see an error message like:

  RuntimeError: FrameDecorator.function: expecting a String, integer or None.

This commit just adds an additional call to PyInt_Check which handle
the missing case.

I had already written a test case to cover this issue before spotting
that the gdb.python/py-framefilter.exp test also triggers this
failure.  As the new test case is slightly different I have kept it
in.

The new test forces the behaviour of gdb.FrameDecorator.function
returning an address.  The reason the existing test case hits this is
due to the behaviour of the builtin gdb.FrameDecorator base class.  If
the base class behaviour ever changed then the return an address case
would only be tested by the new test case.

gdb/ChangeLog:

* python/py-framefilter.c (py_print_frame): Use PyInt_Check as
well as PyLong_Check for Python 2.

gdb/testsuite/ChangeLog:

* gdb.python/py-framefilter-addr.c: New file.
* gdb.python/py-framefilter-addr.exp: New file.
* gdb.python/py-framefilter-addr.py: New file.
gdb/ChangeLog
gdb/python/py-framefilter.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.python/py-framefilter-addr.c [new file with mode: 0644]
gdb/testsuite/gdb.python/py-framefilter-addr.exp [new file with mode: 0644]
gdb/testsuite/gdb.python/py-framefilter-addr.py [new file with mode: 0644]