This is the mail archive of the archer@sourceware.org mailing list for the Archer 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]

[python][patch] Info about base class in gdb.Type


A small patch to add a bool indicating if a class member as returned by
the fields method on a gdb.Type represents a base class. 

PS. asked about this (and other patches I'll hopefully be sending) on
IRC and was told to sign the copyright waiver thing for the FSF before
submitting. Not sure if I need to give any info on that but the FSF say
they have it now.

2009-05-28  Richard Ward  <richard.j.ward1@googlemail.com>
    
*   gdb/python/python-type.c
            convert_field adds a new bool entry "base_class" indicating
            whether the field represents a base class
*   gdb/doc/gdb.texinfo:
           updated to refelect the above.

>From c9357da0d5970bd54af4a707c6253b9b65d51bb5 Mon Sep 17 00:00:00 2001
From: Richard Ward <richard@elemental-lin.(none)>
Date: Fri, 29 May 2009 13:00:12 +0100
Subject: [PATCH] 2009-05-28  Richard Ward  <richard.j.ward1@googlemail.com>

*	gdb/python/python-type.c
		convert_field adds a new bool entry "base_class" indicating
		whether the field represents a base class
*	gdb/doc/gdb.texinfo: updated to refelect this.
---
 gdb/doc/gdb.texinfo      |    6 ++++++
 gdb/python/python-type.c |    5 +++++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 958a74f..82944c4 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -18516,6 +18516,12 @@ This is @code{True} if the field is artificial, usually meaning that
 it was provided by the compiler and not the user.  This attribute is
 always provided, and is @code{False} if the field is not artificial.
 
+@item base_class
+This is @code{True} if the field represents a base class of a C@t{++}
+structure.  This attribute is always provided, and is @code{False}
+if the field is not a base class of the type on which @code{fields} was
+called, or if that type was not a C@t{++} class.
+
 @item bitsize
 If the field is packed, or is a bitfield, then this will have a
 non-zero value, which is the size of the field in bits.  Otherwise,
diff --git a/gdb/python/python-type.c b/gdb/python/python-type.c
index 53a7eab..d9d6120 100644
--- a/gdb/python/python-type.c
+++ b/gdb/python/python-type.c
@@ -168,6 +168,11 @@ convert_field (struct type *type, int field)
   if (PyObject_SetAttrString (result, "artificial", arg) < 0)
     goto failarg;
 
+  arg = field < TYPE_N_BASECLASSES (type) ? Py_True : Py_False;
+  Py_INCREF (arg);
+  if (PyObject_SetAttrString (result, "base_class", arg) < 0)
+    goto failarg;
+
   arg = PyLong_FromLong (TYPE_FIELD_BITSIZE (type, field));
   if (!arg)
     goto fail;
-- 
1.6.0.4


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