MemoryView missing from Python 2.4 and 2.6

Wiederhake, Tim tim.wiederhake@intel.com
Fri Feb 24 10:37:00 GMT 2017


Hi all!

It seems like indeed my code is incompatible with Python 2.4, which according to
the README file is still supported by GDB.

My understanding (correct me if I'm wrong) is that in Python there is the
"old style buffer API", the "new style buffer api" and "memory views".
From: https://docs.python.org/2.7/c-api/buffer.html:
 - "old style buffer API": Deprecated in 2.7, removed in 3.0
 - "new style buffer API": Introduced in 3.0, backported to 2.6
 - "memory view": Introduced in 3.0, backported to 2.7 (used bypy_record_btrace)

That means that there is no buffer API that covers the complete range of Python
versions that are supported by GDB (2.4 to 3.x).

This leaves us with four possible courses of action:

1) Drop the support for Python 2.4, 2.5, 2.6, 3.0, 3.1 and 3.2, making GDB
support "Versions 2.7 and >= 3.3". Rationale:

According to https://docs.python.org/devguide/index.html#branchstatus these
versions are end-of-life'd and do not receive any security patches anymore:

Version	Released	End-of-life
3.2	2011-02-20	2016-02-20
3.1	2009-06-27	2012-04-11
3.0	2008-12-03	2009-01-13
2.6	2008-10-01	2013-10-29
(Versions < 2.6 are not even listed any more on that page.)

This would fix the situation immediately but annoy Jose.

2) Refactor "gdb.Membuf" from python/py-inferior.c into its own file and use
that. I don't like this idea too much because it is basically reinventing the
wheel and gdb.Membuf is less versatile than build-in buffers, strings, etc.

3) Use the "new style buffer API" and limit GDB's support to Python >= 2.6.
In this case we would have to limit the supported Python versions anyway so
on the one hand there is not much reason to not throw out 2.6 as well. On the
other hand, there still seem to be some Python 2.6 users.

4) Return a string in "gdb.BtraceInstruction.data ()". The instruction data can
potentially contain null bytes which can cause issues for obvious reasons.

Regards,
Tim

> -----Original Message-----
> From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] On Behalf Of Yao Qi
> Sent: Friday, February 24, 2017 12:00 AM
> To: Jose E. Marchesi <jose.marchesi@oracle.com>; Wiederhake, Tim
> <tim.wiederhake@intel.com>
> Cc: gdb-patches@sourceware.org; Metzger, Markus T
> <markus.t.metzger@intel.com>
> Subject: Re: MemoryView missing from Python 2.4 and 2.6
> 
> On 17-02-23 17:48:20, Jose E. Marchesi wrote:
> > While building git GDB on a certain distribution that features Python
> > 2.6.6 (I know, ancient) we triggered a build failure:
> >
> > g++  -g -O2   -I. -I../../gdb -I../../gdb/common -I../../gdb/config -
> DLOCALEDIR="\"/usr/local/share/locale\"" -DHAVE_CONFIG_H -
> I../../gdb/../include/opcode -I../../gdb/../opcodes/.. -I../../gdb/../readline/..
> -I../../gdb/../zlib -I../bfd -I../../gdb/../bfd -I../../gdb/../include -
> I../libdecnumber -I../../gdb/../libdecnumber  -I../../gdb/gnulib/import -
> Ibuild-gnulib/import   -DTUI=1  -I/usr/include/python2.6 -
> I/usr/include/python2.6 -Wall -Wpointer-arith -Wno-unused -Wunused-
> value -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body
> -Wunused-but-set-parameter -Wunused-but-set-variable -Wno-sign-
> compare -Wno-write-strings -Wno-narrowing -Wformat-nonliteral -Werror -c
> -o py-record-btrace.o -MT py-record-btrace.o -MMD -MP -MF .deps/py-
> record-btrace.Tpo -fno-strict-aliasing -DNDEBUG -fwrapv
> ../../gdb/python/py-record-btrace.c
> > ../../gdb/python/py-record-btrace.c: In function ???PyObject*
> btpy_insn_data(PyObject*, void*)???:
> > ../../gdb/python/py-record-btrace.c:333:10: error:
> ???PyMemoryView_FromObject??? was not declared in this scope
> >    return PyMemoryView_FromObject (object);
> >           ^~~~~~~~~~~~~~~~~~~~~~~
> > ../../gdb/python/py-record-btrace.c:333:10: note: suggested alternative:
> ???PyBuffer_FromObject???
> >    return PyMemoryView_FromObject (object);
> >           ^~~~~~~~~~~~~~~~~~~~~~~
> >           PyBuffer_FromObject
> > make: *** [py-record-btrace.o] Error 1
> >
> > Looks like the Memory View object was introduced in Python 2.7.
> 
> Hi Tim,
> Could you take a look?
> 
> --
> Yao
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928



More information about the Gdb-patches mailing list