bound_registers.py: Add support for Python 3

Message ID cfe9a625-551b-beba-5a77-96d21a84c010@redhat.com
State New, archived
Headers

Commit Message

Pedro Alves March 17, 2017, 3 p.m. UTC
  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(+)
  

Comments

Yao Qi March 22, 2017, 9:16 a.m. UTC | #1
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.
  
Jonah Graham March 22, 2017, 9:37 a.m. UTC | #2
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 (齐尧)
  
Yao Qi March 22, 2017, 11:26 a.m. UTC | #3
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.
  

Patch

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."""