private void OnEnterBreakMode(EnvDTE.dbgEventReason Reason, ref EnvDTE.dbgExecutionAction ExecutionAction)
        {
            int       activeProcessId = _serviceProvider.GetDTE().Debugger.CurrentProcess.ProcessID;
            AD7Engine engine          = AD7Engine.GetEngines().SingleOrDefault(target => target.Process != null && target.Process.Id == activeProcessId);

            if (engine != null)
            {
                long?activeThreadId = ((IThreadIdMapper)engine).GetPythonThreadId((uint)_serviceProvider.GetDTE().Debugger.CurrentThread.ID);
                if (activeThreadId != null)
                {
                    AttachProcess(engine.Process, engine);
                    ChangeActiveThread(activeThreadId.Value, false);
                }
            }
        }
Exemple #2
0
        public void OnDebuggerAttached(EnvDTE.dbgEventReason Reason, ref EnvDTE.dbgExecutionAction ExecutionAction)
        {
            if (Reason == EnvDTE.dbgEventReason.dbgEventReasonBreakpoint)
            {
                try
                {
                    EnvDTE.Debugger debugger = Utils.GetDTE().Debugger;

                    if (debugger.CurrentMode == EnvDTE.dbgDebugMode.dbgBreakMode)
                    {
                        if (debugger.CurrentProgram != null && debugger.CurrentProgram.Process != null && debugger.CurrentProgram.Process.Name.EndsWith("csws.exe", StringComparison.OrdinalIgnoreCase))
                        {
                            int processId = debugger.CurrentProgram.Process.ProcessID;
                            if (processId != lastDebgProcessId)
                            {
                                lastDebgProcessId = processId;

                                bool isJustMyCodeEnabled = ((int)Registry.CurrentUser.GetValue(@"Software\Microsoft\VisualStudio\11.0\Debugger\JustMyCode", 0) == 1);

                                if (isJustMyCodeEnabled)
                                {
                                    ExecutionAction = EnvDTE.dbgExecutionAction.dbgExecutionActionStepInto;
                                }
                                else
                                {
                                    string scriptFile = ReadDebuggingMetadata(processId);
                                    if (scriptFile != null)
                                    {
                                        Utils.GetDTE().ItemOperations.OpenFile(scriptFile);
                                        ExecutionAction = EnvDTE.dbgExecutionAction.dbgExecutionActionStepInto;
                                    }
                                    else
                                    {
                                        MessageBox.Show("Debugger cannot step into the script code automatically.\nPlease either enable 'Just My Code' Debugger option or load the script file (and set the breakpoint) manually.", "CS-Script");
                                    }
                                }
                            }
                        }
                    }
                }
                catch { }
            }
        }
Exemple #3
0
        void DebuggerEvents_OnEnterRunMode(EnvDTE.dbgEventReason Reason)
        {
            if (String.IsNullOrEmpty(this.ServiceControlInstanceURI) ||
                Reason != EnvDTE.dbgEventReason.dbgEventReasonLaunchProgram)
            {
                return;
            }

            // Write DebugSessionId on Endpoints Bin folder
            var debugSessionId = String.Format("{0}@{1}@{2}", Environment.MachineName, this.InstanceName, DateTime.Now.ToUniversalTime().ToString("s")).Replace(" ", "_");

            foreach (var endpoint in this.Design.Endpoints.GetAll())
            {
                var binFolder = Path.Combine(Path.GetDirectoryName(endpoint.Project.PhysicalPath), "Bin");

                if (endpoint is INServiceBusHost)
                {
                    binFolder = Path.Combine(binFolder, "Debug");
                }

                try
                {
                    File.WriteAllText(Path.Combine(binFolder, "ServiceControl.DebugSessionId.txt"), debugSessionId);
                }
                catch { }
            }

            // If ServiceInsight is installed and invocation URI registerd
            if (this.LaunchServiceInsightOnDebug &&
                Microsoft.Win32.Registry.ClassesRoot.OpenSubKey("si") != null)
            {
                var url = String.Format("si://{0}?EndpointName={1}.{2}&Search={3}&AutoRefresh={4}",
                                        this.ServiceControlInstanceURI.Replace("http://", ""),
                                        this.InstanceName,
                                        this.Design.Endpoints.GetAll().First().InstanceName,
                                        debugSessionId,
                                        1);

                // Start ServiceInsight with parameters
                System.Diagnostics.Process.Start(url);
            }
        }
Exemple #4
0
 public void DebuggerEvents_OnEnterBreakMode(EnvDTE.dbgEventReason Reason, ref EnvDTE.dbgExecutionAction ExecutionAction)
 {
     //System.Windows.Forms.MessageBox.Show(string.Format("Run Mode Enter!\r\n{0}\r\n{1}", Reason, ExecutionAction));
     debuggingModel.OnDebuggerAttached(Reason, ref ExecutionAction);
 }
 private void OnExitDebuggerMode(EnvDTE.dbgEventReason Reason)
 {
     _monitorToolViewModel?.Clear();
 }