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]

Re: [python][patch] Preserve string length, and embedded-nulls in pretty-print string emission.


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


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