2011-01-05 Michael Snyder <msnyder@vmware.com>
[deliverable/binutils-gdb.git] / gdb / p-lang.c
index 08738ac28007d63da5506a7450941a9f6bc4c5e9..79a3338d334826c275ede1eee6be3a4a808b336d 100644 (file)
@@ -1,6 +1,6 @@
 /* Pascal language support routines for GDB, the GNU debugger.
 
-   Copyright (C) 2000, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
+   Copyright (C) 2000, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -105,9 +105,11 @@ is_pascal_string_type (struct type *type,int *length_pos,
     {
       /* Old Borland type pascal strings from Free Pascal Compiler.  */
       /* Two fields: length and st.  */
-      if (TYPE_NFIELDS (type) == 2 
-          && strcmp (TYPE_FIELDS (type)[0].name, "length") == 0 
-          && strcmp (TYPE_FIELDS (type)[1].name, "st") == 0)
+      if (TYPE_NFIELDS (type) == 2
+         && TYPE_FIELD_NAME (type, 0)
+         && strcmp (TYPE_FIELD_NAME (type, 0), "length") == 0 
+         && TYPE_FIELD_NAME (type, 1)
+         && strcmp (TYPE_FIELD_NAME (type, 1), "st") == 0)
         {
           if (length_pos)
            *length_pos = TYPE_FIELD_BITPOS (type, 0) / TARGET_CHAR_BIT;
@@ -118,14 +120,16 @@ is_pascal_string_type (struct type *type,int *length_pos,
           if (char_type)
            *char_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 1));
          if (arrayname)
-           *arrayname = TYPE_FIELDS (type)[1].name;
+           *arrayname = TYPE_FIELD_NAME (type, 1);
          return 2;
         };
       /* GNU pascal strings.  */
       /* Three fields: Capacity, length and schema$ or _p_schema.  */
       if (TYPE_NFIELDS (type) == 3
-          && strcmp (TYPE_FIELDS (type)[0].name, "Capacity") == 0
-          && strcmp (TYPE_FIELDS (type)[1].name, "length") == 0)
+         && TYPE_FIELD_NAME (type, 0)
+         && strcmp (TYPE_FIELD_NAME (type, 0), "Capacity") == 0
+         && TYPE_FIELD_NAME (type, 1)
+         && strcmp (TYPE_FIELD_NAME (type, 1), "length") == 0)
         {
          if (length_pos)
            *length_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
@@ -142,7 +146,7 @@ is_pascal_string_type (struct type *type,int *length_pos,
                *char_type = TYPE_TARGET_TYPE (*char_type);
            }
          if (arrayname)
-           *arrayname = TYPE_FIELDS (type)[2].name;
+           *arrayname = TYPE_FIELD_NAME (type, 2);
          return 3;
         };
     }
@@ -222,7 +226,11 @@ pascal_printstr (struct ui_file *stream, struct type *type,
   unsigned int things_printed = 0;
   int in_quotes = 0;
   int need_comma = 0;
-  int width = TYPE_LENGTH (type);
+  int width;
+
+  /* Preserve TYPE's original type, just set its LENGTH.  */
+  check_typedef (type);
+  width = TYPE_LENGTH (type);
 
   /* If the string was not truncated due to `set print elements', and
      the last byte of it is a null, we don't print that, in traditional C
This page took 0.024874 seconds and 4 git commands to generate.