Message ID | 20161120204526.7203-1-jonah@kichwacoders.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 40114 invoked by alias); 20 Nov 2016 20:47:08 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 40097 invoked by uid 89); 20 Nov 2016 20:47:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy= X-HELO: sasl.smtp.pobox.com Received: from pb-smtp1.pobox.com (HELO sasl.smtp.pobox.com) (64.147.108.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 20 Nov 2016 20:46:57 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 7CD9D50D21; Sun, 20 Nov 2016 15:46:55 -0500 (EST) Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 7425850D20; Sun, 20 Nov 2016 15:46:55 -0500 (EST) Received: from localhost.localdomain (unknown [188.221.161.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id BC5A350D1E; Sun, 20 Nov 2016 15:46:54 -0500 (EST) From: Jonah Graham <jonah@kichwacoders.com> To: gdb-patches@sourceware.org Cc: Jonah Graham <jonah@kichwacoders.com> Subject: [PATCH] bound_registers.py: Add support for Python 3 Date: Sun, 20 Nov 2016 20:45:26 +0000 Message-Id: <20161120204526.7203-1-jonah@kichwacoders.com> X-Pobox-Relay-ID: 78C987DC-AF62-11E6-9CF3-987C12518317-18936988!pb-smtp1.pobox.com X-IsSubscribed: yes |
Commit Message
Jonah Graham
Nov. 20, 2016, 8:45 p.m. UTC
gdb/Changelog: * python/lib/gdb/printer/bound_registers.py: Add support for Python 3. --- gdb/ChangeLog | 5 +++++ gdb/python/lib/gdb/printer/bound_registers.py | 5 +++++ 2 files changed, 10 insertions(+)
Comments
Hi GDB devs, This patch fixes https://sourceware.org/bugzilla/show_bug.cgi?id=19637. This is my first patch to GDB, I hope it falls within the "Small changes can be accepted without a copyright assignment form on file." from the CONTRIBUTING file as the new code in this file was copied from printing.py as recommended in the bug report. In case it doesn't, and to cover future contributions, I have started the copyright assignment process. Thank you, Jonah ~~~ Jonah Graham Kichwa Coders Ltd. www.kichwacoders.com On 20 November 2016 at 20:45, Jonah Graham <jonah@kichwacoders.com> wrote: > gdb/Changelog: > > * python/lib/gdb/printer/bound_registers.py: Add support > for Python 3. > --- > gdb/ChangeLog | 5 +++++ > gdb/python/lib/gdb/printer/bound_registers.py | 5 +++++ > 2 files changed, 10 insertions(+) > > diff --git a/gdb/ChangeLog b/gdb/ChangeLog > index 3797e8b..1923888 100644 > --- a/gdb/ChangeLog > +++ b/gdb/ChangeLog > @@ -1,3 +1,8 @@ > +2016-11-20 Jonah Graham <jonah@kichwacoders.com> > + > + * python/lib/gdb/printer/bound_registers.py: Add support > + for Python 3. > + > 2016-11-19 Joel Brobecker <brobecker@adacore.com> > > * contrib/ari/gdb_ari.sh: Add detection of printf_vma and > diff --git a/gdb/python/lib/gdb/printer/bound_registers.py b/gdb/python/lib/gdb/printer/bound_registers.py > index 9ff94aa..e91cc19 100644 > --- a/gdb/python/lib/gdb/printer/bound_registers.py > +++ b/gdb/python/lib/gdb/printer/bound_registers.py > @@ -16,6 +16,11 @@ > > import gdb.printing > > +if sys.version_info[0] > 2: > + # Python 3 removed basestring and long > + basestring = str > + long = int > + > class MpxBound128Printer: > """Adds size field to a mpx __gdb_builtin_type_bound128 type.""" > > -- > 2.10.1 >
On 11/20/2016 02:45 PM, Jonah Graham wrote: > gdb/Changelog: > > * python/lib/gdb/printer/bound_registers.py: Add support > for Python 3. > --- > gdb/ChangeLog | 5 +++++ > gdb/python/lib/gdb/printer/bound_registers.py | 5 +++++ > 2 files changed, 10 insertions(+) > > diff --git a/gdb/ChangeLog b/gdb/ChangeLog > index 3797e8b..1923888 100644 > --- a/gdb/ChangeLog > +++ b/gdb/ChangeLog > @@ -1,3 +1,8 @@ > +2016-11-20 Jonah Graham <jonah@kichwacoders.com> > + > + * python/lib/gdb/printer/bound_registers.py: Add support > + for Python 3. > + > 2016-11-19 Joel Brobecker <brobecker@adacore.com> > > * contrib/ari/gdb_ari.sh: Add detection of printf_vma and > diff --git a/gdb/python/lib/gdb/printer/bound_registers.py b/gdb/python/lib/gdb/printer/bound_registers.py > index 9ff94aa..e91cc19 100644 > --- a/gdb/python/lib/gdb/printer/bound_registers.py > +++ b/gdb/python/lib/gdb/printer/bound_registers.py > @@ -16,6 +16,11 @@ > > import gdb.printing > > +if sys.version_info[0] > 2: > + # Python 3 removed basestring and long > + basestring = str > + long = int > + > class MpxBound128Printer: > """Adds size field to a mpx __gdb_builtin_type_bound128 type.""" > > Since this should apply to every python module, maybe this should be defined inside gdb/python/lib/gdb/__init__.py? I'm assuming it gets included by module "gdb" and therefore "long" is defined to be "int" for Python versions > 3. Then we can remove that code from gdb/python/lib/gdb/printing.py (and from other places setting this type of version-specific adjustment). Does that make sense?
On 23 November 2016 at 16:59, Luis Machado <lgustavo@codesourcery.com> wrote: > On 11/20/2016 02:45 PM, Jonah Graham wrote: >> >> gdb/Changelog: >> >> * python/lib/gdb/printer/bound_registers.py: Add support >> for Python 3. >> --- >> gdb/ChangeLog | 5 +++++ >> gdb/python/lib/gdb/printer/bound_registers.py | 5 +++++ >> 2 files changed, 10 insertions(+) >> >> diff --git a/gdb/ChangeLog b/gdb/ChangeLog >> index 3797e8b..1923888 100644 >> --- a/gdb/ChangeLog >> +++ b/gdb/ChangeLog >> @@ -1,3 +1,8 @@ >> +2016-11-20 Jonah Graham <jonah@kichwacoders.com> >> + >> + * python/lib/gdb/printer/bound_registers.py: Add support >> + for Python 3. >> + >> 2016-11-19 Joel Brobecker <brobecker@adacore.com> >> >> * contrib/ari/gdb_ari.sh: Add detection of printf_vma and >> diff --git a/gdb/python/lib/gdb/printer/bound_registers.py >> b/gdb/python/lib/gdb/printer/bound_registers.py >> index 9ff94aa..e91cc19 100644 >> --- a/gdb/python/lib/gdb/printer/bound_registers.py >> +++ b/gdb/python/lib/gdb/printer/bound_registers.py >> @@ -16,6 +16,11 @@ >> >> import gdb.printing >> >> +if sys.version_info[0] > 2: >> + # Python 3 removed basestring and long >> + basestring = str >> + long = int >> + >> class MpxBound128Printer: >> """Adds size field to a mpx __gdb_builtin_type_bound128 type.""" >> >> > > Since this should apply to every python module, maybe this should be defined > inside gdb/python/lib/gdb/__init__.py? > > I'm assuming it gets included by module "gdb" and therefore "long" is > defined to be "int" for Python versions > 3. > > Then we can remove that code from gdb/python/lib/gdb/printing.py (and from > other places setting this type of version-specific adjustment). > > Does that make sense? Hi Luis, I am not sure I understand how to do it in __init__.py as the modules that wanted to be both Python 2 and Python 3 compatible would still have to have special code. AFAIK an __init__.py cannot change the value of long in other py files. So python/lib/gdb/printing.py and python/lib/gdb/printer/bound_registers.py would still need special case code locally, even if that special case was an import for a definition of long. Jonah
On 11/23/2016 04:39 PM, Jonah Graham wrote: > On 23 November 2016 at 16:59, Luis Machado <lgustavo@codesourcery.com> wrote: >> On 11/20/2016 02:45 PM, Jonah Graham wrote: >>> >>> gdb/Changelog: >>> >>> * python/lib/gdb/printer/bound_registers.py: Add support >>> for Python 3. >>> --- >>> gdb/ChangeLog | 5 +++++ >>> gdb/python/lib/gdb/printer/bound_registers.py | 5 +++++ >>> 2 files changed, 10 insertions(+) >>> >>> diff --git a/gdb/ChangeLog b/gdb/ChangeLog >>> index 3797e8b..1923888 100644 >>> --- a/gdb/ChangeLog >>> +++ b/gdb/ChangeLog >>> @@ -1,3 +1,8 @@ >>> +2016-11-20 Jonah Graham <jonah@kichwacoders.com> >>> + >>> + * python/lib/gdb/printer/bound_registers.py: Add support >>> + for Python 3. >>> + >>> 2016-11-19 Joel Brobecker <brobecker@adacore.com> >>> >>> * contrib/ari/gdb_ari.sh: Add detection of printf_vma and >>> diff --git a/gdb/python/lib/gdb/printer/bound_registers.py >>> b/gdb/python/lib/gdb/printer/bound_registers.py >>> index 9ff94aa..e91cc19 100644 >>> --- a/gdb/python/lib/gdb/printer/bound_registers.py >>> +++ b/gdb/python/lib/gdb/printer/bound_registers.py >>> @@ -16,6 +16,11 @@ >>> >>> import gdb.printing >>> >>> +if sys.version_info[0] > 2: >>> + # Python 3 removed basestring and long >>> + basestring = str >>> + long = int >>> + >>> class MpxBound128Printer: >>> """Adds size field to a mpx __gdb_builtin_type_bound128 type.""" >>> >>> >> >> Since this should apply to every python module, maybe this should be defined >> inside gdb/python/lib/gdb/__init__.py? >> >> I'm assuming it gets included by module "gdb" and therefore "long" is >> defined to be "int" for Python versions > 3. >> >> Then we can remove that code from gdb/python/lib/gdb/printing.py (and from >> other places setting this type of version-specific adjustment). >> >> Does that make sense? > > Hi Luis, > > I am not sure I understand how to do it in __init__.py as the modules > that wanted to be both Python 2 and Python 3 compatible would still > have to have special code. AFAIK an __init__.py cannot change the > value of long in other py files. So python/lib/gdb/printing.py and > python/lib/gdb/printer/bound_registers.py would still need special > case code locally, even if that special case was an import for a > definition of long. That was the point i wasn't sure about (not a Python expert). I see conditional code executing if the version is > 3, but i wasn't sure if it would take effect globally when a module is included. In that case, i suppose there is not much that can be done other than duplicate the code.
On 23 November 2016 at 23:04, Luis Machado <lgustavo@codesourcery.com> wrote: > On 11/23/2016 04:39 PM, Jonah Graham wrote: >> >> On 23 November 2016 at 16:59, Luis Machado <lgustavo@codesourcery.com> >> wrote: >>> >>> On 11/20/2016 02:45 PM, Jonah Graham wrote: >>>> >>>> >>>> gdb/Changelog: >>>> >>>> * python/lib/gdb/printer/bound_registers.py: Add support >>>> for Python 3. >>>> --- >>>> gdb/ChangeLog | 5 +++++ >>>> gdb/python/lib/gdb/printer/bound_registers.py | 5 +++++ >>>> 2 files changed, 10 insertions(+) >>>> >>>> diff --git a/gdb/ChangeLog b/gdb/ChangeLog >>>> index 3797e8b..1923888 100644 >>>> --- a/gdb/ChangeLog >>>> +++ b/gdb/ChangeLog >>>> @@ -1,3 +1,8 @@ >>>> +2016-11-20 Jonah Graham <jonah@kichwacoders.com> >>>> + >>>> + * python/lib/gdb/printer/bound_registers.py: Add support >>>> + for Python 3. >>>> + >>>> 2016-11-19 Joel Brobecker <brobecker@adacore.com> >>>> >>>> * contrib/ari/gdb_ari.sh: Add detection of printf_vma and >>>> diff --git a/gdb/python/lib/gdb/printer/bound_registers.py >>>> b/gdb/python/lib/gdb/printer/bound_registers.py >>>> index 9ff94aa..e91cc19 100644 >>>> --- a/gdb/python/lib/gdb/printer/bound_registers.py >>>> +++ b/gdb/python/lib/gdb/printer/bound_registers.py >>>> @@ -16,6 +16,11 @@ >>>> >>>> import gdb.printing >>>> >>>> +if sys.version_info[0] > 2: >>>> + # Python 3 removed basestring and long >>>> + basestring = str >>>> + long = int >>>> + >>>> class MpxBound128Printer: >>>> """Adds size field to a mpx __gdb_builtin_type_bound128 type.""" >>>> >>>> >>> >>> Since this should apply to every python module, maybe this should be >>> defined >>> inside gdb/python/lib/gdb/__init__.py? >>> >>> I'm assuming it gets included by module "gdb" and therefore "long" is >>> defined to be "int" for Python versions > 3. >>> >>> Then we can remove that code from gdb/python/lib/gdb/printing.py (and >>> from >>> other places setting this type of version-specific adjustment). >>> >>> Does that make sense? >> >> >> Hi Luis, >> >> I am not sure I understand how to do it in __init__.py as the modules >> that wanted to be both Python 2 and Python 3 compatible would still >> have to have special code. AFAIK an __init__.py cannot change the >> value of long in other py files. So python/lib/gdb/printing.py and >> python/lib/gdb/printer/bound_registers.py would still need special >> case code locally, even if that special case was an import for a >> definition of long. > > > That was the point i wasn't sure about (not a Python expert). I see > conditional code executing if the version is > 3, but i wasn't sure if it > would take effect globally when a module is included. > > In that case, i suppose there is not much that can be done other than > duplicate the code. > There is no way I know of, as a reference http://python3porting.com/differences.html#long recommends doing it (roughly) the way already done in python/lib/gdb/printing.py and copied to python/lib/gdb/printer/bound_registers.py Thanks for the review, Jonah
On 23 November 2016 at 23:09, Jonah Graham <jonah@kichwacoders.com> wrote: > On 23 November 2016 at 23:04, Luis Machado <lgustavo@codesourcery.com> wrote: >> On 11/23/2016 04:39 PM, Jonah Graham wrote: >>> >>> On 23 November 2016 at 16:59, Luis Machado <lgustavo@codesourcery.com> >>> wrote: >>>> >>>> On 11/20/2016 02:45 PM, Jonah Graham wrote: >>>>> >>>>> >>>>> gdb/Changelog: >>>>> >>>>> * python/lib/gdb/printer/bound_registers.py: Add support >>>>> for Python 3. >>>>> --- >>>>> gdb/ChangeLog | 5 +++++ >>>>> gdb/python/lib/gdb/printer/bound_registers.py | 5 +++++ >>>>> 2 files changed, 10 insertions(+) >>>>> >>>>> diff --git a/gdb/ChangeLog b/gdb/ChangeLog >>>>> index 3797e8b..1923888 100644 >>>>> --- a/gdb/ChangeLog >>>>> +++ b/gdb/ChangeLog >>>>> @@ -1,3 +1,8 @@ >>>>> +2016-11-20 Jonah Graham <jonah@kichwacoders.com> >>>>> + >>>>> + * python/lib/gdb/printer/bound_registers.py: Add support >>>>> + for Python 3. >>>>> + >>>>> 2016-11-19 Joel Brobecker <brobecker@adacore.com> >>>>> >>>>> * contrib/ari/gdb_ari.sh: Add detection of printf_vma and >>>>> diff --git a/gdb/python/lib/gdb/printer/bound_registers.py >>>>> b/gdb/python/lib/gdb/printer/bound_registers.py >>>>> index 9ff94aa..e91cc19 100644 >>>>> --- a/gdb/python/lib/gdb/printer/bound_registers.py >>>>> +++ b/gdb/python/lib/gdb/printer/bound_registers.py >>>>> @@ -16,6 +16,11 @@ >>>>> >>>>> import gdb.printing >>>>> >>>>> +if sys.version_info[0] > 2: >>>>> + # Python 3 removed basestring and long >>>>> + basestring = str >>>>> + long = int >>>>> + >>>>> class MpxBound128Printer: >>>>> """Adds size field to a mpx __gdb_builtin_type_bound128 type.""" >>>>> >>>>> >>>> >>>> Since this should apply to every python module, maybe this should be >>>> defined >>>> inside gdb/python/lib/gdb/__init__.py? >>>> >>>> I'm assuming it gets included by module "gdb" and therefore "long" is >>>> defined to be "int" for Python versions > 3. >>>> >>>> Then we can remove that code from gdb/python/lib/gdb/printing.py (and >>>> from >>>> other places setting this type of version-specific adjustment). >>>> >>>> Does that make sense? >>> >>> >>> Hi Luis, >>> >>> I am not sure I understand how to do it in __init__.py as the modules >>> that wanted to be both Python 2 and Python 3 compatible would still >>> have to have special code. AFAIK an __init__.py cannot change the >>> value of long in other py files. So python/lib/gdb/printing.py and >>> python/lib/gdb/printer/bound_registers.py would still need special >>> case code locally, even if that special case was an import for a >>> definition of long. >> >> >> That was the point i wasn't sure about (not a Python expert). I see >> conditional code executing if the version is > 3, but i wasn't sure if it >> would take effect globally when a module is included. >> >> In that case, i suppose there is not much that can be done other than >> duplicate the code. >> > > There is no way I know of, as a reference > http://python3porting.com/differences.html#long recommends doing it > (roughly) the way already done in python/lib/gdb/printing.py and > copied to python/lib/gdb/printer/bound_registers.py > > Thanks for the review, > Jonah Hi, Is there more I am supposed to do to get this patch into GDB? If so, please advise and I would be happy to. Thanks Jonah
On 26 November 2016 at 16:27, Jonah Graham <jonah@kichwacoders.com> wrote: > On 23 November 2016 at 23:09, Jonah Graham <jonah@kichwacoders.com> wrote: >> On 23 November 2016 at 23:04, Luis Machado <lgustavo@codesourcery.com> wrote: >>> On 11/23/2016 04:39 PM, Jonah Graham wrote: >>>> >>>> On 23 November 2016 at 16:59, Luis Machado <lgustavo@codesourcery.com> >>>> wrote: >>>>> >>>>> On 11/20/2016 02:45 PM, Jonah Graham wrote: >>>>>> >>>>>> >>>>>> gdb/Changelog: >>>>>> >>>>>> * python/lib/gdb/printer/bound_registers.py: Add support >>>>>> for Python 3. >>>>>> --- >>>>>> gdb/ChangeLog | 5 +++++ >>>>>> gdb/python/lib/gdb/printer/bound_registers.py | 5 +++++ >>>>>> 2 files changed, 10 insertions(+) >>>>>> >>>>>> diff --git a/gdb/ChangeLog b/gdb/ChangeLog >>>>>> index 3797e8b..1923888 100644 >>>>>> --- a/gdb/ChangeLog >>>>>> +++ b/gdb/ChangeLog >>>>>> @@ -1,3 +1,8 @@ >>>>>> +2016-11-20 Jonah Graham <jonah@kichwacoders.com> >>>>>> + >>>>>> + * python/lib/gdb/printer/bound_registers.py: Add support >>>>>> + for Python 3. >>>>>> + >>>>>> 2016-11-19 Joel Brobecker <brobecker@adacore.com> >>>>>> >>>>>> * contrib/ari/gdb_ari.sh: Add detection of printf_vma and >>>>>> diff --git a/gdb/python/lib/gdb/printer/bound_registers.py >>>>>> b/gdb/python/lib/gdb/printer/bound_registers.py >>>>>> index 9ff94aa..e91cc19 100644 >>>>>> --- a/gdb/python/lib/gdb/printer/bound_registers.py >>>>>> +++ b/gdb/python/lib/gdb/printer/bound_registers.py >>>>>> @@ -16,6 +16,11 @@ >>>>>> >>>>>> import gdb.printing >>>>>> >>>>>> +if sys.version_info[0] > 2: >>>>>> + # Python 3 removed basestring and long >>>>>> + basestring = str >>>>>> + long = int >>>>>> + >>>>>> class MpxBound128Printer: >>>>>> """Adds size field to a mpx __gdb_builtin_type_bound128 type.""" >>>>>> >>>>>> >>>>> >>>>> Since this should apply to every python module, maybe this should be >>>>> defined >>>>> inside gdb/python/lib/gdb/__init__.py? >>>>> >>>>> I'm assuming it gets included by module "gdb" and therefore "long" is >>>>> defined to be "int" for Python versions > 3. >>>>> >>>>> Then we can remove that code from gdb/python/lib/gdb/printing.py (and >>>>> from >>>>> other places setting this type of version-specific adjustment). >>>>> >>>>> Does that make sense? >>>> >>>> >>>> Hi Luis, >>>> >>>> I am not sure I understand how to do it in __init__.py as the modules >>>> that wanted to be both Python 2 and Python 3 compatible would still >>>> have to have special code. AFAIK an __init__.py cannot change the >>>> value of long in other py files. So python/lib/gdb/printing.py and >>>> python/lib/gdb/printer/bound_registers.py would still need special >>>> case code locally, even if that special case was an import for a >>>> definition of long. >>> >>> >>> That was the point i wasn't sure about (not a Python expert). I see >>> conditional code executing if the version is > 3, but i wasn't sure if it >>> would take effect globally when a module is included. >>> >>> In that case, i suppose there is not much that can be done other than >>> duplicate the code. >>> >> >> There is no way I know of, as a reference >> http://python3porting.com/differences.html#long recommends doing it >> (roughly) the way already done in python/lib/gdb/printing.py and >> copied to python/lib/gdb/printer/bound_registers.py >> >> Thanks for the review, >> Jonah > > Hi, > > Is there more I am supposed to do to get this patch into GDB? If so, > please advise and I would be happy to. > > Thanks > Jonah This patch is missing the import of sys. Update on the way.
On 11/26/2016 10:27 AM, Jonah Graham wrote: > On 23 November 2016 at 23:09, Jonah Graham <jonah@kichwacoders.com> wrote: >> On 23 November 2016 at 23:04, Luis Machado <lgustavo@codesourcery.com> wrote: >>> On 11/23/2016 04:39 PM, Jonah Graham wrote: >>>> >>>> On 23 November 2016 at 16:59, Luis Machado <lgustavo@codesourcery.com> >>>> wrote: >>>>> >>>>> On 11/20/2016 02:45 PM, Jonah Graham wrote: >>>>>> >>>>>> >>>>>> gdb/Changelog: >>>>>> >>>>>> * python/lib/gdb/printer/bound_registers.py: Add support >>>>>> for Python 3. >>>>>> --- >>>>>> gdb/ChangeLog | 5 +++++ >>>>>> gdb/python/lib/gdb/printer/bound_registers.py | 5 +++++ >>>>>> 2 files changed, 10 insertions(+) >>>>>> >>>>>> diff --git a/gdb/ChangeLog b/gdb/ChangeLog >>>>>> index 3797e8b..1923888 100644 >>>>>> --- a/gdb/ChangeLog >>>>>> +++ b/gdb/ChangeLog >>>>>> @@ -1,3 +1,8 @@ >>>>>> +2016-11-20 Jonah Graham <jonah@kichwacoders.com> >>>>>> + >>>>>> + * python/lib/gdb/printer/bound_registers.py: Add support >>>>>> + for Python 3. >>>>>> + >>>>>> 2016-11-19 Joel Brobecker <brobecker@adacore.com> >>>>>> >>>>>> * contrib/ari/gdb_ari.sh: Add detection of printf_vma and >>>>>> diff --git a/gdb/python/lib/gdb/printer/bound_registers.py >>>>>> b/gdb/python/lib/gdb/printer/bound_registers.py >>>>>> index 9ff94aa..e91cc19 100644 >>>>>> --- a/gdb/python/lib/gdb/printer/bound_registers.py >>>>>> +++ b/gdb/python/lib/gdb/printer/bound_registers.py >>>>>> @@ -16,6 +16,11 @@ >>>>>> >>>>>> import gdb.printing >>>>>> >>>>>> +if sys.version_info[0] > 2: >>>>>> + # Python 3 removed basestring and long >>>>>> + basestring = str >>>>>> + long = int >>>>>> + >>>>>> class MpxBound128Printer: >>>>>> """Adds size field to a mpx __gdb_builtin_type_bound128 type.""" >>>>>> >>>>>> >>>>> >>>>> Since this should apply to every python module, maybe this should be >>>>> defined >>>>> inside gdb/python/lib/gdb/__init__.py? >>>>> >>>>> I'm assuming it gets included by module "gdb" and therefore "long" is >>>>> defined to be "int" for Python versions > 3. >>>>> >>>>> Then we can remove that code from gdb/python/lib/gdb/printing.py (and >>>>> from >>>>> other places setting this type of version-specific adjustment). >>>>> >>>>> Does that make sense? >>>> >>>> >>>> Hi Luis, >>>> >>>> I am not sure I understand how to do it in __init__.py as the modules >>>> that wanted to be both Python 2 and Python 3 compatible would still >>>> have to have special code. AFAIK an __init__.py cannot change the >>>> value of long in other py files. So python/lib/gdb/printing.py and >>>> python/lib/gdb/printer/bound_registers.py would still need special >>>> case code locally, even if that special case was an import for a >>>> definition of long. >>> >>> >>> That was the point i wasn't sure about (not a Python expert). I see >>> conditional code executing if the version is > 3, but i wasn't sure if it >>> would take effect globally when a module is included. >>> >>> In that case, i suppose there is not much that can be done other than >>> duplicate the code. >>> >> >> There is no way I know of, as a reference >> http://python3porting.com/differences.html#long recommends doing it >> (roughly) the way already done in python/lib/gdb/printing.py and >> copied to python/lib/gdb/printer/bound_registers.py >> >> Thanks for the review, >> Jonah > > Hi, > > Is there more I am supposed to do to get this patch into GDB? If so, > please advise and I would be happy to. One of the maintainers needs to OK it, which shouldn't that that long. Given the size of the patch, i don't there's anything else that should be done code-wise.
On 26 November 2016 at 21:26, Luis Machado <lgustavo@codesourcery.com> wrote: > On 11/26/2016 10:27 AM, Jonah Graham wrote: >> >> On 23 November 2016 at 23:09, Jonah Graham <jonah@kichwacoders.com> wrote: >>> >>> On 23 November 2016 at 23:04, Luis Machado <lgustavo@codesourcery.com> >>> wrote: >>>> >>>> On 11/23/2016 04:39 PM, Jonah Graham wrote: >>>>> >>>>> >>>>> On 23 November 2016 at 16:59, Luis Machado <lgustavo@codesourcery.com> >>>>> wrote: >>>>>> >>>>>> >>>>>> On 11/20/2016 02:45 PM, Jonah Graham wrote: >>>>>>> >>>>>>> >>>>>>> >>>>>>> gdb/Changelog: >>>>>>> >>>>>>> * python/lib/gdb/printer/bound_registers.py: Add support >>>>>>> for Python 3. >>>>>>> --- >>>>>>> gdb/ChangeLog | 5 +++++ >>>>>>> gdb/python/lib/gdb/printer/bound_registers.py | 5 +++++ >>>>>>> 2 files changed, 10 insertions(+) >>>>>>> >>>>>>> diff --git a/gdb/ChangeLog b/gdb/ChangeLog >>>>>>> index 3797e8b..1923888 100644 >>>>>>> --- a/gdb/ChangeLog >>>>>>> +++ b/gdb/ChangeLog >>>>>>> @@ -1,3 +1,8 @@ >>>>>>> +2016-11-20 Jonah Graham <jonah@kichwacoders.com> >>>>>>> + >>>>>>> + * python/lib/gdb/printer/bound_registers.py: Add support >>>>>>> + for Python 3. >>>>>>> + >>>>>>> 2016-11-19 Joel Brobecker <brobecker@adacore.com> >>>>>>> >>>>>>> * contrib/ari/gdb_ari.sh: Add detection of printf_vma and >>>>>>> diff --git a/gdb/python/lib/gdb/printer/bound_registers.py >>>>>>> b/gdb/python/lib/gdb/printer/bound_registers.py >>>>>>> index 9ff94aa..e91cc19 100644 >>>>>>> --- a/gdb/python/lib/gdb/printer/bound_registers.py >>>>>>> +++ b/gdb/python/lib/gdb/printer/bound_registers.py >>>>>>> @@ -16,6 +16,11 @@ >>>>>>> >>>>>>> import gdb.printing >>>>>>> >>>>>>> +if sys.version_info[0] > 2: >>>>>>> + # Python 3 removed basestring and long >>>>>>> + basestring = str >>>>>>> + long = int >>>>>>> + >>>>>>> class MpxBound128Printer: >>>>>>> """Adds size field to a mpx __gdb_builtin_type_bound128 type.""" >>>>>>> >>>>>>> >>>>>> >>>>>> Since this should apply to every python module, maybe this should be >>>>>> defined >>>>>> inside gdb/python/lib/gdb/__init__.py? >>>>>> >>>>>> I'm assuming it gets included by module "gdb" and therefore "long" is >>>>>> defined to be "int" for Python versions > 3. >>>>>> >>>>>> Then we can remove that code from gdb/python/lib/gdb/printing.py (and >>>>>> from >>>>>> other places setting this type of version-specific adjustment). >>>>>> >>>>>> Does that make sense? >>>>> >>>>> >>>>> >>>>> Hi Luis, >>>>> >>>>> I am not sure I understand how to do it in __init__.py as the modules >>>>> that wanted to be both Python 2 and Python 3 compatible would still >>>>> have to have special code. AFAIK an __init__.py cannot change the >>>>> value of long in other py files. So python/lib/gdb/printing.py and >>>>> python/lib/gdb/printer/bound_registers.py would still need special >>>>> case code locally, even if that special case was an import for a >>>>> definition of long. >>>> >>>> >>>> >>>> That was the point i wasn't sure about (not a Python expert). I see >>>> conditional code executing if the version is > 3, but i wasn't sure if >>>> it >>>> would take effect globally when a module is included. >>>> >>>> In that case, i suppose there is not much that can be done other than >>>> duplicate the code. >>>> >>> >>> There is no way I know of, as a reference >>> http://python3porting.com/differences.html#long recommends doing it >>> (roughly) the way already done in python/lib/gdb/printing.py and >>> copied to python/lib/gdb/printer/bound_registers.py >>> >>> Thanks for the review, >>> Jonah >> >> >> Hi, >> >> Is there more I am supposed to do to get this patch into GDB? If so, >> please advise and I would be happy to. > > > One of the maintainers needs to OK it, which shouldn't that that long. Given > the size of the patch, i don't there's anything else that should be done > code-wise. > Ping on this patch. Please let me know if there is anything else I can do to get it in.
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3797e8b..1923888 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2016-11-20 Jonah Graham <jonah@kichwacoders.com> + + * python/lib/gdb/printer/bound_registers.py: Add support + for Python 3. + 2016-11-19 Joel Brobecker <brobecker@adacore.com> * contrib/ari/gdb_ari.sh: Add detection of printf_vma and diff --git a/gdb/python/lib/gdb/printer/bound_registers.py b/gdb/python/lib/gdb/printer/bound_registers.py index 9ff94aa..e91cc19 100644 --- a/gdb/python/lib/gdb/printer/bound_registers.py +++ b/gdb/python/lib/gdb/printer/bound_registers.py @@ -16,6 +16,11 @@ import gdb.printing +if sys.version_info[0] > 2: + # Python 3 removed basestring and long + basestring = str + long = int + class MpxBound128Printer: """Adds size field to a mpx __gdb_builtin_type_bound128 type."""