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]

[python] varobjs and the "string" display hint


This updates the varobj code to respect the "string" display hint.

I'm not completely sure we want this, but I lean towards "we do".

Tom

2008-12-15  Tom Tromey  <tromey@redhat.com>

	* varobj.c (value_get_print_value): Use LA_PRINT_STRING for
	"string" printers.

diff --git a/gdb/varobj.c b/gdb/varobj.c
index d98759f..b33229f 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -2240,7 +2240,7 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
   long dummy;
   struct ui_file *stb;
   struct cleanup *old_chain;
-  char *thevalue;
+  char *thevalue = NULL;
   struct value_print_options opts;
 
   if (value == NULL)
@@ -2252,10 +2252,21 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
     if (value_formatter && PyObject_HasAttr (value_formatter,
 					     gdbpy_to_string_cst))
       {
+	char *hint;
 	struct value *replacement;
+	int string_print = 0;
+
+	hint = gdbpy_get_display_hint (value_formatter);
+	if (hint)
+	  {
+	    if (!strcmp (hint, "string"))
+	      string_print = 1;
+	    xfree (hint);
+	  }
+
 	thevalue = apply_varobj_pretty_printer (value_formatter, value,
 						&replacement);
-	if (thevalue)
+	if (thevalue && !string_print)
 	  {
 	    PyGILState_Release (state);
 	    return thevalue;
@@ -2273,7 +2284,14 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
   get_formatted_print_options (&opts, format_code[(int) format]);
   opts.deref_ref = 0;
   opts.raw = 1;
-  common_val_print (value, stb, 0, &opts, current_language);
+  if (thevalue)
+    {
+      make_cleanup (xfree, thevalue);
+      LA_PRINT_STRING (stb, (gdb_byte *) thevalue, strlen (thevalue),
+		       1, 0, &opts);
+    }
+  else
+    common_val_print (value, stb, 0, &opts, current_language);
   thevalue = ui_file_xstrdup (stb, &dummy);
 
   do_cleanups (old_chain);


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