This is the mail archive of the archer@sourceware.org mailing list for the Archer project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch][rfc] Implement Python lazy strings (PR 10705)


I wanted to send this patch out before the holidays for initial
review.  This patch implements Python lazy strings, and also alters
the Python pretty-printing process to handle them accordingly.  A
Python lazy string, as implemented here is a pointer, an optional
encoding and an optional length.  The contents of the lazy string are
not retrieved until printing, and additionally, they are not encoded
with Python's codec machinery.  The are encoded with GDB's encoding
machinery at time of printing.  This patch allows Paul's example:

print estring 
$1 = "embedded x\201\202\203\204

To be processed correctly through the Python pretty-printing code.

This patch is mainly in response to:

http://sourceware.org/bugzilla/show_bug.cgi?id=10705

Though it will not fix pretty-printers attempting to print
uninitialized data in a backtrace.  But it should handle that data as
well as GDB's own printing and encoding mechanisms do now.

There is a small patch required to enable lazy strings with the
libstdc++ printers.  I'll submit that when this patch is accepted
upstream.  But if you want to try them now, you have to remove the
encoding logic in the std::string printer (we let GDB decide the
encoding, it is more accurate).  And also return a lazy_string(length
= len) from the printer over a string().

Tested on X86_64 on archer-tromey-python branch with no regressions.

Cheers,

Phil

--


ChangeLog:

2009-12-18  Phil Muldoon  <pmuldoon@redhat.com>

	PR python/10705

	* python/python-internal.h: Add lazy_string_object_type
	definition.
	(create_lazy_string_object, gdbpy_initialize_lazy_string)
	(is_lazystring, extract_lazy_string): Define.
	* python/py-value.c (valpy_lazy_string): New function.
	(convert_value_from_python): Add lazy string conversion.
	* python/py-prettyprint.c (is_lazy_string): New function.
	(extract_lazy_string): Likewise.
	(pretty_print_one_value): Check if return is also a lazy string.
	(print_string_repr): Add lazy string printing branch.
	(print_children): Likewise.
	* python/py-lazy-string.c: New file. Implement lazy strings.
	* python/python.c (_initialize_python): Call
	gdbpy_initialize_lazy_string.
	* varobj.c (value_get_print_value): Add lazy string printing
	branch.  Account for encoding.
	* c-lang.c (c_printstr): Account for new encoding argument.  If
	encoding is NULL, find encoding suited for type, otherwise use
	user encoding.
	* language.h (language_defn): Add encoding argument.
	(LA_PRINT_STRING): Likewise.
	* language.c (unk_lang_printstr): Update to reflect new encoding
	argument to language_defn.
	* ada-lang.h (ada_printstr): Likewise.
	* c-lang.h (c_printstr): Likewise.
	* p-lang.h (pascal_printstr);
	* f-lang.c (f_printstr): Likewise.
	* m2-lang.c (m2_printstr): Likewise.
	* objc-lang.c (objc_printstr): Likewise.
	* p-lang.c (pascal_printstr): Likewise.
	* scm-lang.c (scm_printstr): Likewise.
	* c-valprint.c (c_val_print): Update LA_PRINT_STRING call for
	encoding argument.
	* ada-valprint.c (ada_printstr): Likewise.
	* f-valprint.c (f_val_print): Likewise
	* m2-valprint.c (m2_val_print): Likewise.
	* p-valprint.c (pascal_val_print): Likewise.
	* expprint.c (print_subexp_standard): Likewise.
	* valprint.c (val_print_string): Likewise.
	* Makefile.in (SUBDIR_PYTHON_OBS): Add py-lazy-string.
	(SUBDIR_PYTHON_SRCS): Likewise.
	(py-lazy-string.o): New rule.

gdb/testsuite ChangeLog:

2009-12-18  Phil Muldoon  <pmuldoon@redhat.com>

	* gdb.python/py-value.exp (test_lazy_strings): Add lazy string test.
	* gdb.python/py-prettyprint.py (pp_ls): New printer.
	* gdb.python/py-prettyprint.exp (run_lang_tests): Add lazy string
	test.
	* gdb.python/py-prettyprint.c: Define lazystring test structure.
	* gdb.python/py-mi.exp: Add lazy string test.

gdb/doc ChangeLog:

2009-12-18  Phil Muldoon  <pmuldoon@redhat.com>

	* gdb.texinfo (Values From Inferior): Document lazy_string value
	method.
	(Python API): Add Lazy strings menu item.
	(Lazy Strings In Python): New node.

--

diff --git gdb/Makefile.in b/gdb/Makefile.in
index ac3a4a0..306afb1 100644
--- gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -279,6 +279,7 @@ SUBDIR_PYTHON_OBS = \
 	py-hooks.o \
 	py-inferior.o \
 	py-infthread.o \
+	py-lazy-string.o \
 	py-objfile.o \
 	py-param.o \
 	py-prettyprint.o \
@@ -297,6 +298,7 @@ SUBDIR_PYTHON_SRCS = \
 	python/py-hooks.c \
 	python/py-inferior.c \
 	python/py-infthread.c \
+	python/py-lazy-string.c \
 	python/py-objfile.c \
 	python/py-param.c \
 	python/py-prettyprint.c \
@@ -1981,6 +1983,10 @@ py-infthread.o: $(srcdir)/python/py-infthread.c
 	$(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-infthread.c
 	$(POSTCOMPILE)
 
+py-lazy-string.o: $(srcdir)/python/py-lazy-string.c
+	$(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-lazy-string.c
+	$(POSTCOMPILE)
+
 py-objfile.o: $(srcdir)/python/py-objfile.c
 	$(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-objfile.c
 	$(POSTCOMPILE)
diff --git gdb/ada-lang.h b/gdb/ada-lang.h
index c314867..40d3c32 100644
--- gdb/ada-lang.h
+++ gdb/ada-lang.h
@@ -260,7 +260,7 @@ extern void ada_emit_char (int, struct type *, struct ui_file *, int, int);
 extern void ada_printchar (int, struct type *, struct ui_file *);
 
 extern void ada_printstr (struct ui_file *, struct type *, const gdb_byte *,
-			  unsigned int, int,
+			  unsigned int, const char *, int,
 			  const struct value_print_options *);
 
 struct value *ada_convert_actual (struct value *actual,
diff --git gdb/ada-valprint.c gdb/ada-valprint.c
index 565172c..0af2af5 100644
--- gdb/ada-valprint.c
+++ gdb/ada-valprint.c
@@ -555,7 +555,7 @@ printstr (struct ui_file *stream, struct type *elttype, const gdb_byte *string,
 
 void
 ada_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
-	      unsigned int length, int force_ellipses,
+	      unsigned int length, const char *encoding, int force_ellipses,
 	      const struct value_print_options *options)
 {
   printstr (stream, type, string, length, force_ellipses, TYPE_LENGTH (type),
diff --git gdb/c-lang.c gdb/c-lang.c
index 515685a..3c22f48 100644
--- gdb/c-lang.c
+++ gdb/c-lang.c
@@ -369,7 +369,7 @@ c_printchar (int c, struct type *type, struct ui_file *stream)
 
 void
 c_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
-	    unsigned int length, int force_ellipses,
+	    unsigned int length, const char *user_encoding, int force_ellipses,
 	    const struct value_print_options *options)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
@@ -381,6 +381,7 @@ c_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
   struct obstack wchar_buf, output;
   struct cleanup *cleanup;
   enum c_string_type str_type;
+  const char *type_encoding;
   const char *encoding;
   struct wchar_iterator *iter;
   int finished = 0;
@@ -395,7 +396,7 @@ c_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
 				    width, byte_order) == 0))
     length--;
 
-  str_type = classify_type (type, byte_order, &encoding) & ~C_CHAR;
+  str_type = classify_type (type, byte_order, &type_encoding) & ~C_CHAR;
   switch (str_type)
     {
     case C_STRING:
@@ -411,6 +412,8 @@ c_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
       break;
     }
 
+  encoding = (user_encoding && *user_encoding) ? user_encoding : type_encoding;
+
   if (length == 0)
     {
       fputs_filtered ("\"\"", stream);
diff --git gdb/c-lang.h gdb/c-lang.h
index ba9d996..f653a9a 100644
--- gdb/c-lang.h
+++ gdb/c-lang.h
@@ -81,7 +81,7 @@ extern void c_printchar (int, struct type *, struct ui_file *);
 
 extern void c_printstr (struct ui_file * stream, struct type *elttype,
 			const gdb_byte *string, unsigned int length,
-			int force_ellipses,
+			const char *user_encoding, int force_ellipses,
 			const struct value_print_options *options);
 
 extern void c_language_arch_info (struct gdbarch *gdbarch,
diff --git gdb/c-valprint.c gdb/c-valprint.c
index dc391ee..5b639f0 100644
--- gdb/c-valprint.c
+++ gdb/c-valprint.c
@@ -198,7 +198,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 		}
 
 	      LA_PRINT_STRING (stream, unresolved_elttype,
-			       valaddr + embedded_offset, len, 0, options);
+			       valaddr + embedded_offset, len, NULL, 0, options);
 	      i = len;
 	    }
 	  else
diff --git gdb/doc/gdb.texinfo gdb/doc/gdb.texinfo
index 18ffb09..29cdefb 100644
--- gdb/doc/gdb.texinfo
+++ gdb/doc/gdb.texinfo
@@ -18873,6 +18873,7 @@ situation, a Python @code{KeyboardInterrupt} exception is thrown.
 * Objfiles In Python::          Object files.
 * Breakpoints In Python::       Manipulating breakpoints using Python.
 * Frames In Python::            Acessing inferior stack frames from Python.
+* Lazy Strings In Python::      Python representation of lazy strings.
 @end menu
 
 @node Basic Python
@@ -19168,6 +19169,25 @@ argument to Python's @code{string.decode} method.
 If the optional @var{length} argument is given, the string will be
 fetched and converted to the given length.
 @end defmethod
+
+@defmethod Value lazy_string @r{[}encoding@r{]} @r{[}length@r{]}
+If this @code{gdb.Value} represents a string, then this method
+converts the contents to a @code{gdb.LazyString} (@pxref{Lazy Strings
+In Python}).  Otherwise, this method will throw an exception.
+
+If the optional @var{encoding} argument is given, it must be a string
+naming the encoding of the string in the @code{gdb.LazyString}, such as
+@code{"ascii"}, @code{"iso-8859-6"} or @code{"utf-8"}.  When a lazy
+string is printed, the @value{GDBN} codec machinery is used to convert
+the string during printing.  If @var{encoding} is not given, or if
+@var{encoding} is an empty string, then @var{encoding} is set to
+NULL.  When @value{GDBN} attempts to print a @code{gdb.LazyString}
+where @var{encoding} is set to NULL, @value{GDBN} will automatically
+select the encoding most suitable for the string type.
+
+If the optional @var{length} argument is given, the string will be
+fetched and encoded to the given length.
+@end defmethod
 @end table
 
 @node Types In Python
@@ -20433,6 +20453,51 @@ Set this frame to be the user's selected frame.
 @end defmethod
 @end table
 
+@node Lazy Strings In Python
+@subsubsection Python representation of lazy strings.
+
+@cindex lazy strings in python
+@tindex gdb.LazyString
+A @code{gdb.LazyString} can be defined as an @code{address} that
+points to a region of memory, an @code{encoding} that will be used to
+encode that region of memory, and a @code{length} to delimit the
+region of memory that represents the string.  The difference between a
+@code{gdb.LazyString} and a string wrapped within a @code{gdb.Value}
+is that a @code{gdb.LazyString} will be treated differently by
+@value{GDBN} when printing.  A @code{gdb.LazyString} is retrieved and
+encoded during printing, while a @code{gdb.Value} wrapping a string is
+immediately retrieved and encoded on creation.
+
+A @code{gdb.LazyString} object has the following functions:
+
+@defmethod LazyString value
+Convert the @code{gdb.LazyString} to a @code{gdb.Value}.  This value
+will point to the string in memory, but will lose all the delayed
+retrieval, encoding and handling that @value{GDBN} applies to a
+@code{gdb.LazyString}.
+@end defmethod
+
+@defivar LazyString address
+This attribute holds the address of the string.  This attribute is not
+writable.
+@end defivar
+
+@defivar LazyString length
+This attribute holds the length of the string.  This attribute is not
+writable.
+@end defivar
+
+@defivar LazyString encoding
+This attribute holds the encoding that will be applied to the string
+when the string is printed by @value{GDBN}.  This attribute is not
+writable.
+@end defivar
+
+@defivar LazyString type
+This attribute holds the type that is associated with the string.
+This attribute is not writable.
+@end defivar
+
 @node Interpreters
 @chapter Command Interpreters
 @cindex command interpreters
diff --git gdb/expprint.c gdb/expprint.c
index e83d101..566bf6b 100644
--- gdb/expprint.c
+++ gdb/expprint.c
@@ -187,7 +187,7 @@ print_subexp_standard (struct expression *exp, int *pos,
 	   additional parameter to LA_PRINT_STRING.  -fnf */
 	get_user_print_options (&opts);
 	LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char,
-			 &exp->elts[pc + 2].string, nargs, 0, &opts);
+			 &exp->elts[pc + 2].string, nargs, NULL, 0, &opts);
       }
       return;
 
@@ -206,7 +206,7 @@ print_subexp_standard (struct expression *exp, int *pos,
 	fputs_filtered ("@\"", stream);
 	get_user_print_options (&opts);
 	LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char,
-			 &exp->elts[pc + 2].string, nargs, 0, &opts);
+			 &exp->elts[pc + 2].string, nargs, NULL, 0, &opts);
 	fputs_filtered ("\"", stream);
       }
       return;
@@ -292,7 +292,7 @@ print_subexp_standard (struct expression *exp, int *pos,
 	  struct value_print_options opts;
 	  get_user_print_options (&opts);
 	  LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char,
-			   tempstr, nargs - 1, 0, &opts);
+			   tempstr, nargs - 1, NULL, 0, &opts);
 	  (*pos) = pc;
 	}
       else
diff --git gdb/f-lang.c gdb/f-lang.c
index 19c1316..693ecff 100644
--- gdb/f-lang.c
+++ gdb/f-lang.c
@@ -143,7 +143,7 @@ f_printchar (int c, struct type *type, struct ui_file *stream)
 
 static void
 f_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
-	    unsigned int length, int force_ellipses,
+	    unsigned int length, const char *encoding, int force_ellipses,
 	    const struct value_print_options *options)
 {
   unsigned int i;
diff --git gdb/f-valprint.c gdb/f-valprint.c
index 0a57404..d5963d1 100644
--- gdb/f-valprint.c
+++ gdb/f-valprint.c
@@ -259,7 +259,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
     case TYPE_CODE_STRING:
       f77_get_dynamic_length_of_aggregate (type);
       LA_PRINT_STRING (stream, builtin_type (gdbarch)->builtin_char,
-		       valaddr, TYPE_LENGTH (type), 0, options);
+		       valaddr, TYPE_LENGTH (type), NULL, 0, options);
       break;
 
     case TYPE_CODE_ARRAY:
diff --git gdb/language.c gdb/language.c
index 51a49f8..bdb97cb 100644
--- gdb/language.c
+++ gdb/language.c
@@ -1080,7 +1080,7 @@ unk_lang_printchar (int c, struct type *type, struct ui_file *stream)
 static void
 unk_lang_printstr (struct ui_file *stream, struct type *type,
 		   const gdb_byte *string, unsigned int length,
-		   int force_ellipses,
+		   const char *encoding,  int force_ellipses,
 		   const struct value_print_options *options)
 {
   error (_("internal error - unimplemented function unk_lang_printstr called."));
diff --git gdb/language.h gdb/language.h
index c650e07..9ecc034 100644
--- gdb/language.h
+++ gdb/language.h
@@ -190,7 +190,7 @@ struct language_defn
 
     void (*la_printstr) (struct ui_file * stream, struct type *elttype,
 			 const gdb_byte *string, unsigned int length,
-			 int force_ellipses,
+			 const char *encoding, int force_ellipses,
 			 const struct value_print_options *);
 
     void (*la_emitchar) (int ch, struct type *chtype,
@@ -389,9 +389,9 @@ extern enum language set_language (enum language);
 
 #define LA_PRINT_CHAR(ch, type, stream) \
   (current_language->la_printchar(ch, type, stream))
-#define LA_PRINT_STRING(stream, elttype, string, length, force_ellipses,options) \
+#define LA_PRINT_STRING(stream, elttype, string, length, encoding, force_ellipses,options) \
   (current_language->la_printstr(stream, elttype, string, length, \
-				 force_ellipses,options))
+				 encoding, force_ellipses,options))
 #define LA_EMIT_CHAR(ch, type, stream, quoter) \
   (current_language->la_emitchar(ch, type, stream, quoter))
 #define LA_GET_STRING(value, buffer, length, encoding) \
diff --git gdb/m2-lang.c gdb/m2-lang.c
index 88c7e5e..a9d8e15 100644
--- gdb/m2-lang.c
+++ gdb/m2-lang.c
@@ -104,7 +104,7 @@ m2_printchar (int c, struct type *type, struct ui_file *stream)
 
 static void
 m2_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
-	     unsigned int length, int force_ellipses,
+	     unsigned int length, const char *encoding, int force_ellipses,
 	     const struct value_print_options *options)
 {
   unsigned int i;
diff --git gdb/m2-valprint.c gdb/m2-valprint.c
index 657eff7..164ddb9 100644
--- gdb/m2-valprint.c
+++ gdb/m2-valprint.c
@@ -360,8 +360,8 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 		}
 
 	      LA_PRINT_STRING (stream, TYPE_TARGET_TYPE (type),
-			       valaddr + embedded_offset, len, 0,
-			       options);
+			       valaddr + embedded_offset, len, NULL,
+			       0, options);
 	      i = len;
 	    }
 	  else
diff --git gdb/objc-lang.c gdb/objc-lang.c
index 0e4fb71..66f7333 100644
--- gdb/objc-lang.c
+++ gdb/objc-lang.c
@@ -343,7 +343,7 @@ objc_printchar (int c, struct type *type, struct ui_file *stream)
 static void
 objc_printstr (struct ui_file *stream, struct type *type,
 	       const gdb_byte *string, unsigned int length,
-	       int force_ellipses,
+	       const char *encoding, int force_ellipses,
 	       const struct value_print_options *options)
 {
   unsigned int i;
diff --git gdb/p-lang.c gdb/p-lang.c
index 1722c0f..9815fcc 100644
--- gdb/p-lang.c
+++ gdb/p-lang.c
@@ -214,7 +214,7 @@ pascal_printchar (int c, struct type *type, struct ui_file *stream)
 void
 pascal_printstr (struct ui_file *stream, struct type *type,
 		 const gdb_byte *string, unsigned int length,
-		 int force_ellipses,
+		 const char *encoding, int force_ellipses,
 		 const struct value_print_options *options)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
diff --git gdb/p-lang.h gdb/p-lang.h
index 2b2eb2d..09b76da 100644
--- gdb/p-lang.h
+++ gdb/p-lang.h
@@ -54,7 +54,7 @@ extern int
 extern void pascal_printchar (int, struct type *, struct ui_file *);
 
 extern void pascal_printstr (struct ui_file *, struct type *, const gdb_byte *,
-			     unsigned int, int,
+			     unsigned int, const char *, int,
 			     const struct value_print_options *);
 
 extern struct type **const (pascal_builtin_types[]);
diff --git gdb/p-valprint.c gdb/p-valprint.c
index 50c993f..903e71a 100644
--- gdb/p-valprint.c
+++ gdb/p-valprint.c
@@ -104,7 +104,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 		}
 
 	      LA_PRINT_STRING (stream, TYPE_TARGET_TYPE (type),
-			       valaddr + embedded_offset, len, 0,
+			       valaddr + embedded_offset, len, NULL, 0,
 			       options);
 	      i = len;
 	    }
@@ -306,7 +306,8 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
                                      &string_pos, &char_type, NULL))
 	    {
 	      len = extract_unsigned_integer (valaddr + embedded_offset + length_pos, length_size, byte_order);
-	      LA_PRINT_STRING (stream, char_type, valaddr + embedded_offset + string_pos, len, 0, options);
+	      LA_PRINT_STRING (stream, char_type, valaddr +
+			       embedded_offset + string_pos, len, NULL, 0, options);
 	    }
 	  else
 	    pascal_object_print_value_fields (type, valaddr + embedded_offset, address, stream,
diff --git gdb/python/py-lazy-string.c gdb/python/py-lazy-string.c
new file mode 100644
index 0000000..c7b91d0
--- /dev/null
+++ gdb/python/py-lazy-string.c
@@ -0,0 +1,181 @@
+/* Python interface to lazy strings.
+
+   Copyright (C) 2009 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include "defs.h"
+#include "python-internal.h"
+#include "charset.h"
+#include "value.h"
+
+typedef struct {
+  PyObject_HEAD
+  CORE_ADDR address;
+  char *encoding;
+  long length;
+  struct type *type;
+} lazy_string_object;
+
+static PyObject *
+stpy_get_address (PyObject *self, void *closure)
+{
+  lazy_string_object *self_string = (lazy_string_object *) self;
+  return PyLong_FromUnsignedLongLong (self_string->address);
+}
+
+static PyObject *
+stpy_get_encoding (PyObject *self, void *closure)
+{
+  lazy_string_object *self_string = (lazy_string_object *) self;
+
+  /* An encoding can be set to NULL by the user, so check before
+     attempting a Python FromString call.  */
+  if (self_string->encoding)
+    return PyString_FromString (self_string->encoding);
+
+  return NULL;
+}
+
+static PyObject *
+stpy_get_length (PyObject *self, void *closure)
+{
+  lazy_string_object *self_string = (lazy_string_object *) self;
+  return PyLong_FromLong (self_string->length);
+}
+
+PyObject *
+stpy_get_type (PyObject *self, void *closure)
+{
+  lazy_string_object *obj = (lazy_string_object *) self;
+  PyObject *type;
+
+  if (obj->type)
+    type = type_to_type_object (obj->type);
+  else
+    return NULL;
+
+  return type;
+}
+
+PyObject *
+create_lazy_string_object (CORE_ADDR address, long length,
+			   const char *encoding, struct type *type)
+{
+  lazy_string_object *str_obj = NULL;
+
+  str_obj = PyObject_New (lazy_string_object, &lazy_string_object_type);
+  if (!str_obj)
+    {
+      PyErr_SetString (PyExc_MemoryError,
+		       "Could not allocate lazy string object.");
+      return NULL;
+    }
+
+  if (address == 0)
+    {
+      PyErr_SetString (PyExc_MemoryError,
+		       "Cannot create a lazy string from a GDB-side string.");
+      return NULL;
+    }
+
+  str_obj->address = address;
+  str_obj->length = length;
+  if (encoding == NULL || strcmp (encoding, ""))
+    str_obj->encoding = NULL;
+  else
+    str_obj->encoding = xstrdup (encoding);
+  str_obj->type = type;
+  type_incref (type);
+  return (PyObject *) str_obj;
+}
+
+static PyObject *
+stpy_convert_to_value  (PyObject *self, PyObject *args)
+{
+  lazy_string_object *self_string = (lazy_string_object *) self;
+  struct value *val;
+
+  val = value_at_lazy (self_string->type, self_string->address);
+  return value_to_value_object (val);
+}
+
+static void
+stpy_dealloc (PyObject *self)
+{
+  xfree (((lazy_string_object *) self)->encoding);
+  type_decref (((lazy_string_object *) self)->type);
+}
+
+void
+gdbpy_initialize_lazy_string (void)
+{
+  if (PyType_Ready (&lazy_string_object_type) < 0)
+    return;
+
+  Py_INCREF (&lazy_string_object_type);
+}
+
+
+
+static PyMethodDef lazy_string_object_methods[] = {
+  { "value", stpy_convert_to_value, METH_NOARGS,
+    "Create a (lazy) value that contains a pointer to the string." },
+  {NULL}  /* Sentinel */
+};
+
+
+static PyGetSetDef lazy_string_object_getset[] = {
+  { "address", stpy_get_address, NULL, "Address of the string.", NULL },
+  { "encoding", stpy_get_encoding, NULL, "Encoding of the string.", NULL },
+  { "length", stpy_get_length, NULL, "Length of the string.", NULL },
+  { "type", stpy_get_type, NULL, "Type associated with the string.", NULL },
+  { NULL }  /* Sentinel */
+};
+
+PyTypeObject lazy_string_object_type = {
+  PyObject_HEAD_INIT (NULL)
+  0,				  /*ob_size*/
+  "gdb.LazyString",	          /*tp_name*/
+  sizeof (lazy_string_object),	  /*tp_basicsize*/
+  0,				  /*tp_itemsize*/
+  stpy_dealloc,			  /*tp_dealloc*/
+  0,				  /*tp_print*/
+  0,				  /*tp_getattr*/
+  0,				  /*tp_setattr*/
+  0,				  /*tp_compare*/
+  0,				  /*tp_repr*/
+  0,				  /*tp_as_number*/
+  0,				  /*tp_as_sequence*/
+  0,				  /*tp_as_mapping*/
+  0,				  /*tp_hash */
+  0,				  /*tp_call*/
+  0,				  /*tp_str*/
+  0,				  /*tp_getattro*/
+  0,				  /*tp_setattro*/
+  0,				  /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT,             /*tp_flags*/
+  "GDB lazy string object",	  /* tp_doc */
+  0,				  /* tp_traverse */
+  0,				  /* tp_clear */
+  0,				  /* tp_richcompare */
+  0,				  /* tp_weaklistoffset */
+  0,			          /* tp_iter */
+  0,				  /* tp_iternext */
+  lazy_string_object_methods,	  /* tp_methods */
+  0,				  /* tp_members */
+  lazy_string_object_getset	  /* tp_getset */
+};
diff --git gdb/python/py-prettyprint.c gdb/python/py-prettyprint.c
index a6348ba..911cdb9 100644
--- gdb/python/py-prettyprint.c
+++ gdb/python/py-prettyprint.c
@@ -122,6 +122,81 @@ find_pretty_printer (PyObject *value)
   return function;
 }
 
+/* Determine whether the printer object pointed to by OBJ is a
+   Python lazy string.  */
+int is_lazy_string (PyObject *result)
+{
+  return PyObject_TypeCheck (result, &lazy_string_object_type);
+}
+
+/* Extract and return the actual string from the lazy string object
+   STRING.  Addtionally, the string type is written to *STR_TYPE, the
+   string length is written to *LENGTH, and the string encoding is
+   written to *ENCODING.  On error, NULL is returned.  The caller is
+   responsible for freeing the returned buffer.  */
+gdb_byte *
+extract_lazy_string (PyObject *string, struct type
+		     **str_type, long *length,
+		     char **encoding)
+{
+  struct value *output;
+  int width;
+  int bytes_read;
+  gdb_byte *buffer = NULL;
+  int errcode;
+  struct gdbarch *gdbarch;
+  enum bfd_endian byte_order;
+  PyObject *py_len = NULL, *py_encoding = NULL;
+
+  output = convert_value_from_python (string);
+
+  /* Lazy strings are pointers, so point to the actual string
+     data.  */
+  if (TYPE_CODE (value_type (output)) == TYPE_CODE_PTR)
+    output = value_ind (output);
+
+  py_len = PyObject_GetAttrString (string, "length");
+  py_encoding = PyObject_GetAttrString (string, "encoding");
+
+  /* An NULL encoding is ok, but a NULL length is not.  */
+  if (!py_len)
+    goto error;
+
+  *length = PyLong_AsLong (py_len);
+
+  /* The user can supply NULL as an encoding, so check for NULL
+     first.  */
+  if (py_encoding)
+    *encoding = xstrdup (PyString_AsString (py_encoding));
+  else
+    *encoding = NULL;
+
+  *str_type = value_type (output);
+  gdbarch = get_type_arch (*str_type);
+  byte_order = gdbarch_byte_order (gdbarch);
+  width = TYPE_LENGTH (*str_type);
+
+  errcode = read_string (value_address (output), *length, width,
+			 *length, byte_order, &buffer,
+			 &bytes_read);
+  if (errcode)
+    goto error;
+
+  *length = bytes_read / width;
+  Py_DECREF (py_len);
+  Py_XDECREF (py_encoding);
+
+  return buffer;
+
+ error:
+  Py_XDECREF (py_encoding);
+  Py_XDECREF (py_len);
+  xfree (buffer);
+  *length = 0;
+  *str_type = NULL;
+  return NULL;
+}
+
 /* Pretty-print a single value, via the printer object PRINTER.
    If the function returns a string, a PyObject containing the string
    is returned.  Otherwise, if the function returns a value,
@@ -139,7 +214,7 @@ pretty_print_one_value (PyObject *printer, struct value **out_value)
       result = PyObject_CallMethodObjArgs (printer, gdbpy_to_string_cst, NULL);
       if (result)
 	{
-	  if (! gdbpy_is_string (result))
+	  if (! gdbpy_is_string (result) && ! is_lazy_string (result))
 	    {
 	      *out_value = convert_value_from_python (result);
  	      if (PyErr_Occurred ())
@@ -197,21 +272,46 @@ print_string_repr (PyObject *printer, const char *hint,
   py_str = pretty_print_one_value (printer, &replacement);
   if (py_str)
     {
-      PyObject *string = python_string_to_target_python_string (py_str);
-      if (string)
+      gdb_byte *output = NULL;
+      long length;
+      struct type *type;
+      char *encoding = NULL;
+      PyObject *string = NULL;
+
+      if (is_lazy_string (py_str))
+	  output = extract_lazy_string (py_str, &type, &length,
+					&encoding);
+      else
+	{
+	  string = python_string_to_target_python_string (py_str);
+	  if (string)
+	    {
+	      output = PyString_AsString (string);
+	      length = PyString_Size (string);
+	      type = builtin_type (gdbarch)->builtin_char;
+	    }
+	  else
+	    gdbpy_print_stack ();
+
+	}
+
+      if (output)
 	{
-	  gdb_byte *output = PyString_AsString (string);
-	  int len = PyString_Size (string);
-	  
 	  if (hint && !strcmp (hint, "string"))
-	    LA_PRINT_STRING (stream, builtin_type (gdbarch)->builtin_char,
-			     output, len, 0, options);
+	    LA_PRINT_STRING (stream, type, output, length, encoding,
+			     0, options);
 	  else
 	    fputs_filtered (output, stream);
-	  Py_DECREF (string);
 	}
       else
 	gdbpy_print_stack ();
+
+      if (string)
+	Py_DECREF (string);
+      else
+	xfree (output);
+
+      xfree (encoding);
       Py_DECREF (py_str);
     }
   else if (replacement)
@@ -423,15 +523,27 @@ print_children (PyObject *printer, const char *hint,
 	  fputs_filtered (" = ", stream);
 	}
 
-      if (gdbpy_is_string (py_v))
+      if (is_lazy_string (py_v) || gdbpy_is_string (py_v))
 	{
-	  char *text = python_string_to_host_string (py_v);
-	  if (! text)
+	  gdb_byte *output = NULL;
+	  struct type *type;
+	  long length;
+	  char *encoding = NULL;
+
+	  if (is_lazy_string (py_v))
+	    {
+	      output = extract_lazy_string (py_v, &type, &length, &encoding);
+	      xfree (encoding);
+	    }
+	  else
+	      output = python_string_to_host_string (py_v);
+
+	  if (!output)
 	    gdbpy_print_stack ();
 	  else
 	    {
-	      fputs_filtered (text, stream);
-	      xfree (text);
+	      fputs_filtered (output, stream);
+	      xfree (output);
 	    }
 	}
       else
diff --git gdb/python/py-value.c gdb/python/py-value.c
index 14efd79..9b762f3 100644
--- gdb/python/py-value.c
+++ gdb/python/py-value.c
@@ -224,6 +224,35 @@ valpy_get_type (PyObject *self, void *closure)
   return obj->type;
 }
 
+/* Implementation of gdb.Value.lazy_string ([encoding] [, length]) ->
+   string.  Return a PyObject representing a lazy_string_object type.
+   A lazy string is a pointer to a string with an optional encoding and
+   length.  If ENCODING is not given, encoding is set to NULL.  If an
+   ENCODING is provided the encoding parameter is set to ENCODING, but
+   the string is not encoded.  If LENGTH is provided then the length
+   parameter is set to LENGTH, otherwise length will be set to -1 (first
+   null of appropriate with).  */
+static PyObject *
+valpy_lazy_string (PyObject *self, PyObject *args, PyObject *kw)
+{
+  int length = -1;
+  struct value *value = ((value_object *) self)->value;
+  const char *user_encoding = NULL;
+  static char *keywords[] = { "encoding", "length", NULL };
+  PyObject *str_obj;
+
+  if (!PyArg_ParseTupleAndKeywords (args, kw, "|si", keywords,
+				    &user_encoding, &length))
+    return NULL;
+
+  str_obj = create_lazy_string_object (value_address (value), length,
+				       user_encoding, value_type (value));
+  if (str_obj)
+    Py_INCREF (str_obj);
+
+  return (PyObject *) str_obj;
+}
+
 /* Implementation of gdb.Value.string ([encoding] [, errors]
    [, length]) -> string.  Return Unicode string with value contents.
    If ENCODING is not given, the string is assumed to be encoded in
@@ -957,6 +986,13 @@ convert_value_from_python (PyObject *obj)
 	}
       else if (PyObject_TypeCheck (obj, &value_object_type))
 	value = value_copy (((value_object *) obj)->value);
+      else if (PyObject_TypeCheck (obj, &lazy_string_object_type))
+	{
+	  PyObject *result;
+	  PyObject *function = PyString_FromString ("value");
+	  result = PyObject_CallMethodObjArgs (obj, function,  NULL);
+	  value = value_copy (((value_object *) result)->value);
+	}
       else
 	PyErr_Format (PyExc_TypeError, _("Could not convert Python object: %s"),
 		      PyString_AsString (PyObject_Str (obj)));
@@ -1027,6 +1063,9 @@ static PyGetSetDef value_object_getset[] = {
 static PyMethodDef value_object_methods[] = {
   { "cast", valpy_cast, METH_VARARGS, "Cast the value to the supplied type." },
   { "dereference", valpy_dereference, METH_NOARGS, "Dereferences the value." },
+  { "lazy_string", (PyCFunction) valpy_lazy_string, METH_VARARGS | METH_KEYWORDS,
+    "lazy_string ([encoding]  [, length]) -> lazy_string\n\
+Return a lazy string representation of the value." },
   { "string", (PyCFunction) valpy_string, METH_VARARGS | METH_KEYWORDS,
     "string ([encoding] [, errors] [, length]) -> string\n\
 Return Unicode string representation of the value." },
diff --git gdb/python/python-internal.h gdb/python/python-internal.h
index 47662d9..160dc57 100644
--- gdb/python/python-internal.h
+++ gdb/python/python-internal.h
@@ -73,6 +73,7 @@ extern PyObject *gdb_module;
 extern PyTypeObject block_object_type;
 extern PyTypeObject value_object_type;
 extern PyTypeObject symbol_object_type;
+extern PyTypeObject lazy_string_object_type;
 
 /* Used in python-inferior.c.  */
 typedef struct
@@ -104,6 +105,9 @@ PyObject *value_to_value_object (struct value *v);
 PyObject *type_to_type_object (struct type *);
 PyObject *objfile_to_objfile_object (struct objfile *);
 PyObject *frame_info_to_frame_object (struct frame_info *frame);
+PyObject *create_lazy_string_object (CORE_ADDR address, long length,
+				     const char *encoding, struct type *type);
+
 thread_object *create_thread_object (struct thread_info *tp);
 thread_object *find_thread_object (ptid_t ptid);
 PyObject *find_inferior_object (int pid);
@@ -131,7 +135,7 @@ void gdbpy_initialize_objfile (void);
 void gdbpy_initialize_parameters (void);
 void gdbpy_initialize_thread (void);
 void gdbpy_initialize_inferior (void);
-
+void gdbpy_initialize_lazy_string (void);
 struct cleanup *make_cleanup_py_decref (PyObject *py);
 
 struct cleanup *ensure_python_env (struct gdbarch *gdbarch,
@@ -179,8 +183,12 @@ PyObject *python_string_to_target_python_string (PyObject *obj);
 char *python_string_to_host_string (PyObject *obj);
 PyObject *target_string_to_unicode (const gdb_byte *str, int length);
 int gdbpy_is_string (PyObject *obj);
-
+int is_lazy_string (PyObject *result);
+gdb_byte *extract_lazy_string (PyObject *string,
+			       struct type **str_type, long *length,
+			       char **encoding);
 int gdbpy_is_value_object (PyObject *obj);
+PyObject *execute_pretty_printer (PyObject *printer);
 
 /* Note that these are declared here, and not in python.h with the
    other pretty-printer functions, because they refer to PyObject.  */
@@ -190,6 +198,7 @@ PyObject *gdbpy_get_varobj_pretty_printer (struct value *value);
 PyObject *gdbpy_instantiate_printer (PyObject *cons, PyObject *value);
 char *gdbpy_get_display_hint (PyObject *printer);
 PyObject *gdbpy_default_visualizer (PyObject *self, PyObject *args);
+PyObject *execute_pretty_printer (PyObject *printer);
 
 extern PyObject *gdbpy_children_cst;
 extern PyObject *gdbpy_to_string_cst;
diff --git gdb/python/python.c gdb/python/python.c
index 707b700..6910ea1 100644
--- gdb/python/python.c
+++ gdb/python/python.c
@@ -916,6 +916,7 @@ Enables or disables auto-loading of Python code when an object is opened."),
   gdbpy_initialize_thread ();
   gdbpy_initialize_inferior ();
   gdbpy_initialize_events ();
+  gdbpy_initialize_lazy_string ();
 
   PyRun_SimpleString ("import gdb");
   PyRun_SimpleString ("gdb.pretty_printers = []");
diff --git gdb/scm-lang.c gdb/scm-lang.c
index de34894..23051cd 100644
--- gdb/scm-lang.c
+++ gdb/scm-lang.c
@@ -48,7 +48,7 @@ scm_printchar (int c, struct type *type, struct ui_file *stream)
 
 static void
 scm_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
-	      unsigned int length, int force_ellipses,
+	      unsigned int length, const char *encoding, int force_ellipses,
 	      const struct value_print_options *options)
 {
   fprintf_filtered (stream, "\"%s\"", string);
diff --git gdb/testsuite/gdb.python/py-mi.exp gdb/testsuite/gdb.python/py-mi.exp
index 30d6f32..d21daef 100644
--- gdb/testsuite/gdb.python/py-mi.exp
+++ gdb/testsuite/gdb.python/py-mi.exp
@@ -65,6 +65,10 @@ mi_create_varobj_checked string string_1 \
     "struct string_repr" \
     "create string_1 varobj"
 
+mi_create_varobj_checked lstring estring \
+    "struct lazystring" \
+    "create estring varobj"
+
 mi_gdb_test "-data-evaluate-expression \"string_1 = string_2\"" ".*" \
     "assign string_1 from string_2"
 
diff --git gdb/testsuite/gdb.python/py-prettyprint.c gdb/testsuite/gdb.python/py-prettyprint.c
index 7f16400..c087867 100644
--- gdb/testsuite/gdb.python/py-prettyprint.c
+++ gdb/testsuite/gdb.python/py-prettyprint.c
@@ -34,6 +34,10 @@ struct ns {
   int length;
 };
 
+struct lazystring {
+  const char *lazy_str;
+};
+
 #ifdef __cplusplus
 struct S : public s {
   int zs;
@@ -193,6 +197,7 @@ main ()
   /* Clearing by being `static' could invoke an other GDB C++ bug.  */
   struct nullstr nullstr;
 
+
   init_ss(&ss, 1, 2);
   init_ss(ssa+0, 3, 4);
   init_ss(ssa+1, 5, 6);
@@ -202,6 +207,9 @@ main ()
   ns.null_str = "embedded\0null\0string";
   ns.length = 20;
 
+  struct lazystring estring;
+  estring.lazy_str = "embedded x\201\202\203\204" ;
+
 #ifdef __cplusplus
   S cps;
 
diff --git gdb/testsuite/gdb.python/py-prettyprint.exp gdb/testsuite/gdb.python/py-prettyprint.exp
index 4de1620..8584598 100644
--- gdb/testsuite/gdb.python/py-prettyprint.exp
+++ gdb/testsuite/gdb.python/py-prettyprint.exp
@@ -96,7 +96,7 @@ proc run_lang_tests {lang} {
 
     gdb_test "print x" " = $hex \"this is x\""
     gdb_test "print cstring" " = $hex \"const string\""
-
+    gdb_test "print estring" "\"embedded x\\\\201\\\\202\\\\203\\\\204\""
     gdb_test "print c" " = container $hex \"container\" with 2 elements = {$nl *.0. = 23,$nl *.1. = 72$nl}"
 
     gdb_test "print nullstr" "RuntimeError: Error reading string from inferior.*"
diff --git gdb/testsuite/gdb.python/py-prettyprint.py gdb/testsuite/gdb.python/py-prettyprint.py
index 2f070d8..428f928 100644
--- gdb/testsuite/gdb.python/py-prettyprint.py
+++ gdb/testsuite/gdb.python/py-prettyprint.py
@@ -112,6 +112,18 @@ class pp_ns:
     def display_hint (self):
         return 'string'
 
+class pp_ls:
+    "Print a std::basic_string of some kind"
+
+    def __init__(self, val):
+        self.val = val
+
+    def to_string(self):
+        return self.val['lazy_str'].lazy_string()
+
+    def display_hint (self):
+        return 'string'
+
 class pp_outer:
     "Print struct outer"
 
@@ -184,6 +196,9 @@ def register_pretty_printers ():
     pretty_printers_dict[re.compile ('^struct ns$')]  = pp_ns
     pretty_printers_dict[re.compile ('^ns$')]  = pp_ns
 
+    pretty_printers_dict[re.compile ('^struct lazystring$')]  = pp_ls
+    pretty_printers_dict[re.compile ('^lazystring$')]  = pp_ls
+
     pretty_printers_dict[re.compile ('^struct outerstruct$')]  = pp_outer
     pretty_printers_dict[re.compile ('^outerstruct$')]  = pp_outer
 
diff --git gdb/testsuite/gdb.python/py-value.c gdb/testsuite/gdb.python/py-value.c
index 023d830..a7e7cd5 100644
--- gdb/testsuite/gdb.python/py-value.c
+++ gdb/testsuite/gdb.python/py-value.c
@@ -53,6 +53,8 @@ main (int argc, char *argv[])
   PTR x = &s;
   char st[17] = "divide et impera";
   char nullst[17] = "divide\0et\0impera";
+  const char *sptr = "pointer";
+
   int a[3] = {1,2,3};
   int *p = a;
   int i = 2;
diff --git gdb/testsuite/gdb.python/py-value.exp gdb/testsuite/gdb.python/py-value.exp
index b9f2c3c..a6debd5 100644
--- gdb/testsuite/gdb.python/py-value.exp
+++ gdb/testsuite/gdb.python/py-value.exp
@@ -255,6 +255,22 @@ proc test_value_in_inferior {} {
   gdb_test "python print repr(nullst)" "u'divide\\\\x00et'"
 }
 
+proc test_lazy_strings {} {
+
+  global hex
+
+  gdb_test "print sptr" "\"pointer\""
+  gdb_py_test_silent_cmd "python sptr = gdb.history (0)" "Get value from history" 1
+  gdb_py_test_silent_cmd "print /d  &sptr" "Get string address" 1
+  gdb_py_test_silent_cmd "python saddr = gdb.history (0)" "Get value from history" 1
+  gdb_py_test_silent_cmd "python lstr = sptr.lazy_string()" "Aquire lazy string" 1
+  gdb_test "python print lstr.address == saddr" "True." "Test address equality"
+  gdb_test "python print lstr.type" "const char \*." "Test type name equality"
+  gdb_test "python print sptr.type" "const char \*." "Test type name equality"
+  gdb_test "python print lstr.value()" "\"pointer\"" "Test value fetch"
+}
+
+
 # A few objfile tests.
 proc test_objfiles {} {
     gdb_test "python\nok=False\nfor file in gdb.objfiles():\n  if 'py-value' in file.filename:\n    ok=True\nprint ok\nend" "True"
@@ -406,6 +422,7 @@ if ![runto_main] then {
 }
 
 test_value_in_inferior
+test_lazy_strings
 test_value_after_death
 test_cast_regression
 
diff --git gdb/valprint.c gdb/valprint.c
index cf35bf0..b81890d 100644
--- gdb/valprint.c
+++ gdb/valprint.c
@@ -1452,7 +1452,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)
diff --git gdb/varobj.c gdb/varobj.c
index 7235635..052b3fe 100644
--- gdb/varobj.c
+++ gdb/varobj.c
@@ -2453,11 +2453,15 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
   struct cleanup *old_chain;
   gdb_byte *thevalue = NULL;
   struct value_print_options opts;
-  int len = 0;
+  struct type *type = NULL;
+  long len = 0;
+  char *encoding = NULL;
+  struct gdbarch *gdbarch = NULL;
 
   if (value == NULL)
     return NULL;
 
+  gdbarch = get_type_arch (value_type (value));
 #if HAVE_PYTHON
   {
     struct cleanup *back_to = varobj_ensure_python_env (var);
@@ -2484,25 +2488,32 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
 		  string_print = 1;
 		xfree (hint);
 	      }
-
 	    output = apply_varobj_pretty_printer (value_formatter,
 						  &replacement);
 	    if (output)
 	      {
-		PyObject *py_str
-		  = python_string_to_target_python_string (output);
-		if (py_str)
+		if (is_lazy_string (output))
+		    thevalue = extract_lazy_string (output, &type,
+						    &len, &encoding);
+		else
 		  {
-		    char *s = PyString_AsString (py_str);
-		    len = PyString_Size (py_str);
-		    thevalue = xmemdup (s, len + 1, len + 1);
-		    Py_DECREF (py_str);
+		    PyObject *py_str
+		      = python_string_to_target_python_string (output);
+		    if (py_str)
+		      {
+			char *s = PyString_AsString (py_str);
+			len = PyString_Size (py_str);
+			thevalue = xmemdup (s, len + 1, len + 1);
+			type = builtin_type (gdbarch)->builtin_char;
+			Py_DECREF (py_str);
+		      }
 		  }
 		Py_DECREF (output);
 	      }
 	    if (thevalue && !string_print)
 	      {
 		do_cleanups (back_to);
+		xfree (encoding);
 		return thevalue;
 	      }
 	    if (replacement)
@@ -2521,10 +2532,10 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
   opts.raw = 1;
   if (thevalue)
     {
-      struct gdbarch *gdbarch = get_type_arch (value_type (value));
       make_cleanup (xfree, thevalue);
-      LA_PRINT_STRING (stb, builtin_type (gdbarch)->builtin_char,
-		       thevalue, len, 0, &opts);
+      make_cleanup (xfree, encoding);
+      LA_PRINT_STRING (stb, type,
+		       thevalue, len, encoding, 0, &opts);
     }
   else


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]