Fix 'info type-printers' Python error - PR 17136

Message ID 20150626134907.GA23742@host1.jankratochvil.net
State New, archived
Headers

Commit Message

Jan Kratochvil June 26, 2015, 1:49 p.m. UTC
  Hi,

by Clem Dickey and Jonathan Wakely:

https://bugzilla.redhat.com/show_bug.cgi?id=1085576
https://sourceware.org/bugzilla/show_bug.cgi?id=17136

if you debug any program then register the type printer with the current
objfile, running 'info type-printers' results in a python exception:

(gdb) info type-printers
Python Exception <type 'exceptions.AttributeError'> 'gdb.Objfile' object has no attribute 'name': 
Error occurred in Python command: 'gdb.Objfile' object has no attribute 'name'
->
(gdb) info type-printers 
Type printers for /lib64/libstdc++.so.6:
  basic_string_view<C>
  deque<T>
...
  unordered_set<T>
  vector<T>

The exception doesn't happen if the type printer is registered globally, by
passing None instead of gdb.current_objfile().

Doug: https://sourceware.org/bugzilla/show_bug.cgi?id=17136#c6
The patch can be checked in IMO.
Given that I don't have the time to write a testcase myself
I'm not going to force someone else to.
Another reviewer may require one though.


Jan
2015-06-26  Clem Dickey <clemd@acm.org>

	Fix 'info type-printers' Python error.
	* python/lib/gdb/command/type_printers.py (InfoTypePrinter): Fix typo.
  

Comments

Jan Kratochvil June 27, 2015, 7:57 p.m. UTC | #1
On Fri, 26 Jun 2015 15:49:07 +0200, Jan Kratochvil wrote:
> -                print ("%sType printers for %s:" % (sep, objfile.name))
> +                print ("%sType printers for %s:" % (sep, objfile.filename))

I have looked now into history when the regression by "name"->"filename"
rename in objfile happened but I haven't found anything.

FSF GDB got already checked in support for "filename" in 2012 by:
	https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=18a9fc1261b8a654fe6db7eea7e60b0c59296d96

A the previous archer.git commit also had "filename" in 2009:
	https://sourceware.org/git/?p=archer.git;a=commitdiff;h=89c73adef9f9fac7e1efeb6961a867f46e54e24b


Jan
  
Doug Evans Aug. 6, 2015, 4:31 p.m. UTC | #2
On Fri, Jun 26, 2015 at 6:49 AM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
> Hi,
>
> by Clem Dickey and Jonathan Wakely:
>
> https://bugzilla.redhat.com/show_bug.cgi?id=1085576
> https://sourceware.org/bugzilla/show_bug.cgi?id=17136
>
> if you debug any program then register the type printer with the current
> objfile, running 'info type-printers' results in a python exception:
>
> (gdb) info type-printers
> Python Exception <type 'exceptions.AttributeError'> 'gdb.Objfile' object has no attribute 'name':
> Error occurred in Python command: 'gdb.Objfile' object has no attribute 'name'
> ->
> (gdb) info type-printers
> Type printers for /lib64/libstdc++.so.6:
>   basic_string_view<C>
>   deque<T>
> ...
>   unordered_set<T>
>   vector<T>
>
> The exception doesn't happen if the type printer is registered globally, by
> passing None instead of gdb.current_objfile().
>
> Doug: https://sourceware.org/bugzilla/show_bug.cgi?id=17136#c6
> The patch can be checked in IMO.
> Given that I don't have the time to write a testcase myself
> I'm not going to force someone else to.
> Another reviewer may require one though.
>
>
> Jan
>
> 2015-06-26  Clem Dickey <clemd@acm.org>
>
>         Fix 'info type-printers' Python error.
>         * python/lib/gdb/command/type_printers.py (InfoTypePrinter): Fix typo.
>
> diff --git a/gdb/python/lib/gdb/command/type_printers.py b/gdb/python/lib/gdb/command/type_printers.py
> index 0ef7686..1203989 100644
> --- a/gdb/python/lib/gdb/command/type_printers.py
> +++ b/gdb/python/lib/gdb/command/type_printers.py
> @@ -47,7 +47,7 @@ class InfoTypePrinter(gdb.Command):
>          sep = ''
>          for objfile in gdb.objfiles():
>              if objfile.type_printers:
> -                print ("%sType printers for %s:" % (sep, objfile.name))
> +                print ("%sType printers for %s:" % (sep, objfile.filename))
>                  self.list_type_printers(objfile.type_printers)
>                  sep = '\n'
>          if gdb.current_progspace().type_printers:
>

Hi.

fyi, I have pushed this to trunk and the 7.10 branch.
  

Patch

diff --git a/gdb/python/lib/gdb/command/type_printers.py b/gdb/python/lib/gdb/command/type_printers.py
index 0ef7686..1203989 100644
--- a/gdb/python/lib/gdb/command/type_printers.py
+++ b/gdb/python/lib/gdb/command/type_printers.py
@@ -47,7 +47,7 @@  class InfoTypePrinter(gdb.Command):
         sep = ''
         for objfile in gdb.objfiles():
             if objfile.type_printers:
-                print ("%sType printers for %s:" % (sep, objfile.name))
+                print ("%sType printers for %s:" % (sep, objfile.filename))
                 self.list_type_printers(objfile.type_printers)
                 sep = '\n'
         if gdb.current_progspace().type_printers: