From bed91f4da252b5f30d3cb4fd9f9febd61ad9560d Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 21 Oct 2015 15:57:22 -0400 Subject: Fix accessing a function's fields (parameters) from Python (PR 18073) Since 7.4, gdb doesn't allow calling .fields() on a function type, even though the documentation states it should return a list corresponding to the function's parameters. This patch restores the intended behaviour and adds a test for it. Reg-tested on Arch Linux x86-64. gdb/ChangeLog: PR python/18073 * python/py-type.c (typy_get_composite): Allow returning a function type. gdb/testsuite/ChangeLog: PR python/18073 * gdb.python/py-type.c (C::a_method): New. (C::a_const_method): New. (C::a_static_method): New. (a_function): New. * gdb.python/py-type.exp (test_fields): Test getting fields from function and method. --- gdb/python/py-type.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gdb/python') diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index 7b3f8f9..ef4e719 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -495,10 +495,11 @@ typy_get_composite (struct type *type) exception. */ if (TYPE_CODE (type) != TYPE_CODE_STRUCT && TYPE_CODE (type) != TYPE_CODE_UNION - && TYPE_CODE (type) != TYPE_CODE_ENUM) + && TYPE_CODE (type) != TYPE_CODE_ENUM + && TYPE_CODE (type) != TYPE_CODE_FUNC) { PyErr_SetString (PyExc_TypeError, - "Type is not a structure, union, or enum type."); + "Type is not a structure, union, enum, or function type."); return NULL; } -- cgit v1.1