This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix python compatibility with old versions of GDB


> Hi Orgad,
>
> Thanks for submitting this, and sorry for the wait.  Could you provide a
> little bit of context to help others understand what's wrong?  Can you give
> some details on how to reproduce the problem?  Make sure to add it to the
> commit message.
>
> Also, please include a ChangeLog entry in your commit message, more details
> here:
>
> https://sourceware.org/gdb/wiki/ContributionChecklist#Properly_Formatted_GNU_ChangeLog
>
> If anything is not clear, please ask.
>
> Thanks,
>
> Simon

If data-directory is shared between various version of GDB, it should
work for all of them.

There are several hasattr conditions that enable this kind of
compatibility.

RegexpCollectionPrettyPrinter was missing a check that enables it to
work with GDB prior to 7.9, when Type.name was introduced.

gdb/ChangeLog:

   * printing.py: Fix compatibility with old versions of GDB
---
gdb/ChangeLog                  | 4 ++++
gdb/python/lib/gdb/printing.py | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c48fb92e9e..0a0005090b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2017-06-11  Orgad Shaneh  <orgads@gmail.com>
+
+       * printing.py: Fix compatibility with old versions of GDB
+
2017-06-10  Simon Marchi  <simon.marchi@polymtl.ca>

       * gdbarch.sh (displaced_step_free_closure): Remove.
diff --git a/gdb/python/lib/gdb/printing.py b/gdb/python/lib/gdb/printing.py
index 181701c719..106da4ac8b 100644
--- a/gdb/python/lib/gdb/printing.py
+++ b/gdb/python/lib/gdb/printing.py
@@ -205,7 +205,7 @@ class RegexpCollectionPrettyPrinter(PrettyPrinter):

        # Get the type name.
        typename = gdb.types.get_basic_type(val.type).tag
-        if not typename:
+        if not typename and hasattr(val.type, "name"):
            typename = val.type.name
        if not typename:
            return None
--
2.11.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]