Re: [patch] Add solib_address and decode_line Python functionality

Ken Werner
2010-08-13T14:07:23Z

[-- Attachment #1: Type: Text/Plain, Size: 680 bytes --]

On Tuesday, August 10, 2010 08:24:09 pm Tom Tromey wrote:
> >>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:
> Tom> So, could you make this conditional?
>
> Phil> Sure, what do you think of the attached patch?
>
> Thanks for persevering. This is ok.

Hi,

It looks like the const qualifier of the format string argument of the
PyArg_Parse* routines has been introduced after the Python 2.4 release:
http://svn.python.org/view?view=rev&revision=41638
In case gdb is built against libpython 2.4 the current code would generate a
warning. One solution would be to just remove the const qualifier. A small
patch is attached. Any comments are appreciated.

Thanks
Ken

[-- Attachment #2: python.patch --]
[-- Type: text/x-patch, Size: 889 bytes --]

ChangeLog:

2010-08-13 Ken Werner <ken.werner@de.ibm.com>

* gdb/python/python.c (gdbpy_solib_name): Remove the const qualifier of
the format strings to be compatible with Python 2.4.

Index: gdb/python/python.c
===================================================================
RCS file: /cvs/src/src/gdb/python/python.c,v
retrieving revision 1.47
diff -p -u -r1.47 python.c
--- gdb/python/python.c 11 Aug 2010 20:54:11 -0000 1.47
+++ gdb/python/python.c 13 Aug 2010 13:44:16 -0000
@@ -388,10 +388,11 @@ gdbpy_solib_name (PyObject *self, PyObje
PyObject *str_obj;
#ifdef PY_LONG_LONG
unsigned PY_LONG_LONG pc;
- const char *format = "K";
+ /* To be compatible with Python 2.4 the format strings are not const. */
+ char *format = "K";
#else
unsigned long pc;
- const char *format = "k";
+ char *format = "k";
#endif

if (!PyArg_ParseTuple (args, format, &pc))