From c0d4881122d0491f5dea9fa2c017ab5d2ae5fe89 Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Mon, 23 Dec 2013 07:18:51 +0400 Subject: [python] Add gdb.Type.name attribute. Consider the following declarations: typedef long our_time_t; our_time_t current_time = 1384395743; The purpose of this patch is to allow the use of a pretty-printer for variables of type our_time_t. Normally, pretty-printing sniffers use the tag name in order to determine which, if any, pretty-printer should be used. But in the case above, the tag name is not set, since it does not apply to integral types. This patch extends the gdb.Type list of attributes to also include the name of the type, thus allowing the sniffer to match against that name. With that change, I was able to write a pretty-printer which displays our variable as follow: (gdb) print current_time $1 = Thu Nov 14 02:22:23 2013 (1384395743) gdb/ChangeLog: * python/py-type.c (typy_get_name): New function. (type_object_getset): Add entry for attribute "name". * NEWS: Add entry mentioning this new attribute. gdb/doc/ChangeLog: * gdb.texinfo (Types In Python): Document new attribute Types.name. gdb/testsuite: * gdb.python/py-pp-integral.c: New file. * gdb.python/py-pp-integral.py: New file. * gdb.python/py-pp-integral.exp: New file. Tested on x86_64-linux. --- gdb/doc/ChangeLog | 4 ++++ gdb/doc/gdb.texinfo | 5 +++++ 2 files changed, 9 insertions(+) (limited to 'gdb/doc') diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index a7e1c2f..afcfbd9 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,7 @@ +2014-01-07 Joel Brobecker + + * gdb.texinfo (Types In Python): Document new attribute Types.name. + 2013-12-30 Joel Brobecker * gdb.texinfo (Types In Python): Clarify the documentation diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 010bb6b..74ddcf5 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -24311,6 +24311,11 @@ The type code for this type. The type code will be one of the @code{TYPE_CODE_} constants defined below. @end defvar +@defvar Type.name +The name of this type. If this type has no name, then @code{None} +is returned. +@end defvar + @defvar Type.sizeof The size of this type, in target @code{char} units. Usually, a target's @code{char} type will be an 8-bit byte. However, on some -- cgit v1.1