aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2021-03-15 14:20:13 +0000
committerAndrew Burgess <andrew.burgess@embecosm.com>2021-03-16 09:31:56 +0000
commit7807d76a1cc193984c1bdfab456df97632ac721f (patch)
tree95e3833e8c321026d4a5064042ef7c6ddc4d99c1 /gdb/python
parentf302f9e26e872a8da4b1d4556ea2eeebeca866e7 (diff)
downloadgdb-7807d76a1cc193984c1bdfab456df97632ac721f.zip
gdb-7807d76a1cc193984c1bdfab456df97632ac721f.tar.gz
gdb-7807d76a1cc193984c1bdfab456df97632ac721f.tar.bz2
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.
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-framefilter.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
index 6dd741a..1807198 100644
--- a/gdb/python/py-framefilter.c
+++ b/gdb/python/py-framefilter.c
@@ -924,7 +924,11 @@ py_print_frame (PyObject *filter, frame_filter_flags flags,
function = function_to_free.get ();
}
- else if (PyLong_Check (py_func.get ()))
+ else if (PyLong_Check (py_func.get ())
+#if PY_MAJOR_VERSION == 2
+ || PyInt_Check (py_func.get ())
+#endif
+ )
{
CORE_ADDR addr;
struct bound_minimal_symbol msymbol;