From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17269 invoked by alias); 19 Oct 2008 20:18:50 -0000 Received: (qmail 17258 invoked by uid 22791); 19 Oct 2008 20:18:49 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 19 Oct 2008 20:18:12 +0000 Received: (qmail 16256 invoked from network); 19 Oct 2008 20:18:09 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 19 Oct 2008 20:18:09 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Make GDB build with python 2.4 again. Date: Sun, 19 Oct 2008 20:18:00 -0000 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_KY5+IUeGo+W3iJn" Message-Id: <200810192118.18369.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-10/txt/msg00470.txt.bz2 --Boundary-00=_KY5+IUeGo+W3iJn Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 1247 gcc -g -O2 -I. -I../../head/gdb -I../../head/gdb/config -DLOCALEDIR="\"/usr/local/share/locale\"" -DHAVE_CONFIG_H -I../../head/gdb/../include/opcode -I../../head/gdb/../readline/.. -I../bfd -I../../head/gdb/../bfd -I../../head/gdb/../include -I../libdecnumber -I../../head/gdb/../libdecnumber -I../../head/gdb/gnulib -Ignulib -DMI_OUT=1 -DTUI=1 -Wall -Wdeclaration-after-statement -Wpointer-arith -Wformat-nonliteral -Wno-unused -Wno-switch -Wno-char-subscripts -Werror -c -o python-value.o -MT python-value.o -MMD -MP -MF .deps/python-value.Tpo -fno-strict-aliasing -DNDEBUG -fwrapv ../../head/gdb/python/python-value.c ../../head/gdb/python/python-value.c:100: warning: initialization from incompatible pointer type make: *** [python-value.o] Error 1 /usr/include/python2.4/object.h typedef int (*inquiry)(PyObject *); typedef struct { inquiry mp_length; binaryfunc mp_subscript; objobjargproc mp_ass_subscript; } PyMappingMethods; /usr/include/python2.5/object.h typedef Py_ssize_t (*lenfunc)(PyObject *); typedef struct { lenfunc mp_length; binaryfunc mp_subscript; objobjargproc mp_ass_subscript; } PyMappingMethods; I'm checking in the attached fix. I get 95 expected passes with both 2.4 and 2.5. -- Pedro Alves --Boundary-00=_KY5+IUeGo+W3iJn Content-Type: text/x-diff; charset="utf-8"; name="python.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="python.diff" Content-length: 5947 2008-10-19 Pedro Alves * python/python-value.c (value_object_methods) (value_object_as_number, value_object_as_mapping): Move to bottom of file. (valpy_dealloc, valpy_new, valpy_length, valpy_getitem) (valpy_setitem, valpy_str, valpy_add, valpy_subtract) (valpy_multiply, valpy_divide, valpy_remainder, valpy_power) (valpy_negative, valpy_positive, valpy_absolute, valpy_nonzero) (valpy_richcompare, valpy_dereference): Don't forward-declare. (valpy_length) [HAVE_LIBPYTHON2_4]: Change return type to `int'. --- gdb/python/python-value.c | 139 ++++++++++++++++++++-------------------------- 1 file changed, 61 insertions(+), 78 deletions(-) Index: src/gdb/python/python-value.c =================================================================== --- src.orig/gdb/python/python-value.c 2008-10-19 20:27:15.000000000 +0100 +++ src/gdb/python/python-value.c 2008-10-19 20:28:25.000000000 +0100 @@ -57,84 +57,6 @@ typedef struct { int owned_by_gdb; } value_object; -static void valpy_dealloc (PyObject *obj); -static PyObject *valpy_new (PyTypeObject *subtype, PyObject *args, - PyObject *keywords); -static Py_ssize_t valpy_length (PyObject *self); -static PyObject *valpy_getitem (PyObject *self, PyObject *key); -static int valpy_setitem (PyObject *self, PyObject *key, PyObject *value); -static PyObject *valpy_str (PyObject *self); -static PyObject *valpy_add (PyObject *self, PyObject *other); -static PyObject *valpy_subtract (PyObject *self, PyObject *other); -static PyObject *valpy_multiply (PyObject *self, PyObject *other); -static PyObject *valpy_divide (PyObject *self, PyObject *other); -static PyObject *valpy_remainder (PyObject *self, PyObject *other); -static PyObject *valpy_power (PyObject *self, PyObject *other, PyObject *unused); -static PyObject *valpy_negative (PyObject *self); -static PyObject *valpy_positive (PyObject *self); -static PyObject *valpy_absolute (PyObject *self); -static int valpy_nonzero (PyObject *self); -static PyObject *valpy_richcompare (PyObject *self, PyObject *other, int op); -static PyObject *valpy_dereference (PyObject *self, PyObject *args); - -static PyMethodDef value_object_methods[] = { - { "dereference", valpy_dereference, METH_NOARGS, "Dereferences the value." }, - {NULL} /* Sentinel */ -}; - -static PyNumberMethods value_object_as_number = { - valpy_add, - valpy_subtract, - valpy_multiply, - valpy_divide, - valpy_remainder, - NULL, /* nb_divmod */ - valpy_power, /* nb_power */ - valpy_negative, /* nb_negative */ - valpy_positive, /* nb_positive */ - valpy_absolute, /* nb_absolute */ - valpy_nonzero /* nb_nonzero */ -}; - -static PyMappingMethods value_object_as_mapping = { - valpy_length, - valpy_getitem, - valpy_setitem -}; - -PyTypeObject value_object_type = { - PyObject_HEAD_INIT (NULL) - 0, /*ob_size*/ - "gdb.Value", /*tp_name*/ - sizeof (value_object), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - valpy_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - &value_object_as_number, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - &value_object_as_mapping, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - valpy_str, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/ - "GDB value object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - valpy_richcompare, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - value_object_methods /* tp_methods */ -}; - - /* Called by the Python interpreter when deallocating a value object. */ static void valpy_dealloc (PyObject *obj) @@ -206,7 +128,11 @@ valpy_dereference (PyObject *self, PyObj return value_to_value_object (res_val); } +#ifdef HAVE_LIBPYTHON2_4 +static int +#else static Py_ssize_t +#endif valpy_length (PyObject *self) { /* We don't support getting the number of elements in a struct / class. */ @@ -686,4 +612,61 @@ gdbpy_initialize_values (void) values_in_python = NULL; } +static PyMethodDef value_object_methods[] = { + { "dereference", valpy_dereference, METH_NOARGS, "Dereferences the value." }, + {NULL} /* Sentinel */ +}; + +static PyNumberMethods value_object_as_number = { + valpy_add, + valpy_subtract, + valpy_multiply, + valpy_divide, + valpy_remainder, + NULL, /* nb_divmod */ + valpy_power, /* nb_power */ + valpy_negative, /* nb_negative */ + valpy_positive, /* nb_positive */ + valpy_absolute, /* nb_absolute */ + valpy_nonzero /* nb_nonzero */ +}; + +static PyMappingMethods value_object_as_mapping = { + valpy_length, + valpy_getitem, + valpy_setitem +}; + +PyTypeObject value_object_type = { + PyObject_HEAD_INIT (NULL) + 0, /*ob_size*/ + "gdb.Value", /*tp_name*/ + sizeof (value_object), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + valpy_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + &value_object_as_number, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + &value_object_as_mapping, /*tp_as_mapping*/ + 0, /*tp_hash */ + 0, /*tp_call*/ + valpy_str, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/ + "GDB value object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + valpy_richcompare, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + value_object_methods /* tp_methods */ +}; + #endif /* HAVE_PYTHON */ --Boundary-00=_KY5+IUeGo+W3iJn--