[Monodevelop-patches-list] r2454 - in trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn: . Gui Visualizers

Chris Toshok toshok at mono-cvs.ximian.com
Fri Apr 15 01:28:01 EDT 2005


Author: toshok
Date: 2005-04-15 01:28:01 -0400 (Fri, 15 Apr 2005)
New Revision: 2454

Added:
   trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Visualizers/TargetMemoryStream.cs
Modified:
   trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/ChangeLog
   trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/DebugAttributeHandler.cs
   trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/DebuggingService.cs
   trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Gui/LocalsPad.cs
   trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Visualizers/Makefile.am
   trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Visualizers/TargetObjectProvider.cs
Log:
2005-04-14  Chris Toshok  <toshok at ximian.com>

	* Visualizers/TargetObjectProvider.cs
	(TargetObjectProvider.GetData): implement, using
	TargetMemoryStream.

	* Visualizers/Makefile.am (DLLS): remove the -pkg:gtk-sharp-2.0
	(FILES): add TargetMemoryStream.cs
	(install-data-local): add the beginnings of an install target.  we
	still need a strong name.

	* Visualizers/TargetMemoryStream.cs: new file.  a proxy to manage
	a debugee-side MemoryStream for use in serializing objects.

	* Gui/LocalsPad.cs (LocalsPad.InsertStrucChildren): if we're
	inserting a proxy's attribute, return afterward instead of falling
	through to the default behavior.
	(LocalsPad.VisualizerActivate): force the debugee to load the
	assembly containing the source type.
	(LocalsPad.TreePopup): populate the Visualizers submenu with all
	applicable visualizers.
	(LocalsPad.GetDebuggerVisualizerAttributes): return an array of
	attributes.

	* DebugAttributeHandler.cs: change things around so multiple
	Visualizer attributes can be associated with a given type.

	* DebuggingService.cs (DebuggingService.LoadLibrary): new
	function.



Modified: trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/ChangeLog	2005-04-14 12:30:23 UTC (rev 2453)
+++ trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/ChangeLog	2005-04-15 05:28:01 UTC (rev 2454)
@@ -1,3 +1,33 @@
+2005-04-14  Chris Toshok  <toshok at ximian.com>
+
+	* Visualizers/TargetObjectProvider.cs
+	(TargetObjectProvider.GetData): implement, using
+	TargetMemoryStream.
+
+	* Visualizers/Makefile.am (DLLS): remove the -pkg:gtk-sharp-2.0
+	(FILES): add TargetMemoryStream.cs
+	(install-data-local): add the beginnings of an install target.  we
+	still need a strong name.
+
+	* Visualizers/TargetMemoryStream.cs: new file.  a proxy to manage
+	a debugee-side MemoryStream for use in serializing objects.
+
+	* Gui/LocalsPad.cs (LocalsPad.InsertStrucChildren): if we're
+	inserting a proxy's attribute, return afterward instead of falling
+	through to the default behavior.
+	(LocalsPad.VisualizerActivate): force the debugee to load the
+	assembly containing the source type.
+	(LocalsPad.TreePopup): populate the Visualizers submenu with all
+	applicable visualizers.
+	(LocalsPad.GetDebuggerVisualizerAttributes): return an array of
+	attributes.
+
+	* DebugAttributeHandler.cs: change things around so multiple
+	Visualizer attributes can be associated with a given type.
+
+	* DebuggingService.cs (DebuggingService.LoadLibrary): new
+	function.
+
 2005-04-06  Chris Toshok  <toshok at ximian.com>
 
 	* Gui/StackTracePad.cs (StackTracePad.OnStoppedEvent): set

Modified: trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/DebugAttributeHandler.cs
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/DebugAttributeHandler.cs	2005-04-14 12:30:23 UTC (rev 2453)
+++ trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/DebugAttributeHandler.cs	2005-04-15 05:28:01 UTC (rev 2454)
@@ -17,26 +17,27 @@
 using AST = ICSharpCode.SharpRefactory.Parser.AST;
 
 namespace MonoDevelop.Debugger {
+
 	public class DebugAttributeHandler
 	{
-
 		public void Rescan () {
 
 		  display_by_type_name = new Hashtable ();
 		  proxy_by_type_name = new Hashtable ();
+		  visualizers_by_type_name = new Hashtable ();
 
-			DirectoryInfo info = new DirectoryInfo ("/usr/lib/monodevelop/Debugger/");
+			DirectoryInfo info = new DirectoryInfo ("/opt/mono/lib/monodevelop/Debugger/");
 			FileInfo[] dlls = info.GetFiles ("*.dll");
 
 			foreach (FileInfo dll_info in dlls) {
 				Assembly a = Assembly.LoadFile (dll_info.FullName);
 		
-				DebuggerDisplayAttribute[] display_attrs = (DebuggerDisplayAttribute[])a.GetCustomAttributes (typeof (DebuggerDisplayAttribute),
-															      false);
-				DebuggerTypeProxyAttribute[] proxy_attrs = (DebuggerTypeProxyAttribute[])a.GetCustomAttributes (typeof (DebuggerTypeProxyAttribute),
-																false);
-				if (display_attrs == null && proxy_attrs == null)
-					continue;
+				DebuggerDisplayAttribute[] display_attrs = (DebuggerDisplayAttribute[])a.GetCustomAttributes(typeof (DebuggerDisplayAttribute),
+															     false);
+				DebuggerTypeProxyAttribute[] proxy_attrs = (DebuggerTypeProxyAttribute[])a.GetCustomAttributes(typeof (DebuggerTypeProxyAttribute),
+															       false);
+				DebuggerVisualizerAttribute[] viz_attrs = (DebuggerVisualizerAttribute[])a.GetCustomAttributes(typeof (DebuggerVisualizerAttribute),
+															       false);
 
 				foreach (DebuggerDisplayAttribute da in display_attrs) {
 					if (display_by_type_name.ContainsKey (da.TargetTypeName))
@@ -51,6 +52,18 @@
 
 					proxy_by_type_name.Add (pa.TargetTypeName, pa);
 				}
+
+				foreach (DebuggerVisualizerAttribute va in viz_attrs) {
+					ArrayList vas = (ArrayList)visualizers_by_type_name[va.TargetTypeName];
+					if (vas == null) {
+						vas = new ArrayList ();
+						visualizers_by_type_name.Add (va.TargetTypeName, vas);
+					}
+
+					vas.Add (va);
+
+					Console.WriteLine ("VISUALIZER ATTIRBUTE for type {0}", va.TargetTypeName);
+				}
 			}
 		}
 
@@ -136,6 +149,28 @@
 			return sb.ToString ();
 		}
 
+		public DebuggerVisualizerAttribute[] GetDebuggerVisualizerAttributes (Type t)
+		{
+			DebuggerVisualizerAttribute[] vas;
+
+	  		object[] attrs = t.GetCustomAttributes (typeof (DebuggerVisualizerAttribute), false);
+
+			if (attrs != null && attrs.Length > 0) {
+				vas = new DebuggerVisualizerAttribute[attrs.Length];
+				attrs.CopyTo (vas, 0);
+				return vas;
+			}
+
+			ArrayList varray = (ArrayList)visualizers_by_type_name[t.AssemblyQualifiedName];
+			if (varray == null)
+				return null;
+
+			vas = new DebuggerVisualizerAttribute[varray.Count];
+			varray.CopyTo (vas);
+
+			return vas;
+		}
+
 		public DebuggerTypeProxyAttribute GetDebuggerTypeProxyAttribute (Type t)
 		{
 	  		object[] attrs = t.GetCustomAttributes (typeof (DebuggerTypeProxyAttribute), false);
@@ -143,7 +178,7 @@
 			if (attrs != null && attrs.Length > 0)
 				return (DebuggerTypeProxyAttribute)attrs[0];
 
-			return proxy_by_type_name[t.Name] as DebuggerTypeProxyAttribute;
+			return proxy_by_type_name[t.AssemblyQualifiedName] as DebuggerTypeProxyAttribute;
 		}
 
 		public DebuggerDisplayAttribute GetDebuggerDisplayAttribute (Type t)
@@ -153,12 +188,13 @@
 			if (attrs != null && attrs.Length > 0)
 				return (DebuggerDisplayAttribute)attrs[0];
 
-			return display_by_type_name[t.Name] as DebuggerDisplayAttribute;
+			return display_by_type_name[t.AssemblyQualifiedName] as DebuggerDisplayAttribute;
 		
 		}
 
 		Hashtable display_by_type_name;
 		Hashtable proxy_by_type_name;
+		Hashtable visualizers_by_type_name;
 	}
 }
 #endif

Modified: trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/DebuggingService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/DebuggingService.cs	2005-04-14 12:30:23 UTC (rev 2453)
+++ trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/DebuggingService.cs	2005-04-15 05:28:01 UTC (rev 2454)
@@ -99,6 +99,11 @@
 			}
 		}
 
+		public void LoadLibrary (Process thread, string assembly)
+		{
+			backend.LoadLibrary (thread, assembly);
+		}
+
 		private Breakpoint CreateBreakpoint (string name)
 		{
 			SimpleBreakpoint point = new SimpleBreakpoint (name);

Modified: trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Gui/LocalsPad.cs
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Gui/LocalsPad.cs	2005-04-14 12:30:23 UTC (rev 2453)
+++ trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Gui/LocalsPad.cs	2005-04-15 05:28:01 UTC (rev 2454)
@@ -7,13 +7,13 @@
 using MonoDevelop.Gui;
 using MonoDevelop.Services;
 using Stock = MonoDevelop.Gui.Stock;
+
+using Mono.Debugger;
+using Mono.Debugger.Languages;
 #if NET_2_0
 using MonoDevelop.DebuggerVisualizers;
 #endif
 
-using Mono.Debugger;
-using Mono.Debugger.Languages;
-
 namespace MonoDevelop.Debugger
 {
 	public class LocalsPad : Gtk.ScrolledWindow, IPadContent
@@ -86,7 +86,6 @@
 
 #if NET_2_0
 			tree.PopupMenu += new PopupMenuHandler (TreePopup);
-                        tree.ButtonReleaseEvent += new Gtk.ButtonReleaseEventHandler(OnButtonRelease);
 #endif
 
 			Add (tree);
@@ -131,7 +130,7 @@
 					// don't display it at all
 					continue;
 				case DebuggerBrowsableState.Collapsed:
-					// the default behavior for the debugger (c&p from above)
+					// the default behavior for the debugger (c&p from the battr == null branch at the bottom of this function)
 					iter = store.Append (parent);
 					AddObject (member.Name, icon_name, is_field ? sobj.GetField (member.Index) : sobj.GetProperty (member.Index),
 						   iter);
@@ -258,6 +257,8 @@
 					if (InsertProxyChildren (dbgr, pattr, parent, sobj))
 						inserted = true;
 				}
+
+				return inserted;
 			}
 #endif
 
@@ -303,12 +304,6 @@
 		}
 
 #if NET_2_0
-		void OnButtonRelease(object sender, Gtk.ButtonReleaseEventArgs args)
-		{
-	  		if (args.Event.Button == 3)
-				TreePopup (null, new PopupMenuArgs ());
-		}
-
 		void VisualizerActivate (object sender, EventArgs args)
 		{
 			DebuggingService dbgr = (DebuggingService)Runtime.DebuggingService;
@@ -336,32 +331,30 @@
 			// visualizer is loaded into the debuggee.
 			Type sourceType = Type.GetType (va_attr.VisualizerObjectSourceTypeName);
 
-			//			dbgr.LoadLibrary (dbgr.MainThread, sourceType.Assembly.Location);
+			dbgr.LoadLibrary (dbgr.MainThread, sourceType.Assembly.Location);
 
 			ITargetObject tobj = (ITargetObject)iters [selected_iter];
-			visualizer.Show (null, new TargetObjectProvider (tobj, sourceType.FullName));
+			visualizer.Show (null, new TargetObjectProvider (tobj, dbgr.MainThread, sourceType.FullName));
 		}
 
-		void TreePopup (object o, PopupMenuArgs args)
+		Gtk.Menu CreatePopup ()
 		{
 			DebuggingService dbgr = (DebuggingService)Runtime.DebuggingService;
 			TreeModel model;
 			TreeIter selected_iter;
 			ITargetObject obj;
-			DebuggerVisualizerAttribute va;
+			DebuggerVisualizerAttribute[] vas;
 			Gtk.Menu popup_menu;
 
-			Console.WriteLine ("TreePopup");
-
 			if (!tree.Selection.GetSelected (out model, out selected_iter))
-				return;
+				return null;
 
 			popup_menu = new Gtk.Menu ();
 
 			obj = (ITargetObject)iters [selected_iter];
-			va = GetDebuggerVisualizerAttribute (dbgr, obj);
+			vas = GetDebuggerVisualizerAttributes (dbgr, obj);
 	    
-			if (va == null) {
+			if (vas == null) {
 				Gtk.MenuItem item = new Gtk.MenuItem ("No Visualizers Defined");
 				item.Show();
 				popup_menu.Append (item);
@@ -371,25 +364,36 @@
 
 				Gtk.MenuItem item = new Gtk.MenuItem ("Visualizers");
 				Gtk.Menu visualizer_submenu = new Gtk.Menu ();
-				Gtk.MenuItem va_item;
-
 				item.Submenu = visualizer_submenu;
 
-				va_item = new Gtk.MenuItem (va.Description != null ? va.Description : va.VisualizerTypeName);
+				item.Show();
 
-				va_item.Activated += new EventHandler (VisualizerActivate);
+				foreach (DebuggerVisualizerAttribute va in vas) {
+					Gtk.MenuItem va_item;
 
-				item.Show();
-				va_item.Show();
+					va_item = new Gtk.MenuItem (va.Description != null ? va.Description : va.VisualizerTypeName);
 
-				popup_menu.Append(item);
-				visualizer_submenu.Append (va_item);
+					va_item.Activated += new EventHandler (VisualizerActivate);
 
-				visualizers_by_item.Add (va_item, va);
+					va_item.Show();
+
+					popup_menu.Append(item);
+					visualizer_submenu.Append (va_item);
+
+					visualizers_by_item.Add (va_item, va);
+				}
 			}
 
-			popup_menu.Popup ();
+			return popup_menu;
 		}
+
+		void TreePopup (object o, PopupMenuArgs args)
+		{
+			Gtk.Menu popup_menu = CreatePopup();
+
+			if (popup_menu != null)
+				popup_menu.Popup ();
+		}
 #endif
 
 		void TestExpandRow (object o, TestExpandRowArgs args)
@@ -751,10 +755,10 @@
 			return null;
 		}
 
-		DebuggerVisualizerAttribute GetDebuggerVisualizerAttribute (DebuggingService dbgr, ITargetObject obj)
+		DebuggerVisualizerAttribute[] GetDebuggerVisualizerAttributes (DebuggingService dbgr, ITargetObject obj)
 		{
 			if (obj.TypeInfo.Type.TypeHandle != null && obj.TypeInfo.Type.TypeHandle is Type)
-			  return dbgr.AttributeHandler.GetDebuggerVisualizerAttribute ((Type)obj.TypeInfo.Type.TypeHandle);
+			  return dbgr.AttributeHandler.GetDebuggerVisualizerAttributes ((Type)obj.TypeInfo.Type.TypeHandle);
 
 			return null;
 		}

Modified: trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Visualizers/Makefile.am
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Visualizers/Makefile.am	2005-04-14 12:30:23 UTC (rev 2453)
+++ trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Visualizers/Makefile.am	2005-04-15 05:28:01 UTC (rev 2454)
@@ -1,13 +1,13 @@
 
-ASSEMBLY = MonoDevelop.Visualizers.dll
+ASSEMBLY_NAME = MonoDevelop.Visualizers
+ADDIN_BUILD = $(top_builddir)/build/AddIns/DebuggerAddIn
+ASSEMBLY = $(ADDIN_BUILD)/$(ASSEMBLY_NAME).dll
 
 DLLS = $(GTK_SHARP_LIBS) \
 	$(MONO_DEBUGGER_LIBS) \
 	/r:$(top_builddir)/build/bin/MonoDevelop.Base.dll \
 	/r:$(top_builddir)/build/bin/MonoDevelop.Core.dll \
-        /r:$(top_builddir)/build/bin/ICSharpCode.SharpRefactory.dll \
-	/r:$(top_builddir)/build/AddIns/DebuggerAddIn/MonoDevelop.Debugger.dll \
-	/pkg:gtk-sharp
+	/r:$(top_builddir)/build/bin/ICSharpCode.SharpRefactory.dll
 
 
 FILES = \
@@ -15,24 +15,28 @@
 	IDialogVisualizerService.cs \
 	IVisualizerObjectProvider.cs \
 	TargetObjectProvider.cs \
+	TargetMemoryStream.cs \
 	VisualizerDevelopmentHost.cs \
 	VisualizerObjectSource.cs
 
-
 EXTRA_DIST = $(FILES)
 
 if ENABLE_DEBUGGER
 
-all: $(ASSEMBLY)
+noinst_DATA= $(ASSEMBLY)
 
 build_sources = $(addprefix $(srcdir)/, $(FILES))
 
 $(ASSEMBLY): $(build_sources)
+	mkdir -p $(ADDIN_BUILD)
 	$(CSC) -g -define:NET_2_0 -define:WITH_GTK -out:$@ -target:library \
 	$(build_sources) $(DLLS)
 
 CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb
 
+install-data-local:
+	$(GACUTIL) /i $(ASSEMBLY) /f $(GACUTIL_FLAGS)
+
 else
 all:
 

Added: trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Visualizers/TargetMemoryStream.cs
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Visualizers/TargetMemoryStream.cs	2005-04-14 12:30:23 UTC (rev 2453)
+++ trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Visualizers/TargetMemoryStream.cs	2005-04-15 05:28:01 UTC (rev 2454)
@@ -0,0 +1,93 @@
+using System;
+using System.IO;
+
+using Mono.Debugger;
+using Mono.Debugger.Languages;
+
+namespace MonoDevelop.DebuggerVisualizers
+{
+	internal class TargetMemoryStream
+	{
+		public TargetMemoryStream (Process thread)
+		{
+			this.thread = thread;
+			CreateDebugeeStream ();
+		}
+
+		void CreateDebugeeStream ()
+		{
+			Console.WriteLine ("Creating Debuggee-side memory stream");
+
+			Mono.Debugger.StackFrame frame = thread.CurrentFrame;
+
+			streamType = frame.Language.LookupType (frame, "System.IO.MemoryStream") as ITargetStructType;
+			if (streamType == null)
+				throw new Exception ("couldn't find type `System.IO.MemoryStream'");
+
+			ITargetMethodInfo method = null;
+			foreach (ITargetMethodInfo m in streamType.Constructors) {
+				if (m.FullName == ".ctor()") {
+					method = m;
+					break;
+				}
+			}
+
+			if (method == null)
+				throw new Exception ("couldn't find applicable constructor for memory stream");
+
+			ITargetFunctionObject ctor = streamType.GetConstructor (frame, method.Index);
+			ITargetObject[] args = new ITargetObject[0];
+
+			debugeeStream = ctor.Type.InvokeStatic (frame, args, false) as ITargetStructObject;
+			if (debugeeStream == null)
+				throw new Exception ("unable to create instance of memory stream");
+
+			Console.WriteLine ("succeeded in creating debuggee-side memory stream");
+		}
+
+		public ITargetObject TargetStream {
+			get { return debugeeStream; }
+		}
+
+		public byte[] ToArray ()
+		{
+			ITargetMethodInfo method = null;
+			foreach (ITargetMethodInfo m in streamType.Methods) {
+				if (m.FullName == "ToArray()") {
+					method = m;
+					break;
+				}
+			}
+
+			if (method == null)
+				throw new Exception ("couldn't find MemoryStream.ToArray()");
+
+			ITargetFunctionObject ToArray = debugeeStream.GetMethod (method.Index);
+			ITargetObject[] args = new ITargetObject[0];
+
+			ITargetArrayObject target_array = ToArray.Invoke (args, false) as ITargetArrayObject;
+			if (target_array == null)
+				throw new Exception ("MemoryStream.ToArray returned null");
+			ITargetArrayType array_type = (ITargetArrayType)target_array.TypeInfo.Type;
+
+			ITargetFundamentalType fund = array_type.ElementType as ITargetFundamentalType;
+			if (fund == null || fund.Type != typeof (System.Byte))
+				throw new Exception (String.Format ("Array is not of type byte[] (element type is {0})",
+								    array_type.ElementType));
+
+			byte[] rv = new byte[target_array.UpperBound - target_array.LowerBound];
+			for (int i = 0; i < rv.Length; i ++) {
+				ITargetObject el = target_array[target_array.LowerBound + i];
+				rv[i] = (byte)((ITargetFundamentalObject)el).Object;
+			}
+
+			return rv;
+		}
+
+		Process thread;
+
+		ITargetStructType streamType;
+		ITargetStructObject debugeeStream;
+	}
+  
+}

Modified: trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Visualizers/TargetObjectProvider.cs
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Visualizers/TargetObjectProvider.cs	2005-04-14 12:30:23 UTC (rev 2453)
+++ trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Visualizers/TargetObjectProvider.cs	2005-04-15 05:28:01 UTC (rev 2454)
@@ -2,7 +2,6 @@
 using System.IO;
 using System.Runtime.Serialization.Formatters.Binary;
 
-using MonoDevelop.Debugger;
 using MonoDevelop.Services;
 
 using Mono.Debugger;
@@ -13,21 +12,19 @@
 
 	public class TargetObjectProvider : IVisualizerObjectProvider
 	{
-		public TargetObjectProvider (ITargetObject target, string sourceType)
+		public TargetObjectProvider (ITargetObject target, Process thread, string sourceType)
 		{
 			this.target = target;
-
+			this.thread = thread;
 			CreateVisualizerObjectSource (sourceType);
 		}
 
-
 		// Create the debuggee-side object that we'll communicate with
 		void CreateVisualizerObjectSource (string sourceType)
 		{
 			Console.WriteLine ("Creating Debuggee-side object (of type {0})", sourceType);
 
-			DebuggingService dbgr = (DebuggingService)Runtime.DebuggingService;
-			Mono.Debugger.StackFrame frame = dbgr.MainThread.CurrentFrame;
+			Mono.Debugger.StackFrame frame = thread.CurrentFrame;
 
 			// shouldn't be hardcoded - it comes from the attribute 
 			objectSourceType = frame.Language.LookupType (frame, sourceType) as ITargetStructType;
@@ -51,6 +48,8 @@
 			objectSource = ctor.Type.InvokeStatic (frame, args, false) as ITargetStructObject;
 			if (objectSource == null)
 				throw new Exception ("unable to create instance of object source");
+
+			Console.WriteLine ("succeeded in creating debuggee-side object source");
 		}
 
 #region IVisualizerObjectProvider implementation
@@ -65,7 +64,28 @@
 
 		public Stream GetData()
 		{
-			throw new NotImplementedException ();
+			TargetMemoryStream tms = new TargetMemoryStream (thread);
+
+			ITargetMethodInfo method = null;
+			foreach (ITargetMethodInfo m in objectSourceType.Methods) {
+				if (m.FullName == "GetData(System.Object,System.IO.Stream)") {
+					method = m;
+					break;
+				}
+			}
+
+			if (method == null)
+				throw new Exception ("couldn't find VisualizerObjectSource.GetData implementation in object source");
+
+			ITargetFunctionObject GetData = objectSource.GetMethod (method.Index);
+
+			ITargetObject[] args = new ITargetObject[2];
+			args[0] = target;
+			args[1] = tms.TargetStream;
+
+			GetData.Invoke (args, false);
+
+			return new MemoryStream (tms.ToArray());
 		}
 
 		public object GetObject ()
@@ -108,9 +128,10 @@
 		}
 #endregion
 
+		Process thread;
 		ITargetObject target;
 		ITargetStructType objectSourceType;
-		ITargetObject objectSource;
+		ITargetStructObject objectSource;
 	}
 
 }




More information about the Monodevelop-patches-list mailing list