Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move old code elsewhere

svn path=/old-code/; revision=115303
  • Loading branch information...
commit 98aa5a91578361bd3f49d9ab916cc2c66c8bd8db 1 parent 65767f1
@migueldeicaza migueldeicaza authored
Showing with 11,953 additions and 0 deletions.
  1. +76 −0 MonoVS/ChangeLog
  2. BIN  MonoVS/HomeDir/MonoAddin - For Testing.AddIn
  3. BIN  MonoVS/HomeDir/ProjectLauncher.AddIn
  4. +8 −0 MonoVS/LICENSE
  5. +195 −0 MonoVS/Mono.VisualStudio.Debugger/AD7Enums.cs
  6. +394 −0 MonoVS/Mono.VisualStudio.Debugger/AD7Events.cs
  7. +130 −0 MonoVS/Mono.VisualStudio.Debugger/BoundBreakpoint.cs
  8. +112 −0 MonoVS/Mono.VisualStudio.Debugger/BreakpointManager.cs
  9. +116 −0 MonoVS/Mono.VisualStudio.Debugger/BreakpointResolution.cs
  10. +14 −0 MonoVS/Mono.VisualStudio.Debugger/COM.cs
  11. +115 −0 MonoVS/Mono.VisualStudio.Debugger/ChangeLog
  12. +148 −0 MonoVS/Mono.VisualStudio.Debugger/DebuggerController.cs
  13. +122 −0 MonoVS/Mono.VisualStudio.Debugger/DocumentContext.cs
  14. +205 −0 MonoVS/Mono.VisualStudio.Debugger/Engine.cs
  15. +103 −0 MonoVS/Mono.VisualStudio.Debugger/EngineCallback.cs
  16. +45 −0 MonoVS/Mono.VisualStudio.Debugger/ErrorBreakpoint.cs
  17. +28 −0 MonoVS/Mono.VisualStudio.Debugger/Guids.cs
  18. +184 −0 MonoVS/Mono.VisualStudio.Debugger/MemoryAddress.cs
  19. +50 −0 MonoVS/Mono.VisualStudio.Debugger/Module.cs
  20. +8 −0 MonoVS/Mono.VisualStudio.Debugger/Mono.VisualStudio.Debugger.config
  21. +109 −0 MonoVS/Mono.VisualStudio.Debugger/Mono.VisualStudio.Debugger.csproj
  22. +6 −0 MonoVS/Mono.VisualStudio.Debugger/Mono.VisualStudio.Debugger.csproj.user
  23. +50 −0 MonoVS/Mono.VisualStudio.Debugger/Package.cs
  24. +167 −0 MonoVS/Mono.VisualStudio.Debugger/PendingBreakpoint.cs
  25. +177 −0 MonoVS/Mono.VisualStudio.Debugger/Port.cs
  26. +85 −0 MonoVS/Mono.VisualStudio.Debugger/PortSupplier.cs
  27. +558 −0 MonoVS/Mono.VisualStudio.Debugger/Process.cs
  28. +66 −0 MonoVS/Mono.VisualStudio.Debugger/ProgramNode.cs
  29. +64 −0 MonoVS/Mono.VisualStudio.Debugger/ProgramProvider.cs
  30. +36 −0 MonoVS/Mono.VisualStudio.Debugger/Properties/AssemblyInfo.cs
  31. +123 −0 MonoVS/Mono.VisualStudio.Debugger/Resource1.resx
  32. +124 −0 MonoVS/Mono.VisualStudio.Debugger/Settings.cs
  33. +180 −0 MonoVS/Mono.VisualStudio.Debugger/StackFrame.cs
  34. +154 −0 MonoVS/Mono.VisualStudio.Debugger/Thread.cs
  35. +69 −0 MonoVS/Mono.VisualStudio.Debugger/Utils.cs
  36. +51 −0 MonoVS/MonoAddin/AssemblyInfo.cs
  37. +14 −0 MonoVS/MonoAddin/ChangeLog
  38. +442 −0 MonoVS/MonoAddin/CommandBar.resx
  39. +300 −0 MonoVS/MonoAddin/Connect.cs
  40. +22 −0 MonoVS/MonoAddin/MonoAddin.AddIn
  41. +142 −0 MonoVS/MonoAddin/MonoAddin.csproj
  42. +163 −0 MonoVS/MonoAddin/SettingsDialog.Designer.cs
  43. +63 −0 MonoVS/MonoAddin/SettingsDialog.cs
  44. +120 −0 MonoVS/MonoAddin/SettingsDialog.resx
  45. BIN  MonoVS/MonoAddin/lib/Mono.Cecil.dll
  46. BIN  MonoVS/MonoAddin/lib/Mono.CompilerServices.SymbolWriter.dll
  47. +236 −0 MonoVS/MonoAddin/pdb2mdb.cs
  48. +47 −0 MonoVS/MonoVS.sln
  49. +199 −0 MonoVS/README
  50. +36 −0 MonoVS/RegisterDebugger/Properties/AssemblyInfo.cs
  51. +154 −0 MonoVS/RegisterDebugger/RegisterDebugger.cs
  52. +62 −0 MonoVS/RegisterDebugger/RegisterDebugger.csproj
  53. +149 −0 MonoVS/RemotingContract/Contract.cs
  54. +38 −0 MonoVS/RemotingContract/Properties/AssemblyInfo.cs
  55. +54 −0 MonoVS/RemotingContract/RemotingContract.csproj
  56. BIN  MonoVS/RemotingContract/RemotingContract.snk
  57. +78 −0 MonoVS/Server/BreakpointManager.cs
  58. +156 −0 MonoVS/Server/DebuggerManager.cs
  59. +68 −0 MonoVS/Server/DebuggerManager.csproj
  60. +118 −0 MonoVS/Server/DebuggerServer.cs
  61. +29 −0 MonoVS/Server/Makefile
  62. +1,597 −0 MonoVS/Server/Options.cs
  63. +103 −0 MonoVS/Server/Process.cs
  64. +16 −0 MonoVS/Server/ServerBreakpoint.cs
  65. +113 −0 MonoVS/Server/ServerProcess.cs
  66. +111 −0 MonoVS/Server/ServerStackFrame.cs
  67. +78 −0 MonoVS/Server/ServerThread.cs
  68. +119 −0 MonoVS/Server/launcher.cs
  69. +68 −0 MonoVS/Server/launcher.csproj
  70. +37 −0 MonoVS/martin-patch-20080903-mini.diff
  71. +2,949 −0 MonoVS/martin-patch-20080903-monovs.diff
View
76 MonoVS/ChangeLog
@@ -0,0 +1,76 @@
+2008-06-17 Martin Baulig <martin@novell.com>
+
+ * Fix pdb2mdb to work with new Mono.CompilerServices.SymbolWriter.
+
+2008-06-17 Miguel de Icaza <miguel@novell.com>
+
+ * RemotingContract/Contract.cs: Launch now returns a
+ IServerProcess interface, we use this to communicate with the
+ process directly.
+
+ * Mono.VisualStudio.Debugger/Port.cs: Track the IServerProcess to
+ Process mapping.
+
+ * Mono.VisualStudio.Debugger/PendingBreakpoint.cs: Small style
+ changes.
+
+ * Server: Add support for -map to remap filenames on the server to
+ filenames on the client (this is a quick hack, will go away
+ later).
+
+ * Server: drop the solutions from Server, as they require the Unix
+ assemblies for the debugger.
+
+2008-06-13 Jonathan Chambers <joncham@gmail.com>
+
+ * Add .csproj files for launcher and DebuggerServer to work on Windows (for now).
+
+ Code contributed under MIT/X11 license.
+
+2008-06-13 Miguel de Icaza <miguel@novell.com>
+
+ * Refactor the PortSupplier and split out the Port class. The
+ Port will represent a remote host, the PortSupplier should be able
+ to launch new ports in new hosts.
+
+ Rewrite the code to use the documented public COM interfaces to
+ register nodes to hook things as documented.
+
+ Still, no progress made in notifying the debugger of a program
+ creation event. I believe this is the next step:
+
+ http://msdn.microsoft.com/en-us/library/bb145568.aspx
+
+2008-06-12 Miguel de Icaza <miguel@novell.com>
+
+ * Copied the infrastructure for sendings AD7 Events, most stuff
+ are stubs now.
+
+2008-06-11 Miguel de Icaza <miguel@novell.com>
+
+ * RegisterDebugger: Add the Mono-based PortSupplier.
+
+ * RemotingContract: Return the pid.
+
+2008-06-11 Jonathan Chambers <joncham@gmail.com>
+
+ * Fix addin on Win64. Use uri.LocalPath to fix handling of paths with spaces. Absolute path used %20.
+
+ Code contributed under MIT/X11 license.
+
+2008-06-07 Miguel de Icaza <miguel@roxanne.site>
+
+ * Figured how to register the Debug Engine in the registry, we now
+ hit the first NotImplementedException inside VisualStudio.
+
+ Add docs.
+
+2008-06-06 Miguel de Icaza <miguel@novell.com>
+
+ Hook up PDB to MDB conversion to the project.
+
+ Try to launch the debugger.
+
+ Add new Debug Engine (currently does not work, we need to get the
+ beast to register with COM, and I have no idea how to do it).
+
View
BIN  MonoVS/HomeDir/MonoAddin - For Testing.AddIn
Binary file not shown
View
BIN  MonoVS/HomeDir/ProjectLauncher.AddIn
Binary file not shown
View
8 MonoVS/LICENSE
@@ -0,0 +1,8 @@
+This code contains code that is derived from Microsoft's Debug Engine Sample
+whcih is released under the MS-Permissive License terms.
+
+If you contribute code, make sure that you state that the code is dual-licensed
+MIT X11 and MS-PL.
+
+The licensing of this module has not been decided yet; Currently it should be
+considered Novell published and proprietary.
View
195 MonoVS/Mono.VisualStudio.Debugger/AD7Enums.cs
@@ -0,0 +1,195 @@
+using System;
+using System.Linq;
+using System.Collections.Generic;
+using System.Text;
+using Microsoft.VisualStudio.Debugger.Interop;
+
+
+// These classes use a generic enumerator implementation to create the various enumerators required by the engine.
+// They allow the enumeration of everything from programs to breakpoints.
+namespace Mono.VisualStudio.Debugger
+{
+ #region Base Class
+ class AD7Enum<T, I> where I : class
+ {
+ readonly T[] m_data;
+ uint m_position;
+
+ public AD7Enum (T[] data)
+ {
+ m_data = data;
+ m_position = 0;
+ }
+
+ public int Clone (out I ppEnum)
+ {
+ ppEnum = null;
+ return COM.E_NOTIMPL;
+ }
+
+ public int GetCount (out uint pcelt)
+ {
+ pcelt = (uint) m_data.Length;
+ return COM.S_OK;
+ }
+
+ public int Next (uint celt, T[] rgelt, out uint celtFetched)
+ {
+ return Move (celt, rgelt, out celtFetched);
+ }
+
+ public int Reset ()
+ {
+ lock (this) {
+ m_position = 0;
+
+ return COM.S_OK;
+ }
+ }
+
+ public int Skip (uint celt)
+ {
+ uint celtFetched;
+
+ return Move (celt, null, out celtFetched);
+ }
+
+ private int Move (uint celt, T[] rgelt, out uint celtFetched)
+ {
+ lock (this) {
+ int hr = COM.S_OK;
+ celtFetched = (uint) m_data.Length - m_position;
+
+ if (celt > celtFetched) {
+ hr = COM.S_FALSE;
+ } else if (celt < celtFetched) {
+ celtFetched = celt;
+ }
+
+ if (rgelt != null) {
+ for (int c = 0; c < celtFetched; c++) {
+ rgelt[c] = m_data[m_position + c];
+ }
+ }
+
+ m_position += celtFetched;
+
+ return hr;
+ }
+ }
+ }
+ #endregion Base Class
+
+ class AD7ProgramEnum : AD7Enum<IDebugProgram2, IEnumDebugPrograms2>, IEnumDebugPrograms2
+ {
+ public AD7ProgramEnum (IDebugProgram2[] data)
+ : base (data)
+ {
+ }
+
+ public int Next (uint celt, IDebugProgram2[] rgelt, ref uint celtFetched)
+ {
+ return Next (celt, rgelt, out celtFetched);
+ }
+ }
+
+ class AD7FrameInfoEnum : AD7Enum<FRAMEINFO, IEnumDebugFrameInfo2>, IEnumDebugFrameInfo2
+ {
+ public AD7FrameInfoEnum (FRAMEINFO[] data)
+ : base (data)
+ {
+ }
+
+ public int Next (uint celt, FRAMEINFO[] rgelt, ref uint celtFetched)
+ {
+ return Next (celt, rgelt, out celtFetched);
+ }
+ }
+
+ class AD7PropertyInfoEnum : AD7Enum<DEBUG_PROPERTY_INFO, IEnumDebugPropertyInfo2>, IEnumDebugPropertyInfo2
+ {
+ public AD7PropertyInfoEnum (DEBUG_PROPERTY_INFO[] data)
+ : base (data)
+ {
+ }
+ }
+
+ class AD7ThreadEnum : AD7Enum<IDebugThread2, IEnumDebugThreads2>, IEnumDebugThreads2
+ {
+ public AD7ThreadEnum (IDebugThread2[] threads)
+ : base (threads)
+ { }
+
+ public AD7ThreadEnum (IEnumerable<IDebugThread2> threads)
+ : base (threads.ToArray ())
+ { }
+
+ public int Next (uint celt, IDebugThread2[] rgelt, ref uint celtFetched)
+ {
+ return Next (celt, rgelt, out celtFetched);
+ }
+ }
+
+ class AD7ModuleEnum : AD7Enum<IDebugModule2, IEnumDebugModules2>, IEnumDebugModules2
+ {
+ public AD7ModuleEnum (IDebugModule2[] modules)
+ : base (modules)
+ {
+
+ }
+
+ public int Next (uint celt, IDebugModule2[] rgelt, ref uint celtFetched)
+ {
+ return Next (celt, rgelt, out celtFetched);
+ }
+ }
+
+ class AD7PropertyEnum : AD7Enum<DEBUG_PROPERTY_INFO, IEnumDebugPropertyInfo2>, IEnumDebugPropertyInfo2
+ {
+ public AD7PropertyEnum (DEBUG_PROPERTY_INFO[] properties)
+ : base (properties)
+ {
+
+ }
+ }
+
+ class AD7CodeContextEnum : AD7Enum<IDebugCodeContext2, IEnumDebugCodeContexts2>, IEnumDebugCodeContexts2
+ {
+ public AD7CodeContextEnum (IDebugCodeContext2[] codeContexts)
+ : base (codeContexts)
+ {
+
+ }
+
+ public int Next (uint celt, IDebugCodeContext2[] rgelt, ref uint celtFetched)
+ {
+ return Next (celt, rgelt, out celtFetched);
+ }
+ }
+
+ class AD7BoundBreakpointsEnum : AD7Enum<IDebugBoundBreakpoint2, IEnumDebugBoundBreakpoints2>, IEnumDebugBoundBreakpoints2
+ {
+ public AD7BoundBreakpointsEnum (params IDebugBoundBreakpoint2[] breakpoints)
+ : base (breakpoints)
+ { }
+
+ public int Next (uint celt, IDebugBoundBreakpoint2[] rgelt, ref uint celtFetched)
+ {
+ return Next (celt, rgelt, out celtFetched);
+ }
+ }
+
+ class AD7ErrorBreakpointsEnum : AD7Enum<IDebugErrorBreakpoint2, IEnumDebugErrorBreakpoints2>, IEnumDebugErrorBreakpoints2
+ {
+ public AD7ErrorBreakpointsEnum (params IDebugErrorBreakpoint2[] breakpoints)
+ : base (breakpoints)
+ { }
+
+ public int Next (uint celt, IDebugErrorBreakpoint2[] rgelt, ref uint celtFetched)
+ {
+ return Next (celt, rgelt, out celtFetched);
+ }
+ }
+
+
+}
View
394 MonoVS/Mono.VisualStudio.Debugger/AD7Events.cs
@@ -0,0 +1,394 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Microsoft.VisualStudio.Debugger.Interop;
+
+// This file contains the private const intious event objects that are sent to the debugger from the sample engine via IDebugEventCallback2::Event.
+// These are used in EngineCallback.cs.
+// The events are how the engine tells the debugger about what is happening in the debuggee process.
+// There are three base classe the other events derive from: AD7AsynchronousEvent, AD7StoppingEvent, and AD7SynchronousEvent. These
+// each implement the IDebugEvent2.GetAttributes method for the type of event they represent.
+// Most events sent the debugger are asynchronous events.
+
+
+namespace Mono.VisualStudio.Debugger
+{
+ #region Event base classes
+
+ class AD7AsynchronousEvent : IDebugEvent2
+ {
+ public const uint Attributes = (uint) enum_EVENTATTRIBUTES.EVENT_ASYNCHRONOUS;
+
+ public int GetAttributes (out uint attrs)
+ {
+ attrs = Attributes;
+ return COM.S_OK;
+ }
+ }
+
+ class AD7StoppingEvent : IDebugEvent2
+ {
+ public const uint Attributes = (uint) enum_EVENTATTRIBUTES.EVENT_ASYNC_STOP;
+
+ public int GetAttributes (out uint attrs)
+ {
+ attrs = Attributes;
+ return COM.S_OK;
+ }
+ }
+
+ class AD7SynchronousEvent : IDebugEvent2
+ {
+ public const uint Attributes = (uint) enum_EVENTATTRIBUTES.EVENT_SYNCHRONOUS;
+
+ public int GetAttributes (out uint attrs)
+ {
+ attrs = Attributes;
+ return COM.S_OK;
+ }
+ }
+
+ class AD7SynchronousStoppingEvent : IDebugEvent2
+ {
+ public const uint Attributes = (uint) enum_EVENTATTRIBUTES.EVENT_STOPPING | (uint) enum_EVENTATTRIBUTES.EVENT_SYNCHRONOUS;
+
+ public int GetAttributes (out uint attrs)
+ {
+ attrs = Attributes;
+ return COM.S_OK;
+ }
+ }
+
+ #endregion
+
+ // The debug engine (DE) sends this interface to the session debug manager (SDM) when an instance of the DE is created.
+ sealed class EngineCreateEvent : AD7SynchronousEvent, IDebugEngineCreateEvent2
+ {
+ public const string IID = "FE5B734C-759D-4E59-AB04-F103343BDD06";
+
+ public IDebugEngine2 Engine
+ {
+ get;
+ private set;
+ }
+
+ EngineCreateEvent (Engine engine)
+ {
+ this.Engine = engine;
+ }
+
+ public static void Send (Engine engine)
+ {
+ EngineCreateEvent e = new EngineCreateEvent (engine);
+ engine.EngineCallback.Send (e, IID, null, null);
+ }
+
+ public int GetEngine (out IDebugEngine2 engine)
+ {
+ engine = Engine;
+ return COM.S_OK;
+ }
+ }
+
+ // This interface is sent by the debug engine (DE) to the session debug manager (SDM) when a program is attached to.
+ sealed class AD7ProgramCreateEvent : AD7SynchronousEvent, IDebugProgramCreateEvent2
+ {
+ public const string IID = "96CD11EE-ECD4-4E89-957E-B5D496FC4139";
+
+ internal static void Send (Engine engine)
+ {
+ AD7ProgramCreateEvent e = new AD7ProgramCreateEvent ();
+ engine.EngineCallback.Send (e, IID, null);
+ }
+
+ internal static void Send (Port port, IDebugProcess2 process, IDebugProgram2 program)
+ {
+ AD7ProgramCreateEvent e = new AD7ProgramCreateEvent ();
+ Guid iid = new Guid (IID);
+ port.PortEventsCP.Event (port.PortSupplier.Server, port, process, program, e, ref iid);
+ }
+ }
+
+ // This interface is sent by the debug engine (DE) to the session debug manager (SDM) when a program has run to completion
+ // or is otherwise destroyed.
+ sealed class AD7ProgramDestroyEvent : AD7SynchronousEvent, IDebugProgramDestroyEvent2
+ {
+ public const string IID = "E147E9E3-6440-4073-A7B7-A65592C714B5";
+
+ public uint ExitCode
+ {
+ get;
+ private set;
+ }
+
+ public AD7ProgramDestroyEvent (uint exit_code)
+ {
+ ExitCode = exit_code;
+ }
+
+ internal static void Send (Port port, IDebugProcess2 process, IDebugProgram2 program)
+ {
+ AD7ProgramDestroyEvent e = new AD7ProgramDestroyEvent (0);
+ Guid iid = new Guid (IID);
+ port.PortEventsCP.Event (port.PortSupplier.Server, port, process, program, e, ref iid);
+ }
+
+ #region IDebugProgramDestroyEvent2 Members
+
+ public int GetExitCode (out uint exit_code)
+ {
+ exit_code = ExitCode;
+ return COM.S_OK;
+ }
+
+ #endregion
+ }
+
+ // This interface is sent by the debug engine (DE) to the session debug manager (SDM) when a thread is created in a program being debugged.
+ sealed class AD7ThreadCreateEvent : AD7SynchronousEvent, IDebugThreadCreateEvent2
+ {
+ public const string IID = "2090CCFC-70C5-491D-A5E8-BAD2DD9EE3EA";
+ }
+
+ // This interface is sent by the debug engine (DE) to the session debug manager (SDM) when a thread has exited.
+ sealed class AD7ThreadDestroyEvent : AD7AsynchronousEvent, IDebugThreadDestroyEvent2
+ {
+ public const string IID = "2C3B7532-A36F-4A6E-9072-49BE649B8541";
+
+ public uint ExitCode
+ {
+ get;
+ private set;
+ }
+
+ public AD7ThreadDestroyEvent (uint exit_code)
+ {
+ ExitCode = exit_code;
+ }
+
+ #region IDebugThreadDestroyEvent2 Members
+
+ public int GetExitCode (out uint exit_code)
+ {
+ exit_code = ExitCode;
+ return COM.S_OK;
+ }
+
+ #endregion
+ }
+
+ // This interface is sent by the debug engine (DE) to the session debug manager (SDM) when a program is loaded, but before any code is executed.
+ sealed class AD7LoadCompleteEvent : AD7SynchronousEvent, IDebugLoadCompleteEvent2
+ {
+ public const string IID = "B1844850-1349-45D4-9F12-495212F5EB0B";
+ }
+
+ sealed class AD7EntryPointEvent : AD7SynchronousEvent, IDebugEntryPointEvent2
+ {
+ public const string IID = "e8414a3e-1642-48ec-829e-5f4040e16da9";
+ }
+
+ sealed class AD7StepCompleteEvent : AD7SynchronousStoppingEvent, IDebugStepCompleteEvent2
+ {
+ public const string IID = "0f7f24c1-74d9-4ea6-a3ea-7edb2d81441d";
+ }
+
+ // This interface tells the session debug manager (SDM) that an asynchronous break has been successfully completed.
+ sealed class AD7AsyncBreakCompleteEvent : AD7StoppingEvent, IDebugBreakEvent2
+ {
+ public const string IID = "c7405d1d-e24b-44e0-b707-d8a5a4e1641b";
+ }
+
+ // This interface is sent by the debug engine (DE) to the session debug manager (SDM) to output a string for debug tracing.
+ sealed class AD7OutputDebugStringEvent : AD7AsynchronousEvent, IDebugOutputStringEvent2
+ {
+ public const string IID = "569c4bb1-7b82-46fc-ae28-4536ddad753e";
+
+ public string OutputString
+ {
+ get;
+ private set;
+ }
+
+ public AD7OutputDebugStringEvent (string str)
+ {
+ OutputString = str;
+ }
+
+ #region IDebugOutputStringEvent2 Members
+
+ public int GetString (out string str)
+ {
+ str = OutputString;
+ return COM.S_OK;
+ }
+
+ #endregion
+ }
+
+ // This interface is sent when a pending breakpoint has been bound in the debuggee.
+ sealed class AD7BreakpointBoundEvent : AD7AsynchronousEvent, IDebugBreakpointBoundEvent2
+ {
+ public const string IID = "1dddb704-cf99-4b8a-b746-dabb01dd13a0";
+
+ public BoundBreakpoint BoundBreakpoint
+ {
+ get;
+ private set;
+ }
+
+ public AD7BreakpointBoundEvent (BoundBreakpoint bound)
+ {
+ BoundBreakpoint = bound;
+ }
+
+ #region IDebugBreakpointBoundEvent2 Members
+
+ public int EnumBoundBreakpoints (out IEnumDebugBoundBreakpoints2 e)
+ {
+ e = new AD7BoundBreakpointsEnum (BoundBreakpoint);
+ return COM.S_OK;
+ }
+
+ public int GetPendingBreakpoint (out IDebugPendingBreakpoint2 pending)
+ {
+ pending = BoundBreakpoint.PendingBreakpoint;
+ return COM.S_OK;
+ }
+
+ #endregion
+ }
+
+ sealed class AD7BreakpointErrorEvent : AD7SynchronousEvent, IDebugBreakpointErrorEvent2
+ {
+ public const string IID = "abb0ca42-f82b-4622-84e4-6903ae90f210";
+
+ public ErrorBreakpoint ErrorBreakpoint
+ {
+ get;
+ private set;
+ }
+
+ public AD7BreakpointErrorEvent (ErrorBreakpoint error)
+ {
+ this.ErrorBreakpoint = error;
+ }
+
+
+ #region IDebugBreakpointErrorEvent2 Members
+
+ public int GetErrorBreakpoint (out IDebugErrorBreakpoint2 error)
+ {
+ error = ErrorBreakpoint;
+ return COM.S_OK;
+ }
+
+ #endregion
+ }
+
+
+ // This Event is sent when a breakpoint is hit in the debuggee
+ sealed class AD7BreakpointEvent : AD7SynchronousStoppingEvent, IDebugBreakpointEvent2
+ {
+ public const string IID = "501C1E21-C557-48B8-BA30-A1EAB0BC4A74";
+
+ public IEnumDebugBoundBreakpoints2 BoundBreakpoints
+ {
+ get;
+ private set;
+ }
+
+ public AD7BreakpointEvent (IEnumDebugBoundBreakpoints2 bound)
+ {
+ BoundBreakpoints = bound;
+ }
+
+ public AD7BreakpointEvent (BoundBreakpoint bound)
+ {
+ BoundBreakpoints = new AD7BoundBreakpointsEnum (bound);
+ }
+
+ #region IDebugBreakpointEvent2 Members
+
+ public int EnumBreakpoints (out IEnumDebugBoundBreakpoints2 e)
+ {
+ e = BoundBreakpoints;
+ return COM.S_OK;
+ }
+
+ #endregion
+ }
+
+ sealed class AD7ProcessCreateEvent : AD7SynchronousEvent, IDebugProcessCreateEvent2
+ {
+ public const string IID = "BAC3780F-04DA-4726-901C-BA6A4633E1CA";
+
+ internal static void Send (Engine engine, Process process)
+ {
+ AD7ProcessCreateEvent e = new AD7ProcessCreateEvent ();
+ engine.EngineCallback.Send (e, IID, process, null);
+ }
+
+ internal static void Send (Port port, IDebugProcess2 process)
+ {
+ AD7ProcessCreateEvent e = new AD7ProcessCreateEvent ();
+ Guid iid = new Guid (IID);
+ port.PortEventsCP.Event (port.PortSupplier.Server, port, process, null, e, ref iid);
+ }
+ }
+
+ sealed class AD7ProcessDestroyEvent : AD7SynchronousEvent, IDebugProcessDestroyEvent2
+ {
+ public const string IID = "3E2A0832-17E1-4886-8C0E-204DA242995F";
+
+ internal static void Send (Engine engine, Process process)
+ {
+ AD7ProcessDestroyEvent e = new AD7ProcessDestroyEvent ();
+ engine.EngineCallback.Send (e, IID, process, null);
+ }
+
+ internal static void Send (Port port, IDebugProcess2 process)
+ {
+ AD7ProcessDestroyEvent e = new AD7ProcessDestroyEvent ();
+ Guid iid = new Guid (IID);
+ port.PortEventsCP.Event (port.PortSupplier.Server, port, process, null, e, ref iid);
+ }
+ }
+
+ sealed class AD7ErrorEvent : AD7SynchronousEvent, IDebugErrorEvent2
+ {
+ public const string IID = "fdb7a36c-8c53-41da-a337-8bd86b14d5cb";
+
+ public string ErrorMessage
+ {
+ get;
+ private set;
+ }
+
+ public AD7ErrorEvent (string message)
+ {
+ this.ErrorMessage = message;
+ }
+
+ public AD7ErrorEvent (string message, params object[] args)
+ {
+ this.ErrorMessage = String.Format (message, args);
+ }
+
+ #region IDebugErrorEvent2 Members
+
+ public int GetErrorMessage (out uint message_type, out string format, out int reason,
+ out uint severity, out string helper_filename, out uint helper_id)
+ {
+ message_type = 2; // MT_MESSAGEBOX;
+ format = ErrorMessage;
+ reason = 0;
+ severity = 16; // MB_CRITICAL;
+ helper_filename = null;
+ helper_id = 0;
+ return COM.S_OK;
+ }
+
+ #endregion
+ }
+}
View
130 MonoVS/Mono.VisualStudio.Debugger/BoundBreakpoint.cs
@@ -0,0 +1,130 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Microsoft.VisualStudio.Debugger.Interop;
+using System.Diagnostics;
+
+using Mono.VisualStudio.Mdb;
+namespace Mono.VisualStudio.Debugger
+{
+ // This class represents a breakpoint that has been bound to a location in the debuggee. It is a child of the pending breakpoint
+ // that creates it. Unless the pending breakpoint only has one bound breakpoint, each bound breakpoint is displayed as a child of the
+ // pending breakpoint in the breakpoints window. Otherwise, only one is displayed.
+ public class BoundBreakpoint : IDebugBoundBreakpoint2
+ {
+ public PendingBreakpoint PendingBreakpoint {
+ get; private set;
+ }
+
+ public BreakpointResolution Resolution {
+ get; private set;
+ }
+
+ public Engine Engine {
+ get; private set;
+ }
+
+ internal IServerBreakpoint Handle {
+ get; private set;
+ }
+
+ private uint m_address;
+
+ private bool enabled;
+ private bool deleted;
+
+ public BoundBreakpoint (Engine engine, PendingBreakpoint pending, BreakpointResolution resolution,
+ IServerBreakpoint handle)
+ {
+ this.Engine = engine;
+ this.PendingBreakpoint = pending;
+ this.Resolution = resolution;
+ this.Handle = handle;
+
+ enabled = true;
+ deleted = false;
+ }
+
+ #region IDebugBoundBreakpoint2 Members
+
+ // Called when the breakpoint is being deleted by the user.
+ int IDebugBoundBreakpoint2.Delete ()
+ {
+ return COM.S_OK;
+ throw new NotImplementedException ();
+ }
+
+ // Called by the debugger UI when the user is enabling or disabling a breakpoint.
+ public int Enable (int enable)
+ {
+ bool new_enabled = enable == 0 ? false : true;
+ if (new_enabled != enabled) {
+ // A production debug engine would remove or add the underlying int3 here. The sample engine does not support true disabling
+ // of breakpionts.
+ }
+ new_enabled = enabled;
+ return COM.S_OK;
+ }
+
+ // Return the breakpoint resolution which describes how the breakpoint bound in the debuggee.
+ public int GetBreakpointResolution (out IDebugBreakpointResolution2 resolution)
+ {
+ resolution = Resolution;
+ return COM.S_OK;
+ }
+
+ // Return the pending breakpoint for this bound breakpoint.
+ public int GetPendingBreakpoint (out IDebugPendingBreakpoint2 pending)
+ {
+ pending = PendingBreakpoint;
+ return COM.S_OK;
+ }
+
+ //
+ public int GetState (out uint state)
+ {
+ state = 0;
+ if (deleted)
+ state = (uint) enum_BP_STATE.BPS_DELETED;
+ else if (enabled)
+ state = (uint) enum_BP_STATE.BPS_ENABLED;
+ else if (!enabled)
+ state = (uint) enum_BP_STATE.BPS_DISABLED;
+ return COM.S_OK;
+ }
+
+ // The sample engine does not support hit counts on breakpoints. A real-world debugger will want to keep track
+ // of how many times a particular bound breakpoint has been hit and return it here.
+ int IDebugBoundBreakpoint2.GetHitCount (out uint pdwHitCount)
+ {
+ pdwHitCount = 0;
+ return COM.S_OK;
+ throw new NotImplementedException ();
+ }
+
+ // The sample engine does not support conditions on breakpoints.
+ // A real-world debugger will use this to specify when a breakpoint will be hit
+ // and when it should be ignored.
+ int IDebugBoundBreakpoint2.SetCondition (BP_CONDITION bpCondition)
+ {
+ throw new NotImplementedException ();
+ }
+
+ // The sample engine does not support hit counts on breakpoints. A real-world debugger will want to keep track
+ // of how many times a particular bound breakpoint has been hit. The debugger calls SetHitCount when the user
+ // resets a breakpoint's hit count.
+ int IDebugBoundBreakpoint2.SetHitCount (uint dwHitCount)
+ {
+ throw new NotImplementedException ();
+ }
+
+ // The sample engine does not support pass counts on breakpoints.
+ // This is used to specify the breakpoint hit count condition.
+ int IDebugBoundBreakpoint2.SetPassCount (BP_PASSCOUNT bpPassCount)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion
+ }
+}
View
112 MonoVS/Mono.VisualStudio.Debugger/BreakpointManager.cs
@@ -0,0 +1,112 @@
+using System;
+using System.Collections.Generic;
+using Microsoft.VisualStudio.Debugger.Interop;
+using Mono.VisualStudio.Mdb;
+
+namespace Mono.VisualStudio.Debugger
+{
+ // This class manages breakpoints for the engine.
+ public class BreakpointManager
+ {
+ public Process Process
+ {
+ get;
+ private set;
+ }
+
+ internal IBreakpointManager ServerManager
+ {
+ get;
+ private set;
+ }
+
+ List<PendingBreakpoint> pending_breakpoints;
+ Dictionary<IServerBreakpoint, BoundBreakpoint> bound_breakpoints;
+ Dictionary<IServerBreakpoint, PendingBreakpoint> pending_requests;
+
+ public BreakpointManager (Process process, IDebuggerServer server)
+ {
+ this.Process = process;
+
+ ServerManager = server.CreateBreakpointManager (new EventSink (this));
+
+ pending_breakpoints = new List<PendingBreakpoint> ();
+ bound_breakpoints = new Dictionary<IServerBreakpoint, BoundBreakpoint> ();
+ pending_requests = new Dictionary<IServerBreakpoint, PendingBreakpoint> ();
+ }
+
+ internal PendingBreakpoint CreatePendingBreakpoint (IDebugBreakpointRequest2 request)
+ {
+ PendingBreakpoint pending = new PendingBreakpoint (this, request);
+ pending_breakpoints.Add (pending);
+ return pending;
+ }
+
+ internal bool BindBreakpoint (PendingBreakpoint pending, ISourceLocation location)
+ {
+ IServerBreakpoint handle = ServerManager.InsertBreakpoint (location);
+ if (handle == null)
+ return false;
+
+ pending_requests.Add (handle, pending);
+ return true;
+ }
+
+ public BoundBreakpoint GetBoundBreakpoint (IServerBreakpoint handle)
+ {
+ return bound_breakpoints[handle];
+ }
+
+ #region Event Sink
+
+ protected void OnBreakpointBound (IServerBreakpoint handle)
+ {
+ PendingBreakpoint pending = pending_requests [handle];
+ BoundBreakpoint bound = new BoundBreakpoint (
+ Process.Engine, pending, new BreakpointResolution (Process), handle);
+ pending_requests.Remove (handle);
+ bound_breakpoints.Add (handle, bound);
+ Process.Engine.EngineCallback.OnBreakpointBound (bound);
+ }
+
+ protected void OnBreakpointError (IServerBreakpoint handle, string message)
+ {
+ PendingBreakpoint pending = pending_requests [handle];
+ ErrorBreakpointResolution error = new ErrorBreakpointResolution (Process, message);
+ ErrorBreakpoint breakpoint = new ErrorBreakpoint (pending, error);
+
+ pending.ErrorBreakpoint = breakpoint;
+ Process.Engine.EngineCallback.OnBreakpointError (breakpoint);
+ }
+
+ protected class EventSink : MarshalByRefObject, IBreakpointManagerEventSink
+ {
+ public BreakpointManager Manager
+ {
+ get;
+ private set;
+ }
+
+ public EventSink (BreakpointManager manager)
+ {
+ this.Manager = manager;
+ }
+
+ #region IBreakpointManagerEventSink Members
+
+ void IBreakpointManagerEventSink.OnBreakpointBound (IServerBreakpoint breakpoint)
+ {
+ Manager.OnBreakpointBound (breakpoint);
+ }
+
+ void IBreakpointManagerEventSink.OnBreakpointError (IServerBreakpoint breakpoint, string message)
+ {
+ Manager.OnBreakpointError (breakpoint, message);
+ }
+
+ #endregion
+ }
+
+ #endregion
+ }
+}
View
116 MonoVS/Mono.VisualStudio.Debugger/BreakpointResolution.cs
@@ -0,0 +1,116 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Microsoft.VisualStudio.Debugger.Interop;
+using System.Runtime.InteropServices;
+
+namespace Mono.VisualStudio.Debugger
+{
+ // This class represents the information that describes a bound breakpoint.
+ public class BreakpointResolution : IDebugBreakpointResolution2
+ {
+ private readonly Process Process;
+
+ public BreakpointResolution (Process process)
+ {
+ this.Process = process;
+ }
+
+ #region IDebugBreakpointResolution2 Members
+
+ // Gets the type of the breakpoint represented by this resolution.
+ public int GetBreakpointType (out uint type)
+ {
+ type = (uint) enum_BP_TYPE.BPT_CODE;
+ return COM.S_OK;
+ }
+
+ public int GetResolutionInfo (uint fields, BP_RESOLUTION_INFO[] info)
+ {
+#if FIXME
+ if ((fields & (uint) enum_BPRESI_FIELDS.BPRESI_BPRESLOCATION) != 0) {
+ // The sample engine only supports code breakpoints.
+ BP_RESOLUTION_LOCATION location = new BP_RESOLUTION_LOCATION ();
+ location.bpType = (uint) enum_BP_TYPE.BPT_CODE;
+
+ // The debugger will not QI the IDebugCodeContex2 interface returned here. We must pass the pointer
+ // to IDebugCodeContex2 and not IUnknown.
+ AD7MemoryAddress codeContext = new AD7MemoryAddress (Engine, m_address);
+ codeContext.SetDocumentContext (m_documentContext);
+ location.unionmember1 = Marshal.GetComInterfaceForObject (codeContext, typeof (IDebugCodeContext2));
+ info[0].bpResLocation = location;
+ info[0].dwFields |= (uint) enum_BPRESI_FIELDS.BPRESI_BPRESLOCATION;
+
+ }
+#endif
+
+ if ((fields & (uint) enum_BPRESI_FIELDS.BPRESI_PROGRAM) != 0) {
+ info[0].pProgram = Process;
+ info[0].dwFields |= (uint) enum_BPRESI_FIELDS.BPRESI_PROGRAM;
+ }
+
+ return COM.S_OK;
+ }
+
+ #endregion
+ }
+
+ public class ErrorBreakpointResolution : IDebugErrorBreakpointResolution2
+ {
+ public Process Process
+ {
+ get;
+ private set;
+ }
+
+ public string Message
+ {
+ get;
+ private set;
+ }
+
+ public ErrorBreakpointResolution (Process process, string message)
+ {
+ this.Process = process;
+ this.Message = message;
+ }
+
+ #region IDebugErrorBreakpointResolution2 Members
+
+ public uint ErrorType
+ {
+ get
+ {
+ return (uint) enum_BP_ERROR_TYPE.BPET_GENERAL_ERROR;
+ }
+ }
+
+ public int GetBreakpointType (out uint type)
+ {
+ type = ErrorType;
+ return COM.S_OK;
+ }
+
+ public int GetResolutionInfo (uint fields, BP_ERROR_RESOLUTION_INFO[] info)
+ {
+ if ((fields & (uint) enum_BPERESI_FIELDS.BPERESI_PROGRAM) != 0) {
+ info[0].pProgram = Process;
+ info[0].dwFields |= (uint) enum_BPERESI_FIELDS.BPERESI_PROGRAM;
+ }
+
+ if ((fields & (uint) enum_BPERESI_FIELDS.BPERESI_MESSAGE) != 0) {
+ info[0].bstrMessage = Message;
+ info[0].dwFields |= (uint) enum_BPERESI_FIELDS.BPERESI_MESSAGE;
+ }
+
+ if ((fields & (uint) enum_BPERESI_FIELDS.BPERESI_TYPE) != 0) {
+ info[0].dwType = ErrorType;
+ info[0].dwFields |= (uint) enum_BPERESI_FIELDS.BPERESI_TYPE;
+ }
+
+ return COM.S_OK;
+ }
+
+ #endregion
+ }
+}
View
14 MonoVS/Mono.VisualStudio.Debugger/COM.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Mono.VisualStudio.Debugger
+{
+ public static class COM
+ {
+ public const int S_OK = 0;
+ public const int S_FALSE = 1;
+ public const int E_NOTIMPL = unchecked ((int)0x80004001);
+ public const int RPC_E_SERVERFAULT = unchecked ((int)0x80010105);
+ }
+}
View
115 MonoVS/Mono.VisualStudio.Debugger/ChangeLog
@@ -0,0 +1,115 @@
+2008-06-18 Jonathan Chambers <joncham@gmail.com>
+
+ * Mono.VisualStudio.Debugger.csproj: Add Settings.cs.
+
+ * PortSupplier: Use Settings for server info.
+
+ * Settings.cs: Added.
+
+ Code contributed under both MIT/X11 and MS-PL license.
+
+2008-06-18 Jonathan Chambers <joncham@gmail.com>
+
+ * DebugController.cs: Add something to OnMainProcessCreated method as
+ COM Interop registration was failing.
+
+ Code contributed under both MIT/X11 and MS-PL license.
+
+2008-06-17 Jonathan Chambers <joncham@gmail.com>
+
+ * AD7Events.cs: Pass program and process arguments to events when possible.
+
+ * DebugProcess.cs: Pass in executable name in .ctor
+
+ * Engine.cs: Implement Attach and start support for breakpoints.
+
+ * EngineCallback.cs: Pass program and process arguments to events when possible.
+
+ * Port.cs: Pass in executable name in DebugProcess .ctor.
+
+ * ProgramNode.cs: Implement some methods on IDebugProgram2.
+
+ * Utils.cs: Have RequireOk and CheckOk throw a usefule exception.
+
+ Code contributed under MIT/X11 license.
+ AD7Events.cs code contributed under MS-PL.
+
+2008-06-17 Jonathan Chambers <joncham@gmail.com>
+
+ * AD7Events.cs: Add additional arguments to program create events
+
+ * DebugProcess.cs: Add implementation for IDebugProcessEx2.
+
+ * Engine.cs: Make IDebugEngineLaunch2 implementation implicit.
+
+ * Port.cs: Remove most ResumeProcess logic. We no longer hit this before attach.
+
+ * ProgramNode.cs: Remove unneeded IDebugProgramNodeAttach2. Add implementation for
+ IDebugProgram2.
+
+ Code contributed under MIT/X11 license.
+ AD7Events.cs code contributed under MS-PL.
+
+2008-06-17 Jonathan Chambers <joncham@gmail.com>
+
+ * AD7Events.cs: Make AD7ProcessCreateEvent and AD7ProgramCreateEvent synchronous
+ per http://msdn.microsoft.com/en-us/library/bb145067.aspx.
+
+ * Port.cs: Fire AD7ProgramCreateEvent in AddProgramNode per
+ http://msdn.microsoft.com/en-us/library/bb145067.aspx.
+
+ Code contributed under MIT/X11 license.
+
+ AD7Events.cs code contributed under MS-PL.
+
+2008-06-17 Jonathan Chambers <joncham@gmail.com>
+
+ * AD7Events.cs: Add AD7ProcessCreateEvent to implement IDebugProcessCreateEvent2.
+
+ * Engine.cs: Move ResumeProcess logic to Port.
+
+ * Port.cs: Implement ResumeProcess. Send IDebugProcessCreateEvent2 event.
+
+ Code contributed under MIT/X11 license.
+
+2008-06-17 Jonathan Chambers <joncham@gmail.com>
+
+ * PortSupplier.cs: Add Port.cs and move Port class to there. Use tabs.
+
+ Code contributed under MIT/X11 license.
+
+2008-06-17 Jonathan Chambers <joncham@gmail.com>
+
+ * PortSupplier.cs: Factor out connection point logic to separate class
+ (DebugPortEvents2ConnectionPoint).
+
+ Code contributed under MIT/X11 license.
+
+2008-06-17 Jonathan Chambers <joncham@gmail.com>
+
+ * PortSupplier.cs: Implement connection point code. Ports can fire events to these sinks.
+ Implement IDebugPortSupplierEx2 on PortSupplier. This give us the IDebugCoreServer2
+ object which is the first argument to all events (see IDebugPortEvents2.Event). Next,
+ should be able to move ResumeProcess logic to PortSupplier since we can now fire events.
+
+ Code contributed under MIT/X11 license.
+
+2008-06-11 Miguel de Icaza <miguel@novell.com>
+
+ * DebugPort.cs: Gone.
+
+ * DebuggerController.cs: Made it so only one instance is created,
+ this will do for now, and its a skeleton anyways, will have to
+ become more complicated later, with parallel interfaces mirroring
+ the tasks that we are implementing our classes.
+
+ * DebugProcess.cs: More implementation, adjust to having our own
+ port supplier.
+
+ * ProgramNode.cs: Also implement IDebugProgramNodeAttach2, for
+ debugging purposes (the documentation state that we can hook up
+ here).
+
+ * Guids.cs: Add the Guid to the ProgramPublisher (Called the "PDM" on
+ the VS docs) and our new Port suppliers.
+
View
148 MonoVS/Mono.VisualStudio.Debugger/DebuggerController.cs
@@ -0,0 +1,148 @@
+//
+// based on Lluis' DebuggerController.cs
+//
+using System;
+using System.IO;
+using System.Collections;
+using System.Collections.Generic;
+using System.Net;
+using System.Linq;
+using System.Text;
+using System.Runtime.Remoting;
+using System.Runtime.Remoting.Channels;
+using System.Runtime.Remoting.Channels.Tcp;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.Threading;
+
+using Mono.VisualStudio.Mdb;
+
+namespace Mono.VisualStudio.Debugger
+{
+ public class DebuggerController : MarshalByRefObject, IMdbController
+ {
+ AutoResetEvent running_event = new AutoResetEvent (false);
+ int pid = -1;
+
+ public IMdbManager DebuggerManager
+ {
+ get;
+ private set;
+ }
+
+ public string BaseURL
+ {
+ get;
+ private set;
+ }
+
+ static DebuggerController ()
+ {
+ RemotingConfiguration.CustomErrorsEnabled (false);
+ RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off;
+
+ IChannel ch = ChannelServices.GetChannel ("tcp");
+ if (ch == null) {
+ IDictionary dict = new Hashtable ();
+ var client_provider = new BinaryClientFormatterSinkProvider ();
+ var server_provider = new BinaryServerFormatterSinkProvider ();
+
+ dict["port"] = 0;
+ server_provider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
+ ChannelServices.RegisterChannel (new TcpChannel (dict, client_provider, server_provider), false);
+ }
+ }
+
+ public void RegisterDebugger (IMdbManager debugger)
+ {
+ this.DebuggerManager = debugger;
+
+ MonoAddin.Settings settings = MonoAddin.Settings.Instance ();
+ debugger.AddDirectoryMapping (settings.WindowsPath, settings.LinuxPath);
+ running_event.Set ();
+ }
+
+ public IDebuggerServer Launch (string exe, string args, string dir, string env, IClientEventSink sink)
+ {
+ return DebuggerManager.Launch (exe, args, dir, env, sink);
+ }
+
+ public void Kill ()
+ {
+ UriBuilder target = new UriBuilder (BaseURL + "/kill");
+ target.Query = String.Format ("pid={0}", pid);
+ Post (target.ToString ());
+ }
+
+ public void Shutdown ()
+ {
+ UriBuilder target = new UriBuilder (BaseURL + "/shutdown");
+ target.Query = "foo=bar";
+ Post (target.ToString ());
+ }
+
+ internal DebuggerController (string baseurl)
+ {
+ this.BaseURL = baseurl;
+
+ lock (this) {
+ string response = PostStart (CreateRemotingReference ());
+ if (response == "OK") {
+ Utils.Message ("STARTED IN-PROC SERVER!");
+ pid = 0;
+ } else if (response.StartsWith ("SERVER: ")) {
+ Utils.Message ("STARTED SERVER!");
+ pid = Int32.Parse (response.Substring (8));
+ } else {
+ throw new ApplicationException ("Got unknown response: " + response);
+ }
+ }
+
+ if (!running_event.WaitOne (15000, false))
+ throw new ApplicationException ("Coult not create the debugger process.");
+ }
+
+ string PostStart (string reference)
+ {
+ UriBuilder target = new UriBuilder (BaseURL + "/start");
+ Utils.Message ("START: {0} {1}", reference.Length, reference);
+
+ WebRequest wr = WebRequest.Create (target.ToString ());
+ wr.Method = "POST";
+ using (TextWriter writer = new StreamWriter (wr.GetRequestStream ())) {
+ writer.WriteLine (reference);
+ }
+
+ HttpWebResponse r = (HttpWebResponse) wr.GetResponse ();
+ using (TextReader reader = new StreamReader (r.GetResponseStream ())) {
+ string text = reader.ReadToEnd ();
+ Utils.Message ("RESPONSE: |{0}|", text);
+ return text;
+ }
+ }
+
+ string Post (string request)
+ {
+ Utils.Message ("POST: {0}", request);
+ WebRequest wr = WebRequest.Create (request);
+ wr.Method = "POST";
+ wr.ContentLength = 0;
+
+ // Flush the result
+ HttpWebResponse r = (HttpWebResponse) wr.GetResponse ();
+ using (TextReader reader = new StreamReader (r.GetResponseStream ())) {
+ string text = reader.ReadToEnd ();
+ Utils.Message ("RESPONSE: |{0}|", text);
+ return text;
+ }
+ }
+
+ string CreateRemotingReference ()
+ {
+ BinaryFormatter bf = new BinaryFormatter ();
+ ObjRef oref = RemotingServices.Marshal (this);
+ MemoryStream ms = new MemoryStream ();
+ bf.Serialize (ms, oref);
+ return Convert.ToBase64String (ms.ToArray ());
+ }
+ }
+}
View
122 MonoVS/Mono.VisualStudio.Debugger/DocumentContext.cs
@@ -0,0 +1,122 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Microsoft.VisualStudio.Debugger.Interop;
+using System.Diagnostics;
+
+namespace Mono.VisualStudio.Debugger
+{
+ // This class represents a document context to the debugger. A document context represents a location within a source file.
+ class AD7DocumentContext : IDebugDocumentContext2
+ {
+ string m_fileName;
+ TEXT_POSITION m_begPos;
+ TEXT_POSITION m_endPos;
+ AD7MemoryAddress m_codeContext;
+
+
+ public AD7DocumentContext(string fileName, TEXT_POSITION begPos, TEXT_POSITION endPos, AD7MemoryAddress codeContext)
+ {
+ m_fileName = fileName;
+ m_begPos = begPos;
+ m_endPos = endPos;
+ m_codeContext = codeContext;
+ }
+
+ #region IDebugDocumentContext2 Members
+
+ // Compares this document context to a given array of document contexts.
+ int IDebugDocumentContext2.Compare(uint Compare, IDebugDocumentContext2[] rgpDocContextSet, uint dwDocContextSetLen, out uint pdwDocContext)
+ {
+ dwDocContextSetLen = 0;
+ pdwDocContext = 0;
+
+ return COM.E_NOTIMPL;
+ }
+
+ // Retrieves a list of all code contexts associated with this document context.
+ // The engine sample only supports one code context per document context and
+ // the code contexts are always memory addresses.
+ int IDebugDocumentContext2.EnumCodeContexts(out IEnumDebugCodeContexts2 ppEnumCodeCxts)
+ {
+ ppEnumCodeCxts = null;
+ try
+ {
+ AD7MemoryAddress[] codeContexts = new AD7MemoryAddress[1];
+ codeContexts[0] = m_codeContext;
+ ppEnumCodeCxts = new AD7CodeContextEnum(codeContexts);
+ return COM.S_OK;
+ }
+ catch (Exception e)
+ {
+ return Utils.UnexpectedException(e);
+ }
+ }
+
+ // Gets the document that contains this document context.
+ // This method is for those debug engines that supply documents directly to the IDE. Since the sample engine
+ // does not do this, this method returns E_NOTIMPL.
+ int IDebugDocumentContext2.GetDocument(out IDebugDocument2 ppDocument)
+ {
+ ppDocument = null;
+ return COM.S_FALSE;
+ }
+
+ // Gets the language associated with this document context.
+ // The language for this sample is always C++
+ int IDebugDocumentContext2.GetLanguageInfo(ref string pbstrLanguage, ref Guid pguidLanguage)
+ {
+ pbstrLanguage = "C++";
+ pguidLanguage = Guids.guidLanguageCpp;
+ return COM.S_OK;
+ }
+
+ // Gets the displayable name of the document that contains this document context.
+ int IDebugDocumentContext2.GetName(uint gnType, out string pbstrFileName)
+ {
+ pbstrFileName = m_fileName;
+ return COM.S_OK;
+ }
+
+ // Gets the source code range of this document context.
+ // A source range is the entire range of source code, from the current statement back to just after the previous s
+ // statement that contributed code. The source range is typically used for mixing source statements, including
+ // comments, with code in the disassembly window.
+ // Sincethis engine does not support the disassembly window, this is not implemented.
+ int IDebugDocumentContext2.GetSourceRange(TEXT_POSITION[] pBegPosition, TEXT_POSITION[] pEndPosition)
+ {
+ throw new NotImplementedException("This method is not implemented");
+ }
+
+ // Gets the file statement range of the document context.
+ // A statement range is the range of the lines that contributed the code to which this document context refers.
+ int IDebugDocumentContext2.GetStatementRange(TEXT_POSITION[] pBegPosition, TEXT_POSITION[] pEndPosition)
+ {
+ try
+ {
+ pBegPosition[0].dwColumn = m_begPos.dwColumn;
+ pBegPosition[0].dwLine = m_begPos.dwLine;
+
+ pEndPosition[0].dwColumn = m_endPos.dwColumn;
+ pEndPosition[0].dwLine = m_endPos.dwLine;
+ }
+ catch (Exception e)
+ {
+ return Utils.UnexpectedException(e);
+ }
+
+ return COM.S_OK;
+ }
+
+ // Moves the document context by a given number of statements or lines.
+ // This is used primarily to support the Autos window in discovering the proximity statements around
+ // this document context.
+ int IDebugDocumentContext2.Seek(int nCount, out IDebugDocumentContext2 ppDocContext)
+ {
+ ppDocContext = null;
+ return COM.E_NOTIMPL;
+ }
+
+ #endregion
+ }
+}
View
205 MonoVS/Mono.VisualStudio.Debugger/Engine.cs
@@ -0,0 +1,205 @@
+using System;
+using System.Linq;
+using System.Collections.Generic;
+using System.Text;
+using System.Runtime.InteropServices;
+using Microsoft.VisualStudio.Debugger.Interop;
+using System.Diagnostics;
+using System.Threading;
+
+using Mono.VisualStudio.Mdb;
+
+namespace Mono.VisualStudio.Debugger
+{
+ // Engine is the primary entrypoint object for the sample engine.
+ //
+ // It implements:
+ //
+ // IDebugEngine2: This interface represents a debug engine (DE). It is used to manage various aspects of a debugging session,
+ // from creating breakpoints to setting and clearing exceptions.
+ //
+ // IDebugEngineLaunch2: Used by a debug engine (DE) to launch and terminate programs.
+ //
+ // IDebugProgram3: This interface represents a program that is running in a process. Since this engine only debugs one process at a time and each
+ // process only contains one program, it is implemented on the engine.
+ //
+ // IDebugEngineProgram2: This interface provides simultanious debugging of multiple threads in a debuggee.
+
+ [ComVisible (true)]
+ [Guid (Guids.EngineClass)]
+ public class Engine : IDebugEngine2, IDebugEngineLaunch2
+ {
+ internal EngineCallback EngineCallback
+ {
+ get;
+ private set;
+ }
+
+ public Process Process
+ {
+ get;
+ private set;
+ }
+
+ public DebuggerController Controller
+ {
+ get;
+ private set;
+ }
+
+ /// <summary>
+ /// This is the engine GUID of the sample engine. It needs to be changed here and in the registration
+ /// when creating a new engine.
+ /// </summary>
+ public const string Id = Guids.Engine;
+
+ #region IDebugEngine2 Members
+
+ int IDebugEngine2.Attach (IDebugProgram2[] rgpPrograms, IDebugProgramNode2[] rgpProgramNodes, uint celtPrograms, IDebugEventCallback2 pCallback, uint dwReason)
+ {
+ Utils.Message ("ATTACH!");
+ EngineCreateEvent.Send (this);
+ return COM.S_OK;
+ }
+
+ int IDebugEngine2.CauseBreak ()
+ {
+ return Process.CauseBreak ();
+ }
+
+ public int ContinueFromSynchronousEvent (IDebugEvent2 e)
+ {
+ Utils.Message ("CONTINUE FROM SYNC EVENT: {0}", e);
+ if ((e is AD7LoadCompleteEvent) || (e is AD7EntryPointEvent)) {
+ Utils.Message ("LOAD COMPLETE DONE!");
+ Process.ServerProcess.ResumeProcess ();
+ }
+ return COM.S_OK;
+ }
+
+ public int CreatePendingBreakpoint (IDebugBreakpointRequest2 request,
+ out IDebugPendingBreakpoint2 pending)
+ {
+ pending = Process.BreakpointManager.CreatePendingBreakpoint (request);
+ return COM.S_OK;
+ }
+
+ int IDebugEngine2.DestroyProgram (IDebugProgram2 pProgram)
+ {
+ throw new NotImplementedException ();
+ }
+
+ int IDebugEngine2.EnumPrograms (out IEnumDebugPrograms2 ppEnum)
+ {
+ ppEnum = new AD7ProgramEnum (new IDebugProgram2[] { Process });
+ return COM.S_OK;
+ }
+
+ int IDebugEngine2.GetEngineId (out Guid guid)
+ {
+ guid = new Guid (Id);
+ return COM.S_OK;
+ }
+
+ int IDebugEngine2.RemoveAllSetExceptions (ref Guid guidType)
+ {
+ throw new NotImplementedException ();
+ }
+
+ int IDebugEngine2.RemoveSetException (EXCEPTION_INFO[] pException)
+ {
+ throw new NotImplementedException ();
+ }
+
+ int IDebugEngine2.SetException (EXCEPTION_INFO[] pException)
+ {
+ throw new NotImplementedException ();
+ }
+
+ int IDebugEngine2.SetLocale (ushort wLangID)
+ {
+ return COM.S_OK;
+ }
+
+ int IDebugEngine2.SetMetric (string pszMetric, object varValue)
+ {
+ return COM.S_OK;
+ }
+
+ int IDebugEngine2.SetRegistryRoot (string pszRegistryRoot)
+ {
+ // The sample engine does not read settings from the registry.
+ return COM.S_OK;
+ }
+
+ #endregion
+
+ #region IDebugEngineLaunch2 Members
+
+ public int CanTerminateProcess (IDebugProcess2 process)
+ {
+ return COM.S_OK;
+ }
+
+ public int LaunchSuspended (string pszServer, IDebugPort2 pPort, string exe, string args,
+ string dir, string env, string pszOptions, uint dwLaunchFlags,
+ uint hStdInput, uint hStdOutput, uint hStdError, IDebugEventCallback2 callback,
+ out IDebugProcess2 process)
+ {
+ Port port = (Port) pPort;
+ EngineCallback = new EngineCallback (this, callback);
+
+ IDebuggerServer server;
+
+ try {
+ IClientEventSink sink = new ClientEventSink (this);
+ Controller = new DebuggerController (port.PortAddress);
+ server = Controller.Launch (exe, args, dir, env, sink);
+ } catch (Exception ex) {
+ EngineCallback.OnError ("Failed to launch debugger: {0}", ex);
+ process = null;
+ return COM.S_FALSE;
+ }
+
+ process = Process = new Process (port, this, exe, server);
+ AD7ProcessCreateEvent.Send (this, Process);
+ return COM.S_OK;
+ }
+
+ public int ResumeProcess (IDebugProcess2 process)
+ {
+ // This has to be done here and not in LaunchSuspended(). Martin.
+ Debug.Assert (process == Process);
+ Process.Port.AddProgramNode (Process);
+ AD7ProgramCreateEvent.Send (Process.Port, Process, Process);
+
+ Process.Start ();
+
+ return COM.S_OK;
+ }
+
+ public int TerminateProcess (IDebugProcess2 process)
+ {
+ Process.Terminate ();
+ Controller.Kill ();
+
+ Process.Port.RemoveProgramNode (Process);
+ AD7ProgramDestroyEvent.Send (Process.Port, Process, Process);
+ EngineCallback.OnProgramDestroy (Process, 255);
+
+ return COM.S_OK;
+ }
+
+ #endregion
+
+ class ClientEventSink : MarshalByRefObject, IClientEventSink
+ {
+ public readonly Engine Engine;
+
+ public ClientEventSink (Engine engine)
+ {
+ this.Engine = engine;
+ }
+ }
+ }
+}
View
103 MonoVS/Mono.VisualStudio.Debugger/EngineCallback.cs
@@ -0,0 +1,103 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Microsoft.VisualStudio.Debugger.Interop;
+using System.Diagnostics;
+using System.Collections.ObjectModel;
+
+namespace Mono.VisualStudio.Debugger
+{
+ class EngineCallback
+ {
+ public IDebugEventCallback2 Callback { get; private set; }
+ public Engine Engine { get; private set; }
+
+ public EngineCallback (Engine engine, IDebugEventCallback2 callback)
+ {
+ Callback = callback;
+ Engine = engine;
+ }
+
+ public void Send (IDebugEvent2 e, string iid, IDebugProgram2 program, IDebugThread2 thread)
+ {
+ uint attrs;
+ Guid guid = new Guid (iid);
+
+ Utils.RequireOk (e.GetAttributes (out attrs));
+ Utils.Message ("SEND EVENT: {0} {1} {2} {4} - {5:x}",
+ this, e, iid, program, thread, attrs);
+
+ Utils.RequireOk (Callback.Event (Engine, null, program, thread, e, ref guid, attrs));
+ }
+
+ public void Send (IDebugEvent2 e, string iid, IDebugThread2 thread)
+ {
+ Send (e, iid, Engine.Process, thread);
+ }
+
+ public void OnError (string message, params object[] args)
+ {
+ string text = String.Format (message, args);
+ Utils.Message ("ERROR: {0}", text);
+ AD7ErrorEvent e = new AD7ErrorEvent (text);
+ Send (e, AD7ErrorEvent.IID, null);
+ }
+
+ public void OnThreadStart (Thread thread)
+ {
+ AD7ThreadCreateEvent e = new AD7ThreadCreateEvent ();
+ Utils.Message ("THREAD CREATE: {0}", thread.ID);
+ Send (e, AD7ThreadCreateEvent.IID, thread);
+ }
+
+ public void OnThreadDestroy (Thread thread)
+ {
+ AD7ThreadDestroyEvent e = new AD7ThreadDestroyEvent (0);
+ Utils.Message ("THREAD DESTROY: {0}", thread.ID);
+ Send (e, AD7ThreadDestroyEvent.IID, thread);
+ }
+
+ public void OnLoadComplete (Thread thread)
+ {
+ AD7EntryPointEvent e = new AD7EntryPointEvent ();
+ Send (e, AD7EntryPointEvent.IID, thread);
+ }
+
+ public void OnStepComplete (Thread thread)
+ {
+ AD7StepCompleteEvent e = new AD7StepCompleteEvent ();
+ Send (e, AD7StepCompleteEvent.IID, thread);
+ }
+
+ public void OnProgramDestroy (Process process, uint exitCode)
+ {
+ AD7ProgramDestroyEvent e = new AD7ProgramDestroyEvent (exitCode);
+ Send (e, AD7ProgramDestroyEvent.IID, process, null);
+ }
+
+ // Engines notify the debugger that a breakpoint has bound through the breakpoint bound event.
+ public void OnBreakpointBound (BoundBreakpoint bound)
+ {
+ AD7BreakpointBoundEvent e = new AD7BreakpointBoundEvent (bound);
+ Send (e, AD7BreakpointBoundEvent.IID, null);
+ }
+
+ public void OnBreakpointError (ErrorBreakpoint breakpoint)
+ {
+ AD7BreakpointErrorEvent e = new AD7BreakpointErrorEvent (breakpoint);
+ Send (e, AD7BreakpointErrorEvent.IID, null);
+ }
+
+ public void OnBreakpointHit (Thread thread, BoundBreakpoint bpt)
+ {
+ AD7BreakpointEvent e = new AD7BreakpointEvent (bpt);
+ Send (e, AD7BreakpointEvent.IID, thread);
+ }
+
+ public void OnTargetOutput (string output)
+ {
+ AD7OutputDebugStringEvent e = new AD7OutputDebugStringEvent (output);
+ Send (e, AD7OutputDebugStringEvent.IID, null);
+ }
+ }
+}
View
45 MonoVS/Mono.VisualStudio.Debugger/ErrorBreakpoint.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Microsoft.VisualStudio.Debugger.Interop;
+
+namespace Mono.VisualStudio.Debugger
+{
+ public class ErrorBreakpoint : IDebugErrorBreakpoint2
+ {
+ public PendingBreakpoint PendingBreakpoint
+ {
+ get;
+ private set;
+ }
+
+ public ErrorBreakpointResolution ErrorResolution
+ {
+ get;
+ private set;
+ }
+
+ public ErrorBreakpoint (PendingBreakpoint pending, ErrorBreakpointResolution error)
+ {
+ this.PendingBreakpoint = pending;
+ this.ErrorResolution = error;
+ }
+
+ #region IDebugErrorBreakpoint2 Members
+
+ public int GetBreakpointResolution (out IDebugErrorBreakpointResolution2 error)
+ {
+ error = ErrorResolution;
+ return COM.S_OK;
+ }
+
+ public int GetPendingBreakpoint (out IDebugPendingBreakpoint2 pending)
+ {
+ pending = PendingBreakpoint;
+ return COM.S_OK;
+ }
+
+ #endregion
+ }
+}
View
28 MonoVS/Mono.VisualStudio.Debugger/Guids.cs
@@ -0,0 +1,28 @@
+//
+// Shared definitions
+//
+
+using System;
+
+namespace Mono.VisualStudio.Debugger
+{
+ public class Guids
+ {
+ public const string EngineClass = "13EA87A8-A478-4c27-BD54-A1DD732EE56A";
+ public const string ProgramProviderClass = "F3E09C35-C71A-4d52-A849-48AC6CFE40B3";
+
+ public const string Engine = "FEEB0E6F-B2FA-4640-981C-C7BA64C7098E";
+
+ public const string PortSupplier = "345CD6F9-4BDA-40b3-90B1-5D3B735D1AE3";
+ public const string PortSupplierClass = "2EEE1F44-F1B4-4dda-B47E-89B779AF24FD";
+
+ public const string VS_ProgramPublisher = "d04d550d-1ea8-4e37-830e-700fea447688";
+
+ // Language guid for C++. Used when the language for a document context or a stack frame is requested.
+ static private Guid _guidLanguageCpp = new Guid("3a12d0b7-c26c-11d0-b442-00a0244a1dd2");
+ static public Guid guidLanguageCpp
+ {
+ get { return _guidLanguageCpp; }
+ }
+ }
+}
View
184 MonoVS/Mono.VisualStudio.Debugger/MemoryAddress.cs
@@ -0,0 +1,184 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Microsoft.VisualStudio.Debugger.Interop;
+
+namespace Mono.VisualStudio.Debugger
+{
+ // And implementation of IDebugCodeContext2 and IDebugMemoryContext2.
+ // IDebugMemoryContext2 represents a position in the address space of the machine running the program being debugged.
+ // IDebugCodeContext2 represents the starting position of a code instruction.
+ // For most run-time architectures today, a code context can be thought of as an address in a program's execution stream.
+ class AD7MemoryAddress : IDebugCodeContext2
+ {
+ readonly Engine m_engine;
+ readonly ulong m_address;
+ IDebugDocumentContext2 m_documentContext;
+
+ public AD7MemoryAddress(Engine engine, ulong address)
+ {
+ m_engine = engine;
+ m_address = address;
+ }
+
+ public void SetDocumentContext(IDebugDocumentContext2 docContext)
+ {
+ m_documentContext = docContext;
+ }
+
+ #region IDebugMemoryContext2 Members
+
+ // Adds a specified value to the current context's address to create a new context.
+ public int Add(ulong dwCount, out IDebugMemoryContext2 newAddress)
+ {
+ newAddress = new AD7MemoryAddress(m_engine, (uint)dwCount + m_address);
+ return COM.S_OK;
+ }
+
+ // Compares the memory context to each context in the given array in the manner indicated by compare flags,
+ // returning an index of the first context that matches.
+ public int Compare(uint uContextCompare, IDebugMemoryContext2[] compareToItems, uint compareToLength, out uint foundIndex)
+ {
+ foundIndex = uint.MaxValue;
+
+ try
+ {
+ enum_CONTEXT_COMPARE contextCompare = (enum_CONTEXT_COMPARE)uContextCompare;
+
+ for (uint c = 0; c < compareToLength; c++)
+ {
+ AD7MemoryAddress compareTo = compareToItems[c] as AD7MemoryAddress;
+ if (compareTo == null)
+ {
+ continue;
+ }
+
+ if (!Engine.ReferenceEquals(this.m_engine, compareTo.m_engine))
+ {
+ continue;
+ }
+
+ bool result;
+
+ switch (contextCompare)
+ {
+ case enum_CONTEXT_COMPARE.CONTEXT_EQUAL:
+ result = (this.m_address == compareTo.m_address);
+ break;
+
+ case enum_CONTEXT_COMPARE.CONTEXT_LESS_THAN:
+ result = (this.m_address < compareTo.m_address);
+ break;
+
+ case enum_CONTEXT_COMPARE.CONTEXT_GREATER_THAN:
+ result = (this.m_address > compareTo.m_address);
+ break;
+
+ case enum_CONTEXT_COMPARE.CONTEXT_LESS_THAN_OR_EQUAL:
+ result = (this.m_address <= compareTo.m_address);
+ break;
+
+ case enum_CONTEXT_COMPARE.CONTEXT_GREATER_THAN_OR_EQUAL:
+ result = (this.m_address >= compareTo.m_address);
+ break;
+
+ // The sample debug engine doesn't understand scopes or functions
+ case enum_CONTEXT_COMPARE.CONTEXT_SAME_SCOPE:
+ case enum_CONTEXT_COMPARE.CONTEXT_SAME_FUNCTION:
+ result = (this.m_address == compareTo.m_address);
+ break;
+
+ case enum_CONTEXT_COMPARE.CONTEXT_SAME_PROCESS:
+ result = true;
+ break;
+
+ default:
+ // A new comparison was invented that we don't support
+ return COM.E_NOTIMPL;
+ }
+
+ if (result)
+ {
+ foundIndex = c;
+ return COM.S_OK;
+ }
+ }
+
+ return COM.S_FALSE;
+ }
+ catch (Exception e)
+ {
+ return Utils.UnexpectedException(e);
+ }
+ }
+
+ // Gets information that describes this context.
+ public int GetInfo(uint dwFields, CONTEXT_INFO[] pinfo)
+ {
+ try
+ {
+ pinfo[0].dwFields = 0;
+
+ if ((dwFields & (uint)enum_CONTEXT_INFO_FIELDS.CIF_ADDRESS) != 0)
+ {
+ pinfo[0].bstrAddress = m_address.ToString();
+ pinfo[0].dwFields |= (uint)enum_CONTEXT_INFO_FIELDS.CIF_ADDRESS;
+ }
+
+ // Fields not supported by the sample
+ if ((dwFields & (uint)enum_CONTEXT_INFO_FIELDS.CIF_ADDRESSOFFSET) != 0){}
+ if ((dwFields & (uint)enum_CONTEXT_INFO_FIELDS.CIF_ADDRESSABSOLUTE) != 0){}
+ if ((dwFields & (uint)enum_CONTEXT_INFO_FIELDS.CIF_MODULEURL) != 0){}
+ if ((dwFields & (uint)enum_CONTEXT_INFO_FIELDS.CIF_FUNCTION) != 0) {}
+ if ((dwFields & (uint)enum_CONTEXT_INFO_FIELDS.CIF_FUNCTIONOFFSET) != 0) {}
+
+ return COM.S_OK;
+ }
+ catch (Exception e)
+ {
+ return Utils.UnexpectedException(e);
+ }
+ }
+
+ // Gets the user-displayable name for this context
+ // This is not supported by the sample engine.
+ public int GetName(out string pbstrName)
+ {
+ throw new Exception("The method or operation is not implemented.");
+ }
+
+ // Subtracts a specified value from the current context's address to create a new context.
+ public int Subtract(ulong dwCount, out IDebugMemoryContext2 ppMemCxt)
+ {
+ ppMemCxt = new AD7MemoryAddress(m_engine, (uint)dwCount - m_address);
+ return COM.S_OK;
+ }
+
+ #endregion
+
+ #region IDebugCodeContext2 Members
+
+ // Gets the document context for this code-context
+ public int GetDocumentContext(out IDebugDocumentContext2 ppSrcCxt)
+ {
+ ppSrcCxt = m_documentContext;
+ return COM.S_OK;
+ }
+
+ // Gets the language information for this code context.
+ public int GetLanguageInfo(ref string pbstrLanguage, ref Guid pguidLanguage)
+ {
+ if (m_documentContext != null)
+ {
+ m_documentContext.GetLanguageInfo(ref pbstrLanguage, ref pguidLanguage);
+ return COM.S_OK;
+ }
+ else
+ {
+ return COM.S_FALSE;
+ }
+ }
+
+ #endregion
+ }
+}
View
50 MonoVS/Mono.VisualStudio.Debugger/Module.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Microsoft.VisualStudio.Debugger.Interop;
+
+namespace Mono.VisualStudio.Debugger
+{
+ public class Module : IDebugModule2, IDebugModule3
+ {
+ #region IDebugModule2 Members
+
+ public int GetInfo (uint dwFields, MODULE_INFO[] pinfo)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public int ReloadSymbols_Deprecated (string pszUrlToSymbols, out string pbstrDebugMessage)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion
+
+ #region IDebugModule3 Members
+
+
+ public int GetSymbolInfo (uint dwFields, MODULE_SYMBOL_SEARCH_INFO[] pinfo)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public int IsUserCode (out int pfUser)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public int LoadSymbols ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public int SetJustMyCodeState (int fIsUserCode)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion
+ }
+}
View
8 MonoVS/Mono.VisualStudio.Debugger/Mono.VisualStudio.Debugger.config
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <configuration>
+ <system.runtime.remoting>
+
+ </system.runtime.remoting>
+ </configuration>
+</configuration>
View
109 MonoVS/Mono.VisualStudio.Debugger/Mono.VisualStudio.Debugger.csproj
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.21022</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{4F599779-48BF-496D-B341-39375BFEFB9C}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Mono.VisualStudio.Debugger</RootNamespace>
+ <AssemblyName>Mono.VisualStudio.Debugger</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <RegisterForComInterop>true</RegisterForComInterop>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Microsoft.VisualStudio.Debugger.Interop, Version=8.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+ <Reference Include="Microsoft.VisualStudio.OLE.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+ <Reference Include="Microsoft.VisualStudio.Shell.9.0, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
+ <Reference Include="Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+ <Reference Include="Microsoft.VisualStudio.Shell.Interop.8.0, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+ <Reference Include="Microsoft.VisualStudio.Shell.Interop.9.0, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Runtime.Remoting" />
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="AD7Enums.cs" />
+ <Compile Include="BoundBreakpoint.cs" />
+ <Compile Include="AD7Events.cs" />
+ <Compile Include="BreakpointManager.cs" />
+ <Compile Include="BreakpointResolution.cs" />
+ <Compile Include="DocumentContext.cs" />
+ <Compile Include="ErrorBreakpoint.cs" />
+ <Compile Include="MemoryAddress.cs" />
+ <Compile Include="PendingBreakpoint.cs" />
+ <Compile Include="COM.cs" />
+ <Compile Include="DebuggerController.cs" />
+ <Compile Include="Engine.cs" />
+ <Compile Include="EngineCallback.cs" />
+ <Compile Include="Guids.cs" />
+ <Compile Include="Module.cs" />
+ <Compile Include="Package.cs" />
+ <Compile Include="Port.cs" />
+ <Compile Include="PortSupplier.cs" />
+ <Compile Include="Process.cs" />
+ <Compile Include="ProgramNode.cs" />
+ <Compile Include="ProgramProvider.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Settings.cs" />
+ <Compile Include="StackFrame.cs" />
+ <Compile Include="Thread.cs" />
+ <Compile Include="Utils.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Resource1.resx">
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Mono.VisualStudio.Debugger.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\RemotingContract\RemotingContract.csproj">
+ <Project>{F87BA7EA-B636-4CC1-88AD-DCDAE228CCCE}</Project>
+ <Name>RemotingContract</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+ <PropertyGroup>
+ <PostBuildEvent>
+ </PostBuildEvent>
+ </PropertyGroup>
+</Project>
View
6 MonoVS/Mono.VisualStudio.Debugger/Mono.VisualStudio.Debugger.csproj.user
@@ -0,0 +1,6 @@
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <StartAction>Program</StartAction>
+ <StartProgram>devenv.exe</StartProgram>
+ </PropertyGroup>
+</Project>
View
50 MonoVS/Mono.VisualStudio.Debugger/Package.cs
@@ -0,0 +1,50 @@
+//
+// Package.cs: The basics to support packaging with Visual Studio.
+//
+// Currently disabled.
+
+#if false
+using System;
+using System.Diagnostics;
+using System.Globalization;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Runtime.InteropServices;
+using Microsoft.VisualStudio.Shell.Interop;
+using Microsoft.VisualStudio;
+
+using MsVsShell = Microsoft.VisualStudio.Shell;
+
+//
+// Currently commented out as it seems like it needs a hotfix:
+// https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=10671
+//
+// The error is that deriving from MsVsShell.Package here produces
+// the error "assembly ...Shell.Interop can
+//
+// a KB article is here:
+// http://support.microsoft.com/kb/946308
+
+namespace Mono.VisualStudio.Debugger
+{
+
+ //
+ // The number 150 is the resource ID for the PKL key
+ //
+ [MsVsShell.ProvideLoadKey ("standard", "9.0", "Mono Integration.", "Novell", 150)]
+ [MsVsShell.DefaultRegistryRoot(@"Software\Microsoft\VisualStudio\9.0")]
+ [MsVsShell.PackageRegistration(UseManagedResourcesOnly = true)]
+
+
+ [Guid ("4900AC1D-ED3A-40dc-8DD0-E72034AA9C54")]
+ public class DebuggerPackage : MsVsShell.Package
+ {
+ public DebuggerPackage ()
+ {
+ Console.WriteLine ("Here");
+ }
+ }
+
+}
+#endif
View
167 MonoVS/Mono.VisualStudio.Debugger/PendingBreakpoint.cs
@@ -0,0 +1,167 @@
+using System;
+using System.Runtime.InteropServices;
+using Microsoft.VisualStudio.Debugger.Interop;
+
+using Mono.VisualStudio.Mdb;
+
+namespace Mono.VisualStudio.Debugger
+{
+ // This class represents a pending breakpoint which is an abstract representation of a breakpoint before it is bound.
+ // When a user creates a new breakpoint, the pending breakpoint is created and is later bound. The bound breakpoints
+ // become children of the pending breakpoint.
+ public class PendingBreakpoint : IDebugPendingBreakpoint2
+ {
+ public BreakpointManager BreakpointManager
+ {
+ get;
+ private set;
+ }
+
+ public IDebugBreakpointRequest2 Request
+ {
+ get;
+ private set;
+ }
+
+ public enum_BP_LOCATION_TYPE LocationType;
+ private readonly BP_REQUEST_INFO RequestInfo;
+
+ public ErrorBreakpoint ErrorBreakpoint
+ {
+ get;
+ internal set;
+ }
+
+ public PendingBreakpoint (BreakpointManager manager, IDebugBreakpointRequest2 request)
+ {
+ this.BreakpointManager = manager;
+ this.Request = request;
+
+ var info = new BP_REQUEST_INFO[1];
+ Utils.RequireOk (Request.GetRequestInfo ((uint) enum_BPREQI_FIELDS.BPREQI_BPLOCATION, info));
+ RequestInfo = info[0];
+
+ uint type;
+ Utils.RequireOk (Request.GetLocationType (out type));
+ LocationType = (enum_BP_LOCATION_TYPE) type;
+ }
+
+ public bool CanBind ()
+ {
+ Utils.Message ("CAN BIND: {0} {1:x}", LocationType, LocationType);
+ if (LocationType == enum_BP_LOCATION_TYPE.BPLT_CODE_FILE_LINE) {
+ if ((RequestInfo.dwFields & (uint) enum_BPREQI_FIELDS.BPREQI_BPLOCATION) != 0)
+ return true;
+ }
+
+ return false;
+ }
+
+ public bool Bind ()
+ {
+ if (!CanBind ())
+ return false;
+
+ string filename;
+ IDebugDocumentPosition2 doc = (IDebugDocumentPosition2) Marshal.GetObjectForIUnknown (RequestInfo.bpLocation.unionmember2);
+ Utils.RequireOk (doc.GetFileName (out filename));
+
+ TEXT_POSITION[] start = new TEXT_POSITION[1], end = new TEXT_POSITION[1];
+ Utils.RequireOk (doc.GetRange (start, end));
+
+ Utils.Message ("BIND: {0} {1} {2} {3} {4}", filename,
+ start[0].dwLine, start[0].dwColumn, end[0].dwLine, end[0].dwColumn);
+
+ return BreakpointManager.BindBreakpoint (this, new SourceLocation {
+ FileName = filename, Line = (int) start[0].dwLine
+ });
+ }
+
+ protected class SourceLocation : MarshalByRefObject, ISourceLocation
+ {
+ public string FileName;
+ public int Line;
+
+ string ISourceLocation.FileName
+ {
+ get { return FileName; }
+ }
+
+ int ISourceLocation.Line
+ {
+ get { return Line; }
+ }
+ }
+
+ #region IDebugPendingBreakpoint2 Members
+
+ int IDebugPendingBreakpoint2.CanBind (out IEnumDebugErrorBreakpoints2 error)
+ {
+ error = null;
+ return CanBind () ? COM.S_OK : COM.S_FALSE;
+ }
+
+ int IDebugPendingBreakpoint2.Bind ()
+ {
+ try {
+ return Bind () ? COM.S_OK : COM.S_FALSE;
+ } catch (Exception ex) {
+ Utils.Message ("FUCK: {0}", ex);
+ return COM.S_FALSE;
+ }
+ }
+
+ public int Enable (int fEnable)
+ {
+ return COM.S_OK;
+ }
+
+ int IDebugPendingBreakpoint2.Delete ()
+ {
+ return COM.S_OK;
+ }
+
+ int IDebugPendingBreakpoint2.EnumBoundBreakpoints (out IEnumDebugBoundBreakpoints2 ppEnum)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public int EnumErrorBreakpoints (uint type, out IEnumDebugErrorBreakpoints2 e)
+ {
+ if (ErrorBreakpoint != null) {
+ e = new AD7ErrorBreakpointsEnum (ErrorBreakpoint);
+ return COM.S_OK;
+ }
+
+ e = null;
+ return COM.S_FALSE;
+ }
+
+ int IDebugPendingBreakpoint2.GetBreakpointRequest (out IDebugBreakpointRequest2 ppBPRequest)
+ {
+ throw new NotImplementedException ();
+ }
+
+ int IDebugPendingBreakpoint2.GetState (PENDING_BP_STATE_INFO[] pState)
+ {
+ throw new NotImplementedException ();
+ }
+
+ int IDebugPendingBreakpoint2.SetCondition (BP_CONDITION bpCondition)
+ {
+ throw new NotImplementedException ();
+ }
+
+ int IDebugPendingBreakpoint2.SetPassCount (BP_PASSCOUNT bpPassCount)
+ {
+ throw new NotImplementedException ();
+ }
+
+ int IDebugPendingBreakpoint2.Virtualize (int fVirtualize)
+ {
+ return COM.S_OK;