This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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]

[PATCH] varobj.c: Report changed values that use a pretty-printer


I've had a play with pretty printing in MI and it looks really neat.  I've
got Emacs to display map objects as described on Trom Tromey's page:

http://tromey.com/blog/?p=546

There have been a few problems, notably changed values don't seem to get
reported by -var-update.  The patch below seems to fix this.  I think the
expectation might have been that continue would break out of the if statement
when v->children_requested was false, but it breaks out of the whole loop so
the varobj_update_result, r, never gets pushed on to result, even when
r.changed is 1.

When children are added the usual syntax of -var-update breaks and I get
something like:

"^done,changelist=[{name=\"var5\",value=\"std::tr1::unordered_map with 2 elements\",in_scope=\"true\",type_changed=\"false\",displayhint=\"map\",children=[{name=\"var5.[0]\",exp=\"[0]\",numchild=\"0\",value=\"1\",type=\"const int\",thread-id=\"1\"},...

e.g displayhint and children fields which aren't usually there and all
children including those which have _not_ changed get reported.  I think the
normal syntax could be used and just the new children reported and the front
end could be made handle this.

The scope of this work seems enormous as it opens the possiblity of
formatting the watch expressions of all STL containers (as, ISTR, is already
done in Totalview).  Of course the amount of work it entails is probably
enormous too and the problem, as always, is finding someone to do it.  GSoC
2009 worked well with Emacs and Dmitry.  I know it's a long way off, but
perhaps we could think about planning something for 2010.

-- 
Nick                                           http://www.inet.net.nz/~nickrob


2009-09-03  Nick Roberts  <nickrob@snap.net.nz>

	* varobj.c (varobj_update): Ensure that changed values
	are reported when using a pretty-printer.


*** varobj.c	28 Aug 2009 15:11:29 +1200	1.147
--- varobj.c	03 Sep 2009 02:47:39 +1200	
*************** VEC(varobj_update_result) *varobj_update
*** 1545,1581 ****
  	  int i, children_changed;
  	  varobj_p tmp;
  
! 	  if (!v->children_requested)
! 	    continue;
! 
! 	  if (v->frozen)
! 	    continue;
! 
! 	  /* If update_dynamic_varobj_children returns 0, then we have
! 	     a non-conforming pretty-printer, so we skip it.  */
! 	  if (update_dynamic_varobj_children (v, &changed, &new_and_unchanged,
! 					      &children_changed))
  	    {
! 	      if (children_changed)
! 		r.children_changed = 1;
! 	      for (i = 0; VEC_iterate (varobj_p, changed, i, tmp); ++i)
! 		{
! 		  varobj_update_result r = {tmp};
! 		  r.changed = 1;
! 		  r.value_installed = 1;
! 		  VEC_safe_push (varobj_update_result, stack, &r);
! 		}
! 	      for (i = 0;
! 		   VEC_iterate (varobj_p, new_and_unchanged, i, tmp);
! 		   ++i)
  		{
! 		  varobj_update_result r = {tmp};
! 		  r.value_installed = 1;
! 		  VEC_safe_push (varobj_update_result, stack, &r);
  		}
- 	      if (r.changed || r.children_changed)
- 		VEC_safe_push (varobj_update_result, result, &r);
- 	      continue;
  	    }
  	}
  
--- 1545,1578 ----
  	  int i, children_changed;
  	  varobj_p tmp;
  
! 	  if (v->children_requested && !v->frozen)
  	    {
! 	      /* If update_dynamic_varobj_children returns 0, then we have
! 		 a non-conforming pretty-printer, so we skip it.  */
! 	      if (update_dynamic_varobj_children (v, &changed, &new_and_unchanged,
! 						  &children_changed))
  		{
! 		  if (children_changed)
! 		    r.children_changed = 1;
! 		  for (i = 0; VEC_iterate (varobj_p, changed, i, tmp); ++i)
! 		    {
! 		      varobj_update_result r = {tmp};
! 		      r.changed = 1;
! 		      r.value_installed = 1;
! 		      VEC_safe_push (varobj_update_result, stack, &r);
! 		    }
! 		  for (i = 0;
! 		       VEC_iterate (varobj_p, new_and_unchanged, i, tmp);
! 		       ++i)
! 		    {
! 		      varobj_update_result r = {tmp};
! 		      r.value_installed = 1;
! 		      VEC_safe_push (varobj_update_result, stack, &r);
! 		    }
! 		  if (r.changed || r.children_changed)
! 		    VEC_safe_push (varobj_update_result, result, &r);
! 		  continue;
  		}
  	    }
  	}
  


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