change delegation for to_read_description
[deliverable/binutils-gdb.git] / gdb / valprint.c
index ea877f355f040a02f5acc32538dc54b2a1429342..2f6ff94cb535bfc727495a1c5e810d80e9cbdf15 100644 (file)
@@ -1,6 +1,6 @@
 /* Print values for GDB, the GNU debugger.
 
-   Copyright (C) 1986-2013 Free Software Foundation, Inc.
+   Copyright (C) 1986-2014 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -32,7 +32,7 @@
 #include "doublest.h"
 #include "exceptions.h"
 #include "dfp.h"
-#include "python/python.h"
+#include "extension.h"
 #include "ada-lang.h"
 #include "gdb_obstack.h"
 #include "charset.h"
@@ -339,11 +339,17 @@ void
 val_print_optimized_out (const struct value *val, struct ui_file *stream)
 {
   if (val != NULL && value_lval_const (val) == lval_register)
-    fprintf_filtered (stream, _("<not saved>"));
+    val_print_not_saved (stream);
   else
     fprintf_filtered (stream, _("<optimized out>"));
 }
 
+void
+val_print_not_saved (struct ui_file *stream)
+{
+  fprintf_filtered (stream, _("<not saved>"));
+}
+
 void
 val_print_unavailable (struct ui_file *stream)
 {
@@ -764,9 +770,9 @@ val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 
   if (!options->raw)
     {
-      ret = apply_val_pretty_printer (type, valaddr, embedded_offset,
-                                     address, stream, recurse,
-                                     val, options, language);
+      ret = apply_ext_lang_val_pretty_printer (type, valaddr, embedded_offset,
+                                              address, stream, recurse,
+                                              val, options, language);
       if (ret)
        return;
     }
@@ -812,6 +818,15 @@ value_check_printable (struct value *val, struct ui_file *stream,
       return 0;
     }
 
+  if (value_entirely_unavailable (val))
+    {
+      if (options->summary && !val_print_scalar_type_p (value_type (val)))
+       fprintf_filtered (stream, "...");
+      else
+       val_print_unavailable (stream);
+      return 0;
+    }
+
   if (TYPE_CODE (value_type (val)) == TYPE_CODE_INTERNAL_FUNCTION)
     {
       fprintf_filtered (stream, _("<internal function %s>"),
@@ -861,12 +876,13 @@ value_print (struct value *val, struct ui_file *stream,
 
   if (!options->raw)
     {
-      int r = apply_val_pretty_printer (value_type (val),
-                                       value_contents_for_printing (val),
-                                       value_embedded_offset (val),
-                                       value_address (val),
-                                       stream, 0,
-                                       val, options, current_language);
+      int r
+       = apply_ext_lang_val_pretty_printer (value_type (val),
+                                            value_contents_for_printing (val),
+                                            value_embedded_offset (val),
+                                            value_address (val),
+                                            stream, 0,
+                                            val, options, current_language);
 
       if (r)
        return;
@@ -1711,7 +1727,7 @@ val_print_array_elements (struct type *type,
 
 /* Read LEN bytes of target memory at address MEMADDR, placing the
    results in GDB's memory at MYADDR.  Returns a count of the bytes
-   actually read, and optionally a target_xfer_error value in the
+   actually read, and optionally a target_xfer_status value in the
    location pointed to by ERRPTR if ERRPTR is non-null.  */
 
 /* FIXME: cagney/1999-10-14: Only used by val_print_string.  Can this
@@ -1755,13 +1771,15 @@ partial_memory_read (CORE_ADDR memaddr, gdb_byte *myaddr,
    each.  Fetch at most FETCHLIMIT characters.  BUFFER will be set to a newly
    allocated buffer containing the string, which the caller is responsible to
    free, and BYTES_READ will be set to the number of bytes read.  Returns 0 on
-   success, or a target_xfer_error on failure.
+   success, or a target_xfer_status on failure.
+
+   If LEN > 0, reads the lesser of LEN or FETCHLIMIT characters
+   (including eventual NULs in the middle or end of the string).
 
-   If LEN > 0, reads exactly LEN characters (including eventual NULs in
-   the middle or end of the string).  If LEN is -1, stops at the first
-   null character (not necessarily the first null byte) up to a maximum
-   of FETCHLIMIT characters.  Set FETCHLIMIT to UINT_MAX to read as many
-   characters as possible from the string.
+   If LEN is -1, stops at the first null character (not necessarily
+   the first null byte) up to a maximum of FETCHLIMIT characters.  Set
+   FETCHLIMIT to UINT_MAX to read as many characters as possible from
+   the string.
 
    Unless an exception is thrown, BUFFER will always be allocated, even on
    failure.  In this case, some characters might have been read before the
@@ -1807,10 +1825,12 @@ read_string (CORE_ADDR addr, int len, int width, unsigned int fetchlimit,
 
   if (len > 0)
     {
-      *buffer = (gdb_byte *) xmalloc (len * width);
+      unsigned int fetchlen = min (len, fetchlimit);
+
+      *buffer = (gdb_byte *) xmalloc (fetchlen * width);
       bufptr = *buffer;
 
-      nfetch = partial_memory_read (addr, bufptr, len * width, &errcode)
+      nfetch = partial_memory_read (addr, bufptr, fetchlen * width, &errcode)
        / width;
       addr += nfetch * width;
       bufptr += nfetch * width;
This page took 0.025628 seconds and 4 git commands to generate.