public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-pmuldoon-pretty-printers-lookup: Zero test regression commit with CLI and MI tests. Convert varobj/MI to use new pretty-printers API.
@ 2009-02-12 15:31 pmuldoon
  0 siblings, 0 replies; only message in thread
From: pmuldoon @ 2009-02-12 15:31 UTC (permalink / raw)
  To: archer-commits

The branch, archer-pmuldoon-pretty-printers-lookup has been updated
       via  4e37d7f4e1eaa31cac8ce49cf5c297b030b0026c (commit)
      from  6f040543f35c008fc817c31fe4ea2176b72b5b53 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 4e37d7f4e1eaa31cac8ce49cf5c297b030b0026c
Author: Phil Muldoon <pmuldoon@redhat.com>
Date:   Thu Feb 12 15:30:20 2009 +0000

    Zero test regression commit with CLI and MI tests. Convert varobj/MI to use new pretty-printers API.

-----------------------------------------------------------------------

Summary of changes:
 gdb/varobj.c |   79 +++++++++++++++++++++------------------------------------
 1 files changed, 29 insertions(+), 50 deletions(-)

First 500 lines of diff:
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 034e9d2..f21b708 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -181,10 +181,6 @@ struct varobj
   int from;
   int to;
 
-  /* If NULL, no pretty printer is installed.  If not NULL, the
-     constructor to call to get a pretty-printer object.  */
-  PyObject *constructor;
-
   /* The pretty-printer that has been constructed.  If NULL, then a
      new printer object is needed, and one will be constructed.  */
   PyObject *pretty_printer;
@@ -713,23 +709,16 @@ varobj_delete (struct varobj *var, char ***dellist, int only_children)
 
 /* Instantiate a pretty-printer for a given value.  */
 static PyObject *
-instantiate_pretty_printer (struct varobj *var, struct value *value)
+instantiate_pretty_printer (PyObject *constructor, struct value *value)
 {
 #if HAVE_PYTHON
-  if (var->constructor)
-    {
-      PyObject *printer = gdbpy_instantiate_printer (var->constructor, value);
-      if (printer == Py_None)
-	{
-	  Py_DECREF (printer);
-	  printer = NULL;
-	}
-      return printer;
-    }
+  PyObject *printer = gdbpy_instantiate_printer (constructor, value);
+  return printer;
 #endif
   return NULL;
 }
 
+
 /* Set/Get variable object display format */
 
 enum varobj_display_formats
@@ -1224,7 +1213,7 @@ install_new_value (struct varobj *var, struct value *value, int initial)
   /* If the type has custom visualizer, we consider it to be always
      changeable. FIXME: need to make sure this behaviour will not
      mess up read-sensitive values.  */
-  if (var->constructor)
+  if (var->pretty_printer)
     changeable = 1;
 
   need_to_fetch = changeable;
@@ -1278,20 +1267,6 @@ install_new_value (struct varobj *var, struct value *value, int initial)
 	}
     }
 
-#if HAVE_PYTHON
-  {
-    PyGILState_STATE state = PyGILState_Ensure ();
-    if (var->pretty_printer)
-      {
-	Py_DECREF (var->pretty_printer);
-      }
-    if (value)
-      var->pretty_printer = instantiate_pretty_printer (var, value);
-    else
-      var->pretty_printer = NULL;
-    PyGILState_Release (state);
-  }
-#endif
 
   /* Below, we'll be comparing string rendering of old and new
      values.  Don't get string rendering if the value is
@@ -1408,11 +1383,9 @@ install_visualizer (struct varobj *var, PyObject *visualizer)
   varobj_delete (var, NULL, 1 /* children only */);
   var->num_children = -1;
 
-  Py_XDECREF (var->constructor);
-  var->constructor = visualizer;
-
   Py_XDECREF (var->pretty_printer);
-  var->pretty_printer = NULL;
+  var->pretty_printer = visualizer;
+
 
   install_new_value (var, var->value, 1);
 
@@ -1433,21 +1406,21 @@ install_default_visualizer (struct varobj *var)
 #if HAVE_PYTHON
   struct cleanup *cleanup;
   PyGILState_STATE state;
-  PyObject *constructor = NULL;
+  PyObject *pretty_printer = NULL;
 
   state = PyGILState_Ensure ();
   cleanup = make_cleanup_py_restore_gil (&state);
 
   if (var->value)
-    constructor = gdbpy_get_varobj_pretty_printer (var->value);
+      pretty_printer = gdbpy_get_varobj_pretty_printer (var->value);
 
-  if (constructor == Py_None)
+  if (pretty_printer == Py_None)
     {
-      Py_DECREF (constructor);
-      constructor = NULL;
+      Py_DECREF (pretty_printer);
+      pretty_printer = NULL;
     }
   
-  install_visualizer (var, constructor);
+  install_visualizer (var, pretty_printer);
 
   do_cleanups (cleanup);
 #else
@@ -1459,34 +1432,40 @@ void
 varobj_set_visualizer (struct varobj *var, const char *visualizer)
 {
 #if HAVE_PYTHON
-  PyObject *mainmod, *globals, *constructor;
+  PyObject *mainmod, *globals, *pretty_printer, *constructor;
   struct cleanup *back_to;
   PyGILState_STATE state;
 
   state = PyGILState_Ensure ();
   back_to = make_cleanup_py_restore_gil (&state);
-
   mainmod = PyImport_AddModule ("__main__");
   globals = PyModule_GetDict (mainmod);
   Py_INCREF (globals);
   make_cleanup_py_decref (globals);
 
   constructor = PyRun_String (visualizer, Py_eval_input, globals, globals);
+  
+  // Do not instantiate NoneType.
+  if (constructor == Py_None)
+    pretty_printer = Py_None;
+  else
+    pretty_printer = instantiate_pretty_printer(constructor, var->value);
 
-  if (! constructor)
+  if (! pretty_printer)
     {
       gdbpy_print_stack ();
       error ("Could not evaluate visualizer expression: %s", visualizer);
     }
 
-  if (constructor == Py_None)
+  if (pretty_printer == Py_None)
     {
-      Py_DECREF (constructor);
-      constructor = NULL;
+      Py_DECREF (pretty_printer);
+      pretty_printer = NULL;
     }
 
-  install_visualizer (var, constructor);
+  install_visualizer (var, pretty_printer);
 
+  Py_DECREF(constructor);
   do_cleanups (back_to);
 #else
   error ("Python support required");
@@ -1680,6 +1659,8 @@ delete_variable (struct cpstack **resultp, struct varobj *var,
   return delcount;
 }
 
+
+
 /* Delete the variable object VAR and its children */
 /* IMPORTANT NOTE: If we delete a variable which is a child
    and the parent is not removed we dump core.  It must be always
@@ -1924,7 +1905,6 @@ new_variable (void)
   var->children_requested = 0;
   var->from = -1;
   var->to = -1;
-  var->constructor = 0;
   var->pretty_printer = 0;
 
   return var;
@@ -1961,7 +1941,6 @@ free_variable (struct varobj *var)
 #if HAVE_PYTHON
   {
     PyGILState_STATE state = PyGILState_Ensure ();
-    Py_XDECREF (var->constructor);
     Py_XDECREF (var->pretty_printer);
     PyGILState_Release (state);
   }
@@ -2760,7 +2739,7 @@ c_value_of_variable (struct varobj *var, enum varobj_display_formats format)
 
   /* If we have a custom formatter, return whatever string it has
      produced.  */
-  if (var->constructor && var->print_value)
+  if (var->pretty_printer && var->print_value)
     return xstrdup (var->print_value);
   
   /* Strip top-level references. */


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-02-12 15:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-12 15:31 [SCM] archer-pmuldoon-pretty-printers-lookup: Zero test regression commit with CLI and MI tests. Convert varobj/MI to use new pretty-printers API pmuldoon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).