Example #1
0
 /// <summary>
 /// Sets the instance of currently running Visual Studio IDE.
 /// </summary>
 /// <param name="dte">The DTE.</param>
 internal static void SetDTE(DTE dte)
 {
     DTE = dte;
     if (dte != null)
     {
         debuggerEvents = DTE.Events.DebuggerEvents;
         debuggerEvents.OnEnterBreakMode  += DebuggerEvents_OnEnterBreakMode;
         debuggerEvents.OnEnterDesignMode += DebuggerEvents_OnEnterDesignMode;
         debuggerEvents.OnEnterRunMode    += DebuggerEvents_OnEnterRunMode;
         debuggerProxy = (VSDebuggerProxy)AppDomain.CurrentDomain.GetData(VSDebuggerProxy.AppDomainDataName) ?? new VSDebuggerProxy();
         VSDebugger    = new VSDebugger(debuggerProxy);
         Engine.Context.InitializeDebugger(VSDebugger, new DiaSymbolProvider());
         Engine.Context.ClrProvider = VSDebugger;
     }
     else
     {
         // 90s all over again :)
         var timer = new System.Windows.Threading.DispatcherTimer();
         timer.Tick += (a, b) =>
         {
             timer.Stop();
             if (DTE == null)
             {
                 InitializeDTE();
             }
         };
         timer.Interval = TimeSpan.FromSeconds(0.1);
         timer.Start();
     }
 }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VSDebugger"/> class.
 /// </summary>
 /// <param name="proxy">The Visual Studio debugger proxy running in Default AppDomain.</param>
 public VSDebugger(VSDebuggerProxy proxy)
 {
     Proxy = proxy;
     Context.SetUserTypeMetadata(ScriptCompiler.ExtractMetadata(new[]
     {
         typeof(SharpDebug.CommonUserTypes.NativeTypes.cv.Mat).Assembly,     // SharpDebug.CommonUserTypes.dll
     }));
 }
Example #3
0
        /// <summary>
        /// Enumerates variables from the remote connection.
        /// </summary>
        /// <param name="runtime">The Visual Studio implementation of the runtime.</param>
        /// <param name="firstBatch">Tuple of enumeration id and first batch elements.</param>
        internal static IEnumerable <Variable> EnumerateVariables(VSClrRuntime runtime, Tuple <int, Tuple <ulong, int>[]> firstBatch)
        {
            VSDebuggerProxy proxy         = runtime.Proxy;
            uint            processId     = runtime.Process.Id;
            int             enumerationId = firstBatch.Item1;

            Tuple <ulong, int>[] batch = firstBatch.Item2;
            bool destroyed             = batch.Length == EnumerationBatchSize;

            try
            {
                while (batch.Length > 0)
                {
                    foreach (Tuple <ulong, int> tuple in batch)
                    {
                        IClrType clrType = runtime.GetClrType(tuple.Item2);

                        if (clrType != null)
                        {
                            ulong    address  = tuple.Item1;
                            CodeType codeType = runtime.Process.FromClrType(clrType);
                            Variable variable;

                            if (codeType.IsPointer)
                            {
                                variable = Variable.CreatePointerNoCast(codeType, address);
                            }
                            else
                            {
                                variable = Variable.CreateNoCast(codeType, address);
                            }

                            // TODO: Can we get already upcast address and clr type from the remote connection?
                            yield return(Variable.UpcastClrVariable(variable));
                        }
                    }

                    if (destroyed)
                    {
                        break;
                    }
                    batch     = proxy.GetVariableEnumeratorNextBatch(processId, enumerationId, EnumerationBatchSize);
                    destroyed = batch.Length == EnumerationBatchSize;
                }
            }
            finally
            {
                if (!destroyed)
                {
                    proxy.DisposeVariableEnumerator(processId, enumerationId);
                }
            }
        }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RegisterAccess"/> class.
 /// </summary>
 /// <param name="threadId">Thread identifier.</param>
 /// <param name="frameId">Stack frame identifier.</param>
 /// <param name="proxy">VS debugger proxy.</param>
 public RegistersAccess(uint threadId, uint frameId, VSDebuggerProxy proxy)
 {
     this.threadId = threadId;
     this.frameId  = frameId;
     this.proxy    = proxy;
 }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VSDebugger"/> class.
 /// </summary>
 /// <param name="proxy">The Visual Studio debugger proxy running in Default AppDomain.</param>
 public VSDebugger(VSDebuggerProxy proxy)
 {
     this.proxy = proxy;
 }
Example #6
0
 /// <summary>
 /// Sets the instance of currently running Visual Studio IDE.
 /// </summary>
 /// <param name="dte">The DTE.</param>
 internal static void SetDTE(DTE dte)
 {
     DTE = dte;
     debuggerEvents = DTE.Events.DebuggerEvents;
     debuggerEvents.OnEnterBreakMode += DebuggerEvents_OnEnterBreakMode;
     debuggerEvents.OnEnterDesignMode += DebuggerEvents_OnEnterDesignMode;
     debuggerEvents.OnEnterRunMode += DebuggerEvents_OnEnterRunMode;
     debuggerProxy = (VSDebuggerProxy)AppDomain.CurrentDomain.GetData(VSDebuggerProxy.AppDomainDataName) ?? new VSDebuggerProxy();
     VSDebugger = new VSDebugger(debuggerProxy);
     Engine.Context.InitializeDebugger(VSDebugger);
 }