* [PATCH] bound_registers.py: Add support for Python 3 @ 2016-11-20 20:47 Jonah Graham 2016-11-20 20:51 ` Jonah Graham 2016-11-23 16:59 ` Luis Machado 0 siblings, 2 replies; 15+ messages in thread From: Jonah Graham @ 2016-11-20 20:47 UTC (permalink / raw) To: gdb-patches; +Cc: Jonah Graham 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 ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] bound_registers.py: Add support for Python 3 2016-11-20 20:47 [PATCH] bound_registers.py: Add support for Python 3 Jonah Graham @ 2016-11-20 20:51 ` Jonah Graham 2016-11-23 16:59 ` Luis Machado 1 sibling, 0 replies; 15+ messages in thread From: Jonah Graham @ 2016-11-20 20:51 UTC (permalink / raw) To: gdb-patches 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 > ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] bound_registers.py: Add support for Python 3 2016-11-20 20:47 [PATCH] bound_registers.py: Add support for Python 3 Jonah Graham 2016-11-20 20:51 ` Jonah Graham @ 2016-11-23 16:59 ` Luis Machado 2016-11-23 22:40 ` Jonah Graham 1 sibling, 1 reply; 15+ messages in thread From: Luis Machado @ 2016-11-23 16:59 UTC (permalink / raw) To: Jonah Graham, gdb-patches 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? ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] bound_registers.py: Add support for Python 3 2016-11-23 16:59 ` Luis Machado @ 2016-11-23 22:40 ` Jonah Graham 2016-11-23 23:04 ` Luis Machado 0 siblings, 1 reply; 15+ messages in thread From: Jonah Graham @ 2016-11-23 22:40 UTC (permalink / raw) To: Luis Machado; +Cc: gdb-patches 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 ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] bound_registers.py: Add support for Python 3 2016-11-23 22:40 ` Jonah Graham @ 2016-11-23 23:04 ` Luis Machado 2016-11-23 23:10 ` Jonah Graham 0 siblings, 1 reply; 15+ messages in thread From: Luis Machado @ 2016-11-23 23:04 UTC (permalink / raw) To: Jonah Graham; +Cc: gdb-patches 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. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] bound_registers.py: Add support for Python 3 2016-11-23 23:04 ` Luis Machado @ 2016-11-23 23:10 ` Jonah Graham 2016-11-26 16:28 ` Jonah Graham 0 siblings, 1 reply; 15+ messages in thread From: Jonah Graham @ 2016-11-23 23:10 UTC (permalink / raw) To: Luis Machado; +Cc: gdb-patches 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 ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] bound_registers.py: Add support for Python 3 2016-11-23 23:10 ` Jonah Graham @ 2016-11-26 16:28 ` Jonah Graham 2016-11-26 18:55 ` Jonah Graham 2016-11-26 21:27 ` Luis Machado 0 siblings, 2 replies; 15+ messages in thread From: Jonah Graham @ 2016-11-26 16:28 UTC (permalink / raw) To: Luis Machado; +Cc: gdb-patches 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 ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] bound_registers.py: Add support for Python 3 2016-11-26 16:28 ` Jonah Graham @ 2016-11-26 18:55 ` Jonah Graham 2016-11-26 18:55 ` Jonah Graham 2016-11-26 21:27 ` Luis Machado 1 sibling, 1 reply; 15+ messages in thread From: Jonah Graham @ 2016-11-26 18:55 UTC (permalink / raw) To: Luis Machado; +Cc: gdb-patches 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. ^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH] bound_registers.py: Add support for Python 3 2016-11-26 18:55 ` Jonah Graham @ 2016-11-26 18:55 ` Jonah Graham 0 siblings, 0 replies; 15+ messages in thread From: Jonah Graham @ 2016-11-26 18:55 UTC (permalink / raw) To: gdb-patches; +Cc: Jonah Graham 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 | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 745ab7b..7bf79e1 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-26 Simon Marchi <simon.marchi@polymtl.ca> * ui-out.h (struct ui_out_impl): Remove comment. diff --git a/gdb/python/lib/gdb/printer/bound_registers.py b/gdb/python/lib/gdb/printer/bound_registers.py index 9ff94aa..50509fb 100644 --- a/gdb/python/lib/gdb/printer/bound_registers.py +++ b/gdb/python/lib/gdb/printer/bound_registers.py @@ -14,8 +14,15 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +import sys + 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.2 ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] bound_registers.py: Add support for Python 3 2016-11-26 16:28 ` Jonah Graham 2016-11-26 18:55 ` Jonah Graham @ 2016-11-26 21:27 ` Luis Machado 2017-03-08 8:35 ` Jonah Graham 1 sibling, 1 reply; 15+ messages in thread From: Luis Machado @ 2016-11-26 21:27 UTC (permalink / raw) To: Jonah Graham; +Cc: gdb-patches 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. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] bound_registers.py: Add support for Python 3 2016-11-26 21:27 ` Luis Machado @ 2017-03-08 8:35 ` Jonah Graham 2017-03-17 15:00 ` Pedro Alves 0 siblings, 1 reply; 15+ messages in thread From: Jonah Graham @ 2017-03-08 8:35 UTC (permalink / raw) Cc: gdb-patches 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. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] bound_registers.py: Add support for Python 3 2017-03-08 8:35 ` Jonah Graham @ 2017-03-17 15:00 ` Pedro Alves 2017-03-22 9:16 ` Yao Qi 0 siblings, 1 reply; 15+ messages in thread From: Pedro Alves @ 2017-03-17 15:00 UTC (permalink / raw) To: Jonah Graham; +Cc: gdb-patches On 03/08/2017 08:34 AM, Jonah Graham wrote: > On 26 November 2016 at 21:26, Luis Machado <lgustavo@codesourcery.com> wrote: >> On 11/26/2016 10:27 AM, Jonah Graham wrote: >>> 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. > Thanks for the patch. I've pushed it in, as below. (I added the reference to printing.py to the commit log, and the PR number, so that the commit is logged in bugzilla automatically.) From 7503099f3e29739d34cb1224d54fba96404e6e61 Mon Sep 17 00:00:00 2001 From: Jonah Graham <jonah@kichwacoders.com> Date: Fri, 17 Mar 2017 14:57:44 +0000 Subject: [PATCH] Fix PR gdb/19637: bound_registers.py: Add support for Python 3 Fix this the same way gdb/python/lib/gdb/printing.py handles it. gdb/Changelog: 2017-03-17 Jonah Graham <jonah@kichwacoders.com> PR gdb/19637 * python/lib/gdb/printer/bound_registers.py: Add support for Python 3. --- gdb/ChangeLog | 6 ++++++ gdb/python/lib/gdb/printer/bound_registers.py | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d0d0f72..6d81cf5 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2017-03-17 Jonah Graham <jonah@kichwacoders.com> + + PR gdb/19637 + * python/lib/gdb/printer/bound_registers.py: Add support for + Python 3. + 2017-03-16 Andreas Arnez <arnez@linux.vnet.ibm.com> * dwarf2loc.c (indirect_synthetic_pointer): Get data type of diff --git a/gdb/python/lib/gdb/printer/bound_registers.py b/gdb/python/lib/gdb/printer/bound_registers.py index b315690..104ea7f 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.5.5 ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] bound_registers.py: Add support for Python 3 2017-03-17 15:00 ` Pedro Alves @ 2017-03-22 9:16 ` Yao Qi 2017-03-22 9:38 ` Jonah Graham 0 siblings, 1 reply; 15+ messages in thread From: Yao Qi @ 2017-03-22 9:16 UTC (permalink / raw) To: Pedro Alves; +Cc: Jonah Graham, gdb-patches On Fri, Mar 17, 2017 at 3:00 PM, Pedro Alves <palves@redhat.com> wrote: > diff --git a/gdb/python/lib/gdb/printer/bound_registers.py b/gdb/python/lib/gdb/printer/bound_registers.py > index b315690..104ea7f 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 > + This change causes some fails in gdb.python/py-pp-maint.exp, disable pretty-printer^M 6 printers disabled^M 0 of 6 printers enabled^M (gdb) FAIL: gdb.python/py-pp-maint.exp: disable pretty-printer looks the number of pretty-printer is changed. Without this patch, there are 7 pretty-printers, info pretty-printer^M global pretty-printers:^M builtin^M mpx_bound128^M lookup_function_lookup_test^M pp-test^M enum flag_enum^M s^M ss^M struct s^M struct ss^M (gdb) PASS: gdb.python/py-pp-maint.exp: info pretty-printer but with this patch applied, it becomes 6, mpx_bound128 is disappeared. info pretty-printer^M global pretty-printers:^M builtin^M lookup_function_lookup_test^M pp-test^M enum flag_enum^M s^M ss^M struct s^M struct ss^M (gdb) PASS: gdb.python/py-pp-maint.exp: info pretty-printer I'll look into this problem further. -- Yao (齐尧) ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] bound_registers.py: Add support for Python 3 2017-03-22 9:16 ` Yao Qi @ 2017-03-22 9:38 ` Jonah Graham 2017-03-22 11:26 ` Yao Qi 0 siblings, 1 reply; 15+ messages in thread From: Jonah Graham @ 2017-03-22 9:38 UTC (permalink / raw) To: Yao Qi; +Cc: Pedro Alves, gdb-patches Hi, It looks like the wrong version of my patch was merged. Sorry if I didn't understand the proper process for providing an updated version of the patch. The initial version was missing the import sys, this is the correct one: https://sourceware.org/ml/gdb-patches/2016-11/msg00900.html Jonah ~~~ Jonah Graham Kichwa Coders Ltd. www.kichwacoders.com On 22 March 2017 at 09:16, Yao Qi <qiyaoltc@gmail.com> wrote: > On Fri, Mar 17, 2017 at 3:00 PM, Pedro Alves <palves@redhat.com> wrote: >> diff --git a/gdb/python/lib/gdb/printer/bound_registers.py b/gdb/python/lib/gdb/printer/bound_registers.py >> index b315690..104ea7f 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 >> + > > This change causes some fails in gdb.python/py-pp-maint.exp, > > disable pretty-printer^M > 6 printers disabled^M > 0 of 6 printers enabled^M > (gdb) FAIL: gdb.python/py-pp-maint.exp: disable pretty-printer > > looks the number of pretty-printer is changed. Without this patch, > there are 7 pretty-printers, > > info pretty-printer^M > global pretty-printers:^M > builtin^M > mpx_bound128^M > lookup_function_lookup_test^M > pp-test^M > enum flag_enum^M > s^M > ss^M > struct s^M > struct ss^M > (gdb) PASS: gdb.python/py-pp-maint.exp: info pretty-printer > > but with this patch applied, it becomes 6, mpx_bound128 is > disappeared. > > info pretty-printer^M > global pretty-printers:^M > builtin^M > lookup_function_lookup_test^M > pp-test^M > enum flag_enum^M > s^M > ss^M > struct s^M > struct ss^M > (gdb) PASS: gdb.python/py-pp-maint.exp: info pretty-printer > > I'll look into this problem further. > > -- > Yao (齐尧) ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] bound_registers.py: Add support for Python 3 2017-03-22 9:38 ` Jonah Graham @ 2017-03-22 11:26 ` Yao Qi 0 siblings, 0 replies; 15+ messages in thread From: Yao Qi @ 2017-03-22 11:26 UTC (permalink / raw) To: Jonah Graham; +Cc: Pedro Alves, gdb-patches On Wed, Mar 22, 2017 at 9:37 AM, Jonah Graham <jonah@kichwacoders.com> wrote: > Hi, > > It looks like the wrong version of my patch was merged. Sorry if I > didn't understand the proper process for providing an updated version > of the patch. > > The initial version was missing the import sys, this is the correct > one: https://sourceware.org/ml/gdb-patches/2016-11/msg00900.html I pushed the missing bit in. -- Yao (齐尧) ^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2017-03-22 11:26 UTC | newest] Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2016-11-20 20:47 [PATCH] bound_registers.py: Add support for Python 3 Jonah Graham 2016-11-20 20:51 ` Jonah Graham 2016-11-23 16:59 ` Luis Machado 2016-11-23 22:40 ` Jonah Graham 2016-11-23 23:04 ` Luis Machado 2016-11-23 23:10 ` Jonah Graham 2016-11-26 16:28 ` Jonah Graham 2016-11-26 18:55 ` Jonah Graham 2016-11-26 18:55 ` Jonah Graham 2016-11-26 21:27 ` Luis Machado 2017-03-08 8:35 ` Jonah Graham 2017-03-17 15:00 ` Pedro Alves 2017-03-22 9:16 ` Yao Qi 2017-03-22 9:38 ` Jonah Graham 2017-03-22 11:26 ` Yao Qi
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox