Add a gdbarch 'print_auxv_entry' method for FreeBSD ABIs.
[deliverable/binutils-gdb.git] / gdb / gdb-gdb.py
index 49695b54bea2080e108085ce5198ef701effdb83..9a12baf4b6b33035b87c83479a5b68033bccf262 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+# Copyright (C) 2009-2016 Free Software Foundation, Inc.
 #
 # This file is part of GDB.
 #
@@ -23,8 +23,8 @@ class TypeFlag:
     and its value.
 
     In the GDB sources, struct type has a component called instance_flags
-    whose the value is the addition of various flags.  These flags are
-    defined by two emumerates: type_flag_value, and type_instance_flag_value.
+    in which the value is the addition of various flags.  These flags are
+    defined by two enumerates: type_flag_value, and type_instance_flag_value.
     This class helps us recreate a list with all these flags that is
     easy to manipulate and sort.  Because all flag names start with either
     TYPE_FLAG_ or TYPE_INSTANCE_FLAG_, a short_name attribute is provided
@@ -88,21 +88,21 @@ class TypeFlagsPrinter:
         try:
             flags = gdb.lookup_type("enum type_flag_value")
         except:
-            print "Warning: Cannot find enum type_flag_value type."
-            print "         `struct type' pretty-printer will be degraded"
+            print("Warning: Cannot find enum type_flag_value type.")
+            print("         `struct type' pretty-printer will be degraded")
             return
         try:
             iflags = gdb.lookup_type("enum type_instance_flag_value")
         except:
-            print "Warning: Cannot find enum type_instance_flag_value type."
-            print "         `struct type' pretty-printer will be degraded"
+            print("Warning: Cannot find enum type_instance_flag_value type.")
+            print("         `struct type' pretty-printer will be degraded")
             return
         # Note: TYPE_FLAG_MIN is a duplicate of TYPE_FLAG_UNSIGNED,
         # so exclude it from the list we are building.
-        TYPE_FLAGS = [TypeFlag(field.name, field.bitpos)
+        TYPE_FLAGS = [TypeFlag(field.name, field.enumval)
                       for field in flags.fields()
                       if field.name != 'TYPE_FLAG_MIN']
-        TYPE_FLAGS += [TypeFlag(field.name, field.bitpos)
+        TYPE_FLAGS += [TypeFlag(field.name, field.enumval)
                        for field in iflags.fields()]
         TYPE_FLAGS.sort()
 
@@ -154,6 +154,8 @@ class StructMainTypePrettyPrinter:
         loc_kind = str(field_val['loc_kind'])
         if loc_kind == "FIELD_LOC_KIND_BITPOS":
             return 'bitpos = %d' % loc_val['bitpos']
+        elif loc_kind == "FIELD_LOC_KIND_ENUMVAL":
+            return 'enumval = %d' % loc_val['enumval']
         elif loc_kind == "FIELD_LOC_KIND_PHYSADDR":
             return 'physaddr = 0x%x' % loc_val['physaddr']
         elif loc_kind == "FIELD_LOC_KIND_PHYSNAME":
@@ -166,7 +168,7 @@ class StructMainTypePrettyPrinter:
         """Return an image of the main_type field number FIELDNO.
         """
         f = self.val['flds_bnds']['fields'][fieldno]
-        label = "field[%d]:" % fieldno
+        label = "flds_bnds.fields[%d]:" % fieldno
         if f['artificial']:
             label += " (artificial)"
         fields = []
@@ -186,7 +188,34 @@ class StructMainTypePrettyPrinter:
         high = str(b['high'])
         if b['high_undefined'] != 0:
             high += " (undefined)"
-        return "bounds = {%s, %s}" % (low, high)
+        return "flds_bnds.bounds = {%s, %s}" % (low, high)
+    def type_specific_img(self):
+        """Return a string image of the main_type type_specific union.
+        Only the relevant component of that union is printed (based on
+        the value of the type_specific_kind field.
+        """
+        type_specific_kind = str(self.val['type_specific_field'])
+        type_specific = self.val['type_specific']
+        if type_specific_kind == "TYPE_SPECIFIC_NONE":
+            img = 'type_specific_field = %s' % type_specific_kind
+        elif type_specific_kind == "TYPE_SPECIFIC_CPLUS_STUFF":
+            img = "cplus_stuff = %s" % type_specific['cplus_stuff']
+        elif type_specific_kind == "TYPE_SPECIFIC_GNAT_STUFF":
+            img = ("gnat_stuff = {descriptive_type = %s}"
+                   % type_specific['gnat_stuff']['descriptive_type'])
+        elif type_specific_kind == "TYPE_SPECIFIC_FLOATFORMAT":
+            img = "floatformat[0..1] = %s" % type_specific['floatformat']
+        elif type_specific_kind == "TYPE_SPECIFIC_FUNC":
+            img = ("calling_convention = %d"
+                   % type_specific['func_stuff']['calling_convention'])
+            # tail_call_list is not printed.
+        elif type_specific_kind == "TYPE_SPECIFIC_SELF_TYPE":
+            img = "self_type = %s" % type_specific['self_type']
+        else:
+            img = ("type_specific = ??? (unknown type_secific_kind: %s)"
+                   % type_specific_kind)
+        return img
+
     def to_string(self):
         """Return a pretty-printed image of our main_type.
         """
@@ -197,17 +226,13 @@ class StructMainTypePrettyPrinter:
         fields.append("flags = [%s]" % self.flags_to_string())
         fields.append("owner = %s" % self.owner_to_string())
         fields.append("target_type = %s" % self.val['target_type'])
-        fields.append("vptr_basetype = %s" % self.val['vptr_basetype'])
         if self.val['nfields'] > 0:
             for fieldno in range(self.val['nfields']):
-                fields.append("field[%d]:")
                 fields.append(self.struct_field_img(fieldno))
-        if self.val.type.code == gdb.TYPE_CODE_RANGE:
+        if self.val['code'] == gdb.TYPE_CODE_RANGE:
             fields.append(self.bounds_img())
-        # FIXME: We need to print the type_specific field as well.
-        # But I will wait for a patch that introduces a discriminant.
-        # This will simplify the selection of the right component in
-        # that union.
+        fields.append(self.type_specific_img())
+
         return "\n{" + ",\n ".join(fields) + "}"
 
 def type_lookup_function(val):
This page took 0.04924 seconds and 4 git commands to generate.