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

Chris Toshok toshok at mono-cvs.ximian.com
Wed Apr 6 01:08:26 EDT 2005


Author: toshok
Date: 2005-04-06 01:08:26 -0400 (Wed, 06 Apr 2005)
New Revision: 2427

Modified:
   trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/ChangeLog
   trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Visualizers/Makefile.am
   trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Visualizers/TargetObjectProvider.cs
   trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Visualizers/VisualizerObjectSource.cs
Log:
2005-04-05  Chris Toshok  <toshok at ximian.com>

	* Visualizers/Makefile.am (DLLS): add MonoDevelop.Debugger.dll.
	(ASSEMBLY): remove $(ADDIN_BUILD)/ from the assembly path/name.
	(build): add -g so we can get methods from the visualizer dll for
	calling in the debugger addin.

	* Visualizers/VisualizerObjectSource.cs
	(VisualizerObjectSource..ctor): remove the
	NotImplementedException.
	(VisualizerObjectSource.CreateReplacementObject): implement by
	deserializing the incoming stream.
	(VisualizerObjectSource.Deserialize): implement with a binary
	formatter.
	(VisualizerObjectSource.GetData): implement using
	VisualizerObjectSource.Serialize.
	(VisualizerObjectSource.Serialize): implement with a binary
	formatter.

	* Visualizers/TargetObjectProvider.cs
	(TargetObjectProvider.CreateVisualizerObjectSource): method used
	to create an instance of the visualizer's object source in the
	debugee process.
	(TargetObjectProvider.get_IsObjectReplaceable): return true.
	(TargetObjectProvider.GetObject): implement by using GetData and a
	binary formatter to deserialize the object.
	(TargetObjectProvider.ReplaceObject): implement using ReplaceData
	and serialization.
	(TargetObjectProvider.TransferObject): implement using
	TransferData and serialization.



Modified: trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/ChangeLog	2005-04-06 03:56:34 UTC (rev 2426)
+++ trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/ChangeLog	2005-04-06 05:08:26 UTC (rev 2427)
@@ -1,3 +1,34 @@
+2005-04-05  Chris Toshok  <toshok at ximian.com>
+
+	* Visualizers/Makefile.am (DLLS): add MonoDevelop.Debugger.dll.
+	(ASSEMBLY): remove $(ADDIN_BUILD)/ from the assembly path/name.
+	(build): add -g so we can get methods from the visualizer dll for
+	calling in the debugger addin.
+
+	* Visualizers/VisualizerObjectSource.cs
+	(VisualizerObjectSource..ctor): remove the
+	NotImplementedException.
+	(VisualizerObjectSource.CreateReplacementObject): implement by
+	deserializing the incoming stream.
+	(VisualizerObjectSource.Deserialize): implement with a binary
+	formatter.
+	(VisualizerObjectSource.GetData): implement using
+	VisualizerObjectSource.Serialize.
+	(VisualizerObjectSource.Serialize): implement with a binary
+	formatter.
+
+	* Visualizers/TargetObjectProvider.cs
+	(TargetObjectProvider.CreateVisualizerObjectSource): method used
+	to create an instance of the visualizer's object source in the
+	debugee process.
+	(TargetObjectProvider.get_IsObjectReplaceable): return true.
+	(TargetObjectProvider.GetObject): implement by using GetData and a
+	binary formatter to deserialize the object.
+	(TargetObjectProvider.ReplaceObject): implement using ReplaceData
+	and serialization.
+	(TargetObjectProvider.TransferObject): implement using
+	TransferData and serialization.
+
 2005-04-06  Alp Toker  <alp at atoker.com>
 
 	* Gui/LocalsPad.cs: comment out 'using MonoDevelop.DebuggerVisualizers'

Modified: trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Visualizers/Makefile.am
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Visualizers/Makefile.am	2005-04-06 03:56:34 UTC (rev 2426)
+++ trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Visualizers/Makefile.am	2005-04-06 05:08:26 UTC (rev 2427)
@@ -1,11 +1,12 @@
 
-ASSEMBLY = $(ADDIN_BUILD)/MonoDevelop.Visualizers.dll
+ASSEMBLY = MonoDevelop.Visualizers.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
 
 
@@ -27,7 +28,7 @@
 build_sources = $(addprefix $(srcdir)/, $(FILES))
 
 $(ASSEMBLY): $(build_sources)
-	$(CSC) -define:NET_2_0 -define:WITH_GTK -out:$@ -target:library \
+	$(CSC) -g -define:NET_2_0 -define:WITH_GTK -out:$@ -target:library \
 	$(build_sources) $(DLLS)
 
 CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb

Modified: trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Visualizers/TargetObjectProvider.cs
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Visualizers/TargetObjectProvider.cs	2005-04-06 03:56:34 UTC (rev 2426)
+++ trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Visualizers/TargetObjectProvider.cs	2005-04-06 05:08:26 UTC (rev 2427)
@@ -1,5 +1,10 @@
 using System;
 using System.IO;
+using System.Runtime.Serialization.Formatters.Binary;
+
+using MonoDevelop.Debugger;
+using MonoDevelop.Services;
+
 using Mono.Debugger;
 using Mono.Debugger.Languages;
 
@@ -8,18 +13,52 @@
 
 	public class TargetObjectProvider : IVisualizerObjectProvider
 	{
-		public TargetObjectProvider (ITargetObject obj)
+		public TargetObjectProvider (ITargetObject target, string sourceType)
 		{
-			this.obj = obj;
-			throw new NotImplementedException ();
+			this.target = target;
+
+			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;
+
+			// shouldn't be hardcoded - it comes from the attribute 
+			objectSourceType = frame.Language.LookupType (frame, sourceType) as ITargetStructType;
+			if (objectSourceType == null)
+				throw new Exception ("couldn't find type for object source");
+
+			ITargetMethodInfo method = null;
+			foreach (ITargetMethodInfo m in objectSourceType.Constructors) {
+				if (m.FullName == ".ctor()") {
+					method = m;
+					break;
+				}
+			}
+
+			if (method == null)
+				throw new Exception ("couldn't find applicable constructor for object source");
+
+			ITargetFunctionObject ctor = objectSourceType.GetConstructor (frame, method.Index);
+			ITargetObject[] args = new ITargetObject[0];
+
+			objectSource = ctor.Type.InvokeStatic (frame, args, false) as ITargetStructObject;
+			if (objectSource == null)
+				throw new Exception ("unable to create instance of object source");
+		}
+
 #region IVisualizerObjectProvider implementation
 
 		public bool IsObjectReplaceable
 		{
 			get {
-				throw new NotImplementedException ();
+				return true;
 			}
 		}
 	  
@@ -31,13 +70,10 @@
 
 		public object GetObject ()
 		{
-			/* first we cause the target object to serialize itself */
+			Stream s = GetData();
+			BinaryFormatter f = new BinaryFormatter ();
 
-			/* then we transfer the data to the debugger process */
-
-			/* and deserialize it */
-
-			throw new NotImplementedException ();
+			return f.Deserialize (s);
 		}
 
 		public void ReplaceData (Stream newObjectData)
@@ -47,7 +83,11 @@
 
 		public void ReplaceObject (object newObject)
 		{
-			throw new NotImplementedException ();
+			BinaryFormatter f = new BinaryFormatter();
+			MemoryStream stream = new MemoryStream ();
+
+			f.Serialize (stream, newObject);
+			ReplaceData (stream);
 		}
 
 		public Stream TransferData (Stream outgoingData)
@@ -57,11 +97,20 @@
 
 		public object TransferObject (object outgoingObject)
 		{
-			throw new NotImplementedException ();
+			BinaryFormatter f = new BinaryFormatter();
+			Stream outgoingStream = new MemoryStream ();
+			Stream incomingStream;
+
+			f.Serialize (outgoingStream, outgoingObject);
+			incomingStream = TransferData (outgoingStream);
+
+			return f.Deserialize (incomingStream);
 		}
 #endregion
 
-		ITargetObject obj;
+		ITargetObject target;
+		ITargetStructType objectSourceType;
+		ITargetObject objectSource;
 	}
 
 }

Modified: trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Visualizers/VisualizerObjectSource.cs
===================================================================
--- trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Visualizers/VisualizerObjectSource.cs	2005-04-06 03:56:34 UTC (rev 2426)
+++ trunk/MonoDevelop/Core/src/AddIns/DebuggerAddIn/Visualizers/VisualizerObjectSource.cs	2005-04-06 05:08:26 UTC (rev 2427)
@@ -1,5 +1,6 @@
 using System;
 using System.IO;
+using System.Runtime.Serialization.Formatters.Binary;
 
 namespace MonoDevelop.DebuggerVisualizers
 {
@@ -7,27 +8,29 @@
 	{
 		public VisualizerObjectSource ()
 		{
-			throw new NotImplementedException ();
 		}
 
 		public virtual object CreateReplacementObject (object target, Stream incomingData)
 		{
-			throw new NotImplementedException ();
+			/* do we do anything with @target here? */
+			return VisualizerObjectSource.Deserialize (incomingData);
 		}
 
 		public static object Deserialize (Stream serializationStream)
 		{
-			throw new NotImplementedException ();
+			BinaryFormatter f=new BinaryFormatter();
+			return f.Deserialize (serializationStream);
 		}
 
 		public virtual void GetData (object target, Stream outgoingData)
 		{
-			throw new NotImplementedException ();
+			VisualizerObjectSource.Serialize (outgoingData, target);
 		}
 
 		public static void Serialize (Stream serializationStream, object target)
 		{
-			throw new NotImplementedException ();
+			BinaryFormatter f=new BinaryFormatter();
+			f.Serialize (serializationStream, target);
 		}
 
 		public static void TransferData (object target, Stream incomingData, Stream outgoingData)




More information about the Monodevelop-patches-list mailing list