gdb/testsuite/
[binutils-gdb.git] / gdb / valprint.c
index cbb5d94a9e75a32fbd25aea8004dd9a42d613cbd..517e607a85d6af4f9e218786bc89356d32cf43e9 100644 (file)
@@ -2,7 +2,7 @@
 
    Copyright (C) 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
    1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
-   2009 Free Software Foundation, Inc.
+   2009, 2010 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -35,6 +35,7 @@
 #include "exceptions.h"
 #include "dfp.h"
 #include "python/python.h"
+#include "ada-lang.h"
 
 #include <errno.h>
 
@@ -361,15 +362,23 @@ common_val_print (struct value *val, struct ui_file *stream, int recurse,
   if (!value_check_printable (val, stream))
     return 0;
 
+  if (language->la_language == language_ada)
+    /* The value might have a dynamic type, which would cause trouble
+       below when trying to extract the value contents (since the value
+       size is determined from the type size which is unknown).  So
+       get a fixed representation of our value.  */
+    val = ada_to_fixed_value (val);
+
   return val_print (value_type (val), value_contents_all (val),
                    value_embedded_offset (val), value_address (val),
                    stream, recurse, options, language);
 }
 
-/* Print the value VAL in C-ish syntax on stream STREAM according to
-   OPTIONS.
-   If the object printed is a string pointer, returns
-   the number of string bytes printed.  */
+/* Print on stream STREAM the value VAL according to OPTIONS.  The value
+   is printed using the current_language syntax.
+
+   If the object printed is a string pointer, return the number of string
+   bytes printed.  */
 
 int
 value_print (struct value *val, struct ui_file *stream,
@@ -386,6 +395,7 @@ value_print (struct value *val, struct ui_file *stream,
                                        value_address (val),
                                        stream, 0, options,
                                        current_language);
+
       if (r)
        return r;
     }
@@ -1132,6 +1142,7 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
   else
     {
       long low, hi;
+
       if (get_array_bounds (type, &low, &hi))
         len = hi - low + 1;
       else
@@ -1451,7 +1462,8 @@ val_print_string (struct type *elttype, CORE_ADDR addr, int len,
        {
          fputs_filtered (" ", stream);
        }
-      LA_PRINT_STRING (stream, elttype, buffer, bytes_read / width, force_ellipsis, options);
+      LA_PRINT_STRING (stream, elttype, buffer, bytes_read / width,
+                      NULL, force_ellipsis, options);
     }
 
   if (errcode != 0)
@@ -1621,8 +1633,6 @@ show_print (char *args, int from_tty)
 void
 _initialize_valprint (void)
 {
-  struct cmd_list_element *c;
-
   add_prefix_cmd ("print", no_class, set_print,
                  _("Generic command for setting how things print."),
                  &setprintlist, "set print ", 0, &setlist);