diff options
Diffstat (limited to 'gdb/varobj.c')
-rw-r--r-- | gdb/varobj.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/gdb/varobj.c b/gdb/varobj.c index dac0413..5d69743 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -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); |