[python][patch] Preserve string length, and embedded-nulls in pretty-print string emission.
Tom Tromey
tromey@redhat.com
Thu Jun 18 20:21:00 GMT 2009
Oops, I hit send too soon on that last note.
This is the same, but with more comments.
Phil> + PyObject *string = python_string_to_target_python_string (py_str);
Phil> + if (string)
Phil> + {
Phil> + gdb_byte *output = PyString_AsString (string);
Phil> + int len = PyString_Size (string) + 1;
Phil> +
Phil> + if (hint && !strcmp (hint, "string"))
Phil> + LA_PRINT_STRING (stream, output,
Phil> + len, 1, 0, options);
Phil> + else
Phil> + fputs_filtered (output, stream);
Phil> + Py_DECREF (string);
Phil> + }
This needs an 'else' case to call gdbpy_print_stack.
Also, why the '+ 1' in the computation of 'len'?
Won't this make LA_PRINT_STRING print one too many bytes?
Phil> +PyObject *
Phil> apply_varobj_pretty_printer (PyObject *printer_obj,
Phil> struct value **replacement)
Phil> {
[...]
Phil> + if (replacement == NULL && py_str == NULL)
'replacement' cannot be NULL here.
You want '*replacement'.
Phil> @@ -2274,15 +2276,27 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
[...]
Phil> + char *s = PyString_AsString (py_str);
Phil> + len = PyString_Size (py_str) + 1;
Phil> + thevalue = xmemdup (s, len, len);
Here you do want to copy size+1 bytes, but...
Phil> + LA_PRINT_STRING (stb, thevalue, len, 1, 0, &opts);
... here I think you wan to just print size bytes.
Tom
More information about the Archer
mailing list