2002-11-11 Andrew Cagney <ac131313@redhat.com>
[deliverable/binutils-gdb.git] / gdb / p-lang.c
index b5ad5801aaba745acd0913fa02658623f94157ce..88c8cc09a907207c1de3a251f09d46892d552338 100644 (file)
@@ -1,5 +1,5 @@
 /* Pascal language support routines for GDB, the GNU debugger.
-   Copyright 2000 Free Software Foundation, Inc.
+   Copyright 2000, 2002 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -20,6 +20,7 @@
 /* This file is derived from c-lang.c */
 
 #include "defs.h"
+#include "gdb_string.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "expression.h"
@@ -44,7 +45,8 @@ extern void _initialize_pascal_language (void);
    but this does not happen for Free Pascal nor for GPC.  */
 int
 is_pascal_string_type (struct type *type,int *length_pos,
-                       int * length_size, int *string_pos, int *char_size)
+                       int *length_size, int *string_pos, int *char_size,
+                      char **arrayname)
 {
   if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
     {
@@ -54,11 +56,17 @@ is_pascal_string_type (struct type *type,int *length_pos,
           && strcmp (TYPE_FIELDS (type)[0].name, "length") == 0 
           && strcmp (TYPE_FIELDS (type)[1].name, "st") == 0)
         {
-          *length_pos = TYPE_FIELD_BITPOS (type, 0) / TARGET_CHAR_BIT;
-          *length_size = TYPE_FIELD_TYPE (type, 0)->length;
-          *string_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
-          *char_size = 1;
-          return 1;
+          if (length_pos)
+           *length_pos = TYPE_FIELD_BITPOS (type, 0) / TARGET_CHAR_BIT;
+          if (length_size)
+           *length_size = TYPE_LENGTH (TYPE_FIELD_TYPE (type, 0));
+          if (string_pos)
+           *string_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
+          if (char_size)
+           *char_size = 1;
+         if (arrayname)
+           *arrayname = TYPE_FIELDS (type)[1].name;
+         return 2;
         };
       /* GNU pascal strings.  */
       /* Three fields: Capacity, length and schema$ or _p_schema.  */
@@ -66,12 +74,18 @@ is_pascal_string_type (struct type *type,int *length_pos,
           && strcmp (TYPE_FIELDS (type)[0].name, "Capacity") == 0
           && strcmp (TYPE_FIELDS (type)[1].name, "length") == 0)
         {
-          *length_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
-          *length_size = TYPE_FIELD_TYPE (type, 1)->length;
-          *string_pos = TYPE_FIELD_BITPOS (type, 2) / TARGET_CHAR_BIT;
+          if (length_pos)
+           *length_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
+          if (length_size)
+           *length_size = TYPE_LENGTH (TYPE_FIELD_TYPE (type, 1));
+          if (string_pos)
+           *string_pos = TYPE_FIELD_BITPOS (type, 2) / TARGET_CHAR_BIT;
           /* FIXME: how can I detect wide chars in GPC ?? */
-          *char_size = 1;
-          return 1;
+          if (char_size)
+           *char_size = 1;
+         if (arrayname)
+           *arrayname = TYPE_FIELDS (type)[2].name;
+         return 3;
         };
     }
   return 0;
@@ -280,7 +294,7 @@ pascal_create_fundamental_type (struct objfile *objfile, int typeid)
                        0, "void", objfile);
       break;
     case FT_CHAR:
-      type = init_type (TYPE_CODE_INT,
+      type = init_type (TYPE_CODE_CHAR,
                        TARGET_CHAR_BIT / TARGET_CHAR_BIT,
                        0, "char", objfile);
       break;
@@ -407,7 +421,7 @@ const struct op_print pascal_op_print_tab[] =
   {NULL, 0, 0, 0}
 };
 \f
-struct type **const /* CONST_PTR v 4.17 */ (pascal_builtin_types[]) =
+struct type **const (pascal_builtin_types[]) =
 {
   &builtin_type_int,
     &builtin_type_long,
This page took 0.025226 seconds and 4 git commands to generate.