==> ChangeLog <==
[deliverable/binutils-gdb.git] / gdb / p-valprint.c
index 21d21104338a4443bb414a84f59795801152da17..e2105ebd8dbc9a4faee90c60f5067266ec49fcef 100644 (file)
@@ -37,6 +37,7 @@
 #include "annotate.h"
 #include "p-lang.h"
 #include "cp-abi.h"
+#include "cp-support.h"
 \f
 
 
 
 
 int
-pascal_val_print (struct type *type, char *valaddr, int embedded_offset,
-                 CORE_ADDR address, struct ui_file *stream, int format,
-                 int deref_ref, int recurse, enum val_prettyprint pretty)
+pascal_val_print (struct type *type, const bfd_byte *valaddr,
+                 int embedded_offset, CORE_ADDR address,
+                 struct ui_file *stream, int format, int deref_ref,
+                 int recurse, enum val_prettyprint pretty)
 {
   unsigned int i = 0;  /* Number of characters printed */
   unsigned len;
@@ -173,7 +175,7 @@ pascal_val_print (struct type *type, char *valaddr, int embedded_offset,
 
          if (addressprint && format != 's')
            {
-             print_address_numeric (addr, 1, stream);
+             deprecated_print_address_numeric (addr, 1, stream);
            }
 
          /* For a pointer to char or unsigned char, also print the string
@@ -238,9 +240,8 @@ pascal_val_print (struct type *type, char *valaddr, int embedded_offset,
                      wtype = TYPE_TARGET_TYPE (type);
                    }
                  vt_val = value_at (wtype, vt_address);
-                 val_print (value_type (vt_val), VALUE_CONTENTS (vt_val), 0,
-                            VALUE_ADDRESS (vt_val), stream, format,
-                            deref_ref, recurse + 1, pretty);
+                 common_val_print (vt_val, stream, format, deref_ref,
+                                   recurse + 1, pretty);
                  if (pretty)
                    {
                      fprintf_filtered (stream, "\n");
@@ -257,7 +258,7 @@ pascal_val_print (struct type *type, char *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_MEMBER:
-      error ("not implemented: member type in pascal_val_print");
+      error (_("not implemented: member type in pascal_val_print"));
       break;
 
     case TYPE_CODE_REF:
@@ -273,7 +274,7 @@ pascal_val_print (struct type *type, char *valaddr, int embedded_offset,
        {
          fprintf_filtered (stream, "@");
          /* Extract the address, assume that it is unsigned.  */
-         print_address_numeric
+         deprecated_print_address_numeric
            (extract_unsigned_integer (valaddr + embedded_offset,
                                       TARGET_PTR_BIT / HOST_CHAR_BIT),
             1, stream);
@@ -290,10 +291,8 @@ pascal_val_print (struct type *type, char *valaddr, int embedded_offset,
              (TYPE_TARGET_TYPE (type),
               unpack_pointer (lookup_pointer_type (builtin_type_void),
                               valaddr + embedded_offset));
-             val_print (value_type (deref_val),
-                        VALUE_CONTENTS (deref_val), 0,
-                        VALUE_ADDRESS (deref_val), stream, format,
-                        deref_ref, recurse + 1, pretty);
+             common_val_print (deref_val, stream, format, deref_ref,
+                               recurse + 1, pretty);
            }
          else
            fputs_filtered ("???", stream);
@@ -527,7 +526,7 @@ pascal_val_print (struct type *type, char *valaddr, int embedded_offset,
       break;
 
     default:
-      error ("Invalid pascal type code %d in symbol table.", TYPE_CODE (type));
+      error (_("Invalid pascal type code %d in symbol table."), TYPE_CODE (type));
     }
   gdb_flush (stream);
   return (0);
@@ -564,9 +563,7 @@ pascal_value_print (struct value *val, struct ui_file *stream, int format,
          fprintf_filtered (stream, ") ");
        }
     }
-  return val_print (type, VALUE_CONTENTS (val), VALUE_EMBEDDED_OFFSET (val),
-                   VALUE_ADDRESS (val) + value_offset (val),
-                   stream, format, 1, 0, pretty);
+  return common_val_print (val, stream, format, 1, 0, pretty);
 }
 
 
@@ -578,17 +575,25 @@ extern int vtblprint;             /* Controls printing of vtbl's */
 extern int objectprint;                /* Controls looking up an object's derived type
                                   using what we find in its vtables.  */
 static int pascal_static_field_print;  /* Controls printing of static fields. */
+static void
+show_pascal_static_field_print (struct ui_file *file, int from_tty,
+                               struct cmd_list_element *c, const char *value)
+{
+  fprintf_filtered (file, _("Printing of pascal static members is %s.\n"),
+                   value);
+}
 
 static struct obstack dont_print_vb_obstack;
 static struct obstack dont_print_statmem_obstack;
 
-static void pascal_object_print_static_field (struct type *, struct value *,
+static void pascal_object_print_static_field (struct value *,
                                              struct ui_file *, int, int,
                                              enum val_prettyprint);
 
-static void
-  pascal_object_print_value (struct type *, char *, CORE_ADDR, struct ui_file *,
-                            int, int, enum val_prettyprint, struct type **);
+static void pascal_object_print_value (struct type *, const bfd_byte *,
+                                      CORE_ADDR, struct ui_file *,
+                                      int, int, enum val_prettyprint,
+                                      struct type **);
 
 void
 pascal_object_print_class_method (const bfd_byte *valaddr, struct type *type,
@@ -638,7 +643,7 @@ pascal_object_print_class_method (const bfd_byte *valaddr, struct type *type,
       sym = find_pc_function (addr);
       if (sym == 0)
        {
-         error ("invalid pointer to member function");
+         error (_("invalid pointer to member function"));
        }
       len = TYPE_NFN_FIELDS (domain);
       for (i = 0; i < len; i++)
@@ -720,8 +725,9 @@ pascal_object_is_vtbl_member (struct type *type)
   return 0;
 }
 
-/* Mutually recursive subroutines of pascal_object_print_value and c_val_print to
-   print out a structure's fields: pascal_object_print_value_fields and pascal_object_print_value.
+/* Mutually recursive subroutines of pascal_object_print_value and
+   c_val_print to print out a structure's fields:
+   pascal_object_print_value_fields and pascal_object_print_value.
 
    TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and PRETTY have the
    same meanings as in pascal_object_print_value and c_val_print.
@@ -730,7 +736,7 @@ pascal_object_is_vtbl_member (struct type *type)
    should not print, or zero if called from top level.  */
 
 void
-pascal_object_print_value_fields (struct type *type, char *valaddr,
+pascal_object_print_value_fields (struct type *type, const bfd_byte *valaddr,
                                  CORE_ADDR address, struct ui_file *stream,
                                  int format, int recurse,
                                  enum val_prettyprint pretty,
@@ -843,8 +849,7 @@ pascal_object_print_value_fields (struct type *type, char *valaddr,
                  v = value_from_longest (TYPE_FIELD_TYPE (type, i),
                                   unpack_field_as_long (type, valaddr, i));
 
-                 val_print (TYPE_FIELD_TYPE (type, i), VALUE_CONTENTS (v), 0, 0,
-                            stream, format, 0, recurse + 1, pretty);
+                 common_val_print (v, stream, format, 0, recurse + 1, pretty);
                }
            }
          else
@@ -863,9 +868,8 @@ pascal_object_print_value_fields (struct type *type, char *valaddr,
                  if (v == NULL)
                    fputs_filtered ("<optimized out>", stream);
                  else
-                   pascal_object_print_static_field (TYPE_FIELD_TYPE (type, i), v,
-                                               stream, format, recurse + 1,
-                                                     pretty);
+                   pascal_object_print_static_field (v, stream, format,
+                                                     recurse + 1, pretty);
                }
              else
                {
@@ -903,8 +907,9 @@ pascal_object_print_value_fields (struct type *type, char *valaddr,
    baseclasses.  */
 
 void
-pascal_object_print_value (struct type *type, char *valaddr, CORE_ADDR address,
-                          struct ui_file *stream, int format, int recurse,
+pascal_object_print_value (struct type *type, const bfd_byte *valaddr,
+                          CORE_ADDR address, struct ui_file *stream,
+                          int format, int recurse,
                           enum val_prettyprint pretty,
                           struct type **dont_print_vb)
 {
@@ -928,7 +933,7 @@ pascal_object_print_value (struct type *type, char *valaddr, CORE_ADDR address,
       int boffset;
       struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
       char *basename = TYPE_NAME (baseclass);
-      char *base_valaddr;
+      const bfd_byte *base_valaddr;
 
       if (BASETYPE_VIA_VIRTUAL (type, i))
        {
@@ -966,8 +971,9 @@ pascal_object_print_value (struct type *type, char *valaddr, CORE_ADDR address,
       if (boffset != -1 && (boffset < 0 || boffset >= TYPE_LENGTH (type)))
        {
          /* FIXME (alloc): not safe is baseclass is really really big. */
-         base_valaddr = (char *) alloca (TYPE_LENGTH (baseclass));
-         if (target_read_memory (address + boffset, base_valaddr,
+         bfd_byte *buf = alloca (TYPE_LENGTH (baseclass));
+         base_valaddr = buf;
+         if (target_read_memory (address + boffset, buf,
                                  TYPE_LENGTH (baseclass)) != 0)
            boffset = -1;
        }
@@ -1004,14 +1010,16 @@ pascal_object_print_value (struct type *type, char *valaddr, CORE_ADDR address,
    static member classes in an obstack and refuse to print them more
    than once.
 
-   VAL contains the value to print, TYPE, STREAM, RECURSE, and PRETTY
+   VAL contains the value to print, STREAM, RECURSE, and PRETTY
    have the same meanings as in c_val_print.  */
 
 static void
-pascal_object_print_static_field (struct type *type, struct value *val,
+pascal_object_print_static_field (struct value *val,
                                  struct ui_file *stream, int format,
                                  int recurse, enum val_prettyprint pretty)
 {
+  struct type *type = value_type (val);
+
   if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
     {
       CORE_ADDR *first_dont_print;
@@ -1036,12 +1044,11 @@ pascal_object_print_static_field (struct type *type, struct value *val,
                    sizeof (CORE_ADDR));
 
       CHECK_TYPEDEF (type);
-      pascal_object_print_value_fields (type, VALUE_CONTENTS (val), VALUE_ADDRESS (val),
+      pascal_object_print_value_fields (type, value_contents (val), VALUE_ADDRESS (val),
                                  stream, format, recurse, pretty, NULL, 1);
       return;
     }
-  val_print (type, VALUE_CONTENTS (val), 0, VALUE_ADDRESS (val),
-            stream, format, 0, recurse, pretty);
+  common_val_print (val, stream, format, 0, recurse, pretty);
 }
 
 void
@@ -1101,12 +1108,13 @@ extern initialize_file_ftype _initialize_pascal_valprint; /* -Wmissing-prototype
 void
 _initialize_pascal_valprint (void)
 {
-  deprecated_add_show_from_set
-    (add_set_cmd ("pascal_static-members", class_support, var_boolean,
-                 (char *) &pascal_static_field_print,
-                 "Set printing of pascal static members.",
-                 &setprintlist),
-     &showprintlist);
+  add_setshow_boolean_cmd ("pascal_static-members", class_support,
+                          &pascal_static_field_print, _("\
+Set printing of pascal static members."), _("\
+Show printing of pascal static members."), NULL,
+                          NULL,
+                          show_pascal_static_field_print,
+                          &setprintlist, &showprintlist);
   /* Turn on printing of static fields.  */
   pascal_static_field_print = 1;
 
This page took 0.054832 seconds and 4 git commands to generate.