2009-07-10 Phil Muldoon <pmuldoon@redhat.com>
[deliverable/binutils-gdb.git] / gdb / varobj.c
index dac0413ecb98c4d027e63412a53d08a097b96020..5d6974306c753f8958c4a99d86f3f229259f6ce5 100644 (file)
@@ -2221,8 +2221,9 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
   long dummy;
   struct ui_file *stb;
   struct cleanup *old_chain;
-  char *thevalue = NULL;
+  gdb_byte *thevalue = NULL;
   struct value_print_options opts;
+  int len = 0;
 
   if (value == NULL)
     return NULL;
@@ -2238,6 +2239,7 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
        char *hint;
        struct value *replacement;
        int string_print = 0;
+       PyObject *output = NULL;
 
        hint = gdbpy_get_display_hint (value_formatter);
        if (hint)
@@ -2247,8 +2249,20 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
            xfree (hint);
          }
 
-       thevalue = apply_varobj_pretty_printer (value_formatter,
-                                               &replacement);
+       output = apply_varobj_pretty_printer (value_formatter,
+                                             &replacement);
+       if (output)
+         {
+           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);
+               Py_DECREF (py_str);
+             }
+           Py_DECREF (output);
+         }
        if (thevalue && !string_print)
          {
            do_cleanups (back_to);
@@ -2272,8 +2286,7 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
       struct gdbarch *gdbarch = get_type_arch (value_type (value));
       make_cleanup (xfree, thevalue);
       LA_PRINT_STRING (stb, builtin_type (gdbarch)->builtin_char,
-                      (gdb_byte *) thevalue, strlen (thevalue),
-                      0, &opts);
+                      thevalue, len, 0, &opts);
     }
   else
     common_val_print (value, stb, 0, &opts, current_language);
This page took 0.02554 seconds and 4 git commands to generate.