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]

[patch 2/2] gdb-gdb.py: Print also the linked type structures


Hi,

as doing printing all the type-related linked structures by hand all the time
I have made it automatic now.

But it is true it prints maybe too much information this way.  But IMO one
needs to see it all anyway when examining such GDB type.

Maybe the NULL fields do not have to be printed by default?  But this is also
more an item for some general printing framework.

Also the chained structures should be indented but I have not found an easy
way to do it it currently.  This is also more an item for some general
printing framework.


Regards,
Jan


before:

$1 = 
{pointer_type = 0x0,
 reference_type = 0x0,
 chain = 0x0,
 instance_flags = 0,
 length = 36,
 main_type = (struct main_type *) 0x1dfaa70}

after:

$1 = 
{pointer_type = 0x0,
 reference_type = 0x0,
 chain = 0x0,
 instance_flags = 0,
 length = 36,
 main_type = (struct main_type *) 0x1dfaa70}
main_type.
{name = 0x1df754a "array_t",
 tag_name = 0x0,
 code = TYPE_CODE_TYPEDEF,
 flags = [target_stub|objfile_owned],
 owner = (struct objfile *) 0x1de89b0,
 target_type = (struct type *) 0x1dfad10,
 vptr_basetype = 0x0,
 type_specific_field = TYPE_SPECIFIC_NONE}
target_type.
{pointer_type = 0x0,
 reference_type = 0x0,
 chain = 0x0,
 instance_flags = 0,
 length = 36,
 main_type = (struct main_type *) 0x1dfad40}
main_type.
{name = 0x0,
 tag_name = 0x0,
 code = TYPE_CODE_ARRAY,
 flags = [objfile_owned],
 owner = (struct objfile *) 0x1de89b0,
 target_type = (struct type *) 0x1dfab70,
 vptr_basetype = 0x0,
 flds_bnds.fields[0].
  {name = 0x0,
   type = (struct type *) 0x1dfac70,
   loc_kind = FIELD_LOC_KIND_BITPOS,
   bitsize = 0,
   bitpos = 0},
 type_specific_field = TYPE_SPECIFIC_NONE}
flds_bnds.fields[0].type.
{pointer_type = 0x0,
 reference_type = 0x0,
 chain = 0x0,
 instance_flags = 0,
 length = 8,
 main_type = (struct main_type *) 0x1dfaca0}
main_type.
{name = 0x0,
 tag_name = 0x0,
 code = TYPE_CODE_RANGE,
 flags = [unsigned|objfile_owned],
 owner = (struct objfile *) 0x1de89b0,
 target_type = (struct type *) 0x1dfabf0,
 vptr_basetype = 0x0,
 bounds = {0, 8},
 type_specific_field = TYPE_SPECIFIC_NONE}

2010-01-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb-gdb.py (StructTypePrettyPrinter): Chain to 'main_type'.
	(StructMainTypePrettyPrinter): Chain TYPE_CODE_ARRAY and
	TYPE_CODE_TYPEDEF.

--- ./gdb/gdb-gdb.py	2010-01-15 20:13:38.000000000 +0100
+++ ./gdb/gdb-gdb.py	2010-01-15 20:05:51.000000000 +0100
@@ -119,7 +119,9 @@ class StructTypePrettyPrinter:
                       % TypeFlagsPrinter(self.val['instance_flags']))
         fields.append("length = %d" % self.val['length'])
         fields.append("main_type = (%s) %s" % (self.val['main_type'].type, self.val['main_type']))
-        return "\n{" + ",\n ".join(fields) + "}"
+        retval = "\n{" + ",\n ".join(fields) + "}"
+        retval += "\nmain_type." + str(self.val['main_type'].dereference())
+        return retval
 
 class StructMainTypePrettyPrinter:
     """Pretty-print an objet of type main_type"""
@@ -229,7 +231,14 @@ class StructMainTypePrettyPrinter:
             fields.append(self.bounds_img())
         fields.append(self.type_specific_img())
 
-        return "\n{" + ",\n ".join(fields) + "}"
+        retval = "\n{" + ",\n ".join(fields) + "}"
+        if self.val['code'] == gdb.TYPE_CODE_ARRAY:
+            retval += ("\nflds_bnds.fields[0].type."
+                       + str(self.val['flds_bnds']['fields'][0]['type'].dereference()))
+        if self.val['code'] == gdb.TYPE_CODE_TYPEDEF:
+            retval += ("\ntarget_type."
+                       + str(self.val['target_type'].dereference()))
+        return retval
 
 def type_lookup_function(val):
     """A routine that returns the correct pretty printer for VAL


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