2005-01-28 Andrew Cagney <cagney@gnu.org>
[deliverable/binutils-gdb.git] / gdb / ada-valprint.c
index 55baf10dbec16b9ca108ae0d7da0fa5e4c892b2a..0f2f81660c4862a8848d1b58c71da496c7ac11b0 100644 (file)
@@ -1,7 +1,7 @@
 /* Support for printing Ada values for GDB, the GNU debugger.
+
    Copyright 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1997, 2001,
-   2002, 2003, 2004.
-             Free Software Foundation, Inc.
+   2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
 This file is part of GDB.
 
@@ -33,6 +33,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "ada-lang.h"
 #include "c-lang.h"
 #include "infcall.h"
+#include "exceptions.h"
 
 /* Encapsulates arguments to ada_val_print.  */
 struct ada_val_print_args
@@ -48,9 +49,6 @@ struct ada_val_print_args
   enum val_prettyprint pretty;
 };
 
-extern int inspect_it;
-extern unsigned int repeat_count_threshold;
-
 static void print_record (struct type *, char *, struct ui_file *, int,
                          int, enum val_prettyprint);
 
@@ -209,7 +207,7 @@ val_print_packed_array_elements (struct type *type, char *valaddr,
          val_print (elttype, VALUE_CONTENTS (v0), 0, 0, stream, format,
                     0, recurse + 1, pretty);
          annotate_elt_rep (i - i0);
-         fprintf_filtered (stream, " <repeats %u times>", i - i0);
+         fprintf_filtered (stream, _(" <repeats %u times>"), i - i0);
          annotate_elt_rep_end ();
 
        }
@@ -280,7 +278,7 @@ ada_emit_char (int c, struct ui_file *stream, int quoter, int type_len)
    or 2) of a character.  */
 
 static int
-char_at (char *string, int i, int type_len)
+char_at (const bfd_byte *string, int i, int type_len)
 {
   if (type_len == 1)
     return string[i];
@@ -317,21 +315,34 @@ ada_print_floating (char *valaddr, struct type *type, struct ui_file *stream)
   len = strlen (result);
 
   /* Modify for Ada rules.  */
-  if ((s = strstr (result, "inf")) != NULL
-      || (s = strstr (result, "Inf")) != NULL
-      || (s = strstr (result, "INF")) != NULL)
+  
+  s = strstr (result, "inf");
+  if (s == NULL)
+    s = strstr (result, "Inf");
+  if (s == NULL)
+    s = strstr (result, "INF");
+  if (s != NULL)
     strcpy (s, "Inf");
-  else if ((s = strstr (result, "nan")) != NULL
-          || (s = strstr (result, "NaN")) != NULL
-          || (s = strstr (result, "Nan")) != NULL)
+
+  if (s == NULL)
     {
-      s[0] = s[2] = 'N';
-      if (result[0] == '-')
-       result += 1;
+      s = strstr (result, "nan");
+      if (s == NULL)
+       s = strstr (result, "NaN");
+      if (s == NULL)
+       s = strstr (result, "Nan");
+      if (s != NULL)
+       {
+         s[0] = s[2] = 'N';
+         if (result[0] == '-')
+           result += 1;
+       }
     }
-  else if (strchr (result, '.') == NULL)
+
+  if (s == NULL && strchr (result, '.') == NULL)
     {
-      if ((s = strchr (result, 'e')) == NULL)
+      s = strchr (result, 'e');
+      if (s == NULL)
        fprintf_filtered (stream, "%s.0", result);
       else
        fprintf_filtered (stream, "%.*s.0%s", (int) (s-result), result, s);
@@ -357,7 +368,7 @@ ada_print_scalar (struct type *type, LONGEST val, struct ui_file *stream)
   unsigned int i;
   unsigned len;
 
-  CHECK_TYPEDEF (type);
+  type = ada_check_typedef (type);
 
   switch (TYPE_CODE (type))
     {
@@ -411,11 +422,11 @@ ada_print_scalar (struct type *type, LONGEST val, struct ui_file *stream)
     case TYPE_CODE_MEMBER:
     case TYPE_CODE_METHOD:
     case TYPE_CODE_REF:
-      warning ("internal error: unhandled type in ada_print_scalar");
+      warning (_("internal error: unhandled type in ada_print_scalar"));
       break;
 
     default:
-      error ("Invalid type code in symbol table.");
+      error (_("Invalid type code in symbol table."));
     }
   gdb_flush (stream);
 }
@@ -428,8 +439,8 @@ ada_print_scalar (struct type *type, LONGEST val, struct ui_file *stream)
  */
 
 static void
-printstr (struct ui_file *stream, char *string, unsigned int length,
-         int force_ellipses, int type_len)
+printstr (struct ui_file *stream, const bfd_byte *string,
+         unsigned int length, int force_ellipses, int type_len)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -460,9 +471,9 @@ printstr (struct ui_file *stream, char *string, unsigned int length,
 
       rep1 = i + 1;
       reps = 1;
-      while (rep1 < length &&
-            char_at (string, rep1, type_len) == char_at (string, i,
-                                                         type_len))
+      while (rep1 < length
+            && char_at (string, rep1, type_len) == char_at (string, i,
+                                                            type_len))
        {
          rep1 += 1;
          reps += 1;
@@ -482,7 +493,7 @@ printstr (struct ui_file *stream, char *string, unsigned int length,
          ada_emit_char (char_at (string, i, type_len), stream, '\'',
                         type_len);
          fputs_filtered ("'", stream);
-         fprintf_filtered (stream, " <repeats %u times>", reps);
+         fprintf_filtered (stream, _(" <repeats %u times>"), reps);
          i = rep1 - 1;
          things_printed += repeat_count_threshold;
          need_comma = 1;
@@ -589,7 +600,7 @@ ada_val_print_1 (struct type *type, char *valaddr0, int embedded_offset,
   LONGEST val;
   char *valaddr = valaddr0 + embedded_offset;
 
-  CHECK_TYPEDEF (type);
+  type = ada_check_typedef (type);
 
   if (ada_is_array_descriptor_type (type) || ada_is_packed_array_type (type))
     {
@@ -604,7 +615,7 @@ ada_val_print_1 (struct type *type, char *valaddr0, int embedded_offset,
          retn = 0;
        }
       else
-       retn = ada_val_print_1 (VALUE_TYPE (val), VALUE_CONTENTS (val), 0,
+       retn = ada_val_print_1 (value_type (val), VALUE_CONTENTS (val), 0,
                                VALUE_ADDRESS (val), stream, format,
                                deref_ref, recurse, pretty);
       value_free_to_mark (mark);
@@ -850,7 +861,7 @@ ada_val_print_1 (struct type *type, char *valaddr0, int embedded_offset,
                    ada_value_ind (value_from_longest
                                   (lookup_pointer_type (elttype),
                                    deref_val_int));
-                 val_print (VALUE_TYPE (deref_val),
+                 val_print (value_type (deref_val),
                             VALUE_CONTENTS (deref_val), 0,
                             VALUE_ADDRESS (deref_val), stream, format,
                             deref_ref, recurse + 1, pretty);
@@ -892,9 +903,9 @@ ada_value_print (struct value *val0, struct ui_file *stream, int format,
                 enum val_prettyprint pretty)
 {
   char *valaddr = VALUE_CONTENTS (val0);
-  CORE_ADDR address = VALUE_ADDRESS (val0) + VALUE_OFFSET (val0);
+  CORE_ADDR address = VALUE_ADDRESS (val0) + value_offset (val0);
   struct type *type =
-    ada_to_fixed_type (VALUE_TYPE (val0), valaddr, address, NULL);
+    ada_to_fixed_type (value_type (val0), valaddr, address, NULL);
   struct value *val =
     value_from_contents_and_address (type, valaddr, address);
 
@@ -950,7 +961,7 @@ static void
 print_record (struct type *type, char *valaddr, struct ui_file *stream,
              int format, int recurse, enum val_prettyprint pretty)
 {
-  CHECK_TYPEDEF (type);
+  type = ada_check_typedef (type);
 
   fprintf_filtered (stream, "(");
 
@@ -1058,7 +1069,7 @@ print_field_values (struct type *type, char *valaddr, struct ui_file *stream,
          if (TYPE_CPLUS_SPECIFIC (type) != NULL
              && TYPE_FIELD_IGNORE (type, i))
            {
-             fputs_filtered ("<optimized out or zero length>", stream);
+             fputs_filtered (_("<optimized out or zero length>"), stream);
            }
          else
            {
This page took 0.026361 seconds and 4 git commands to generate.