| | |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Linq;
|
| | | using System.Text;
|
| | | using System.Threading;
|
| | | using System.Windows.Threading;
|
| | | using Microsoft.VisualStudio;
|
| | | using Microsoft.VisualStudio.Debugger.Interop;
|
| | | using Microsoft.VisualStudio.Shell;
|
| | | using Microsoft.VisualStudio.Shell.Interop;
|
| | | using QtVsTools.VisualStudio;
|
| | |
|
| | | namespace QtVsTools.Qml.Debug.AD7
|
| | | {
|
| | | using VisualStudio;
|
| | |
|
| | | sealed partial class Program : Disposable, IDebuggerEventSink,
|
| | |
|
| | | IDebugProgramNode2, // "This interface represents a program that can be debugged."
|
| | |
| | |
|
| | | public QmlEngine Engine { get; private set; }
|
| | |
|
| | | public List<StackFrame> CurrentFrames { get; private set; }
|
| | | private List<StackFrame> CurrentFrames { get; set; }
|
| | |
|
| | | public const string Name = "QML Debugger";
|
| | | public Guid ProcessId { get; private set; }
|
| | | private const string Name = "QML Debugger";
|
| | | public Guid ProcessId { get; set; }
|
| | | public Guid ProgramId { get; set; }
|
| | | public IDebugProcess2 NativeProc { get; private set; }
|
| | | public uint NativeProcId { get; private set; }
|
| | | public string ExecPath { get; private set; }
|
| | | public string ExecArgs { get; private set; }
|
| | | public IVsDebugger VsDebugger { get; private set; }
|
| | | Dispatcher vsDebuggerThreadDispatcher;
|
| | | private IDebugProcess2 NativeProc { get; set; }
|
| | | private uint NativeProcId { get; set; }
|
| | | private string ExecPath { get; set; }
|
| | | private string ExecArgs { get; set; }
|
| | | private IVsDebugger VsDebugger { get; set; }
|
| | | private Dispatcher vsDebuggerThreadDispatcher;
|
| | |
|
| | | private readonly static object criticalSectionGlobal = new object();
|
| | | static bool originalBreakAllProcesses = BreakAllProcesses;
|
| | | static int runningPrograms = 0;
|
| | | private static readonly object criticalSectionGlobal = new object();
|
| | | private static bool originalBreakAllProcesses = BreakAllProcesses;
|
| | | private static int runningPrograms = 0;
|
| | |
|
| | | public static Program Create(
|
| | | QmlEngine engine,
|
| | |
| | | return false;
|
| | |
|
| | | VsDebugger = VsServiceProvider.GetService<IVsDebugger>();
|
| | | if (VsDebugger != null)
|
| | | VsDebugger.AdviseDebugEventCallback(this as IDebugEventCallback2);
|
| | | if (VsDebugger != null) {
|
| | | ThreadHelper.JoinableTaskFactory.Run(async () =>
|
| | | {
|
| | | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
|
| | | VsDebugger.AdviseDebugEventCallback(this);
|
| | | });
|
| | | }
|
| | | vsDebuggerThreadDispatcher = Dispatcher.CurrentDispatcher;
|
| | |
|
| | | ProcessId = Guid.NewGuid();
|
| | |
| | | protected override void DisposeManaged()
|
| | | {
|
| | | Debugger.Dispose();
|
| | | if (VsDebugger != null)
|
| | | VsDebugger.UnadviseDebugEventCallback(this as IDebugEventCallback2);
|
| | | if (VsDebugger != null) {
|
| | | ThreadHelper.JoinableTaskFactory.Run(async () =>
|
| | | {
|
| | | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
|
| | | VsDebugger.UnadviseDebugEventCallback(this as IDebugEventCallback2);
|
| | | });
|
| | | }
|
| | |
|
| | | lock (criticalSectionGlobal) {
|
| | | runningPrograms--;
|
| | |
| | | {
|
| | | var debugMode = new DBGMODE[1];
|
| | | int res = VSConstants.S_FALSE;
|
| | | vsDebuggerThreadDispatcher
|
| | | .BeginInvoke(new Action(() => res = VsDebugger.GetMode(debugMode)), new object[0])
|
| | | .Wait();
|
| | |
|
| | | QtVsToolsPackage.Instance.JoinableTaskFactory.Run(async () =>
|
| | | {
|
| | | await QtVsToolsPackage.Instance.JoinableTaskFactory.SwitchToMainThreadAsync();
|
| | | res = VsDebugger.GetMode(debugMode);
|
| | | });
|
| | |
|
| | | if (res != VSConstants.S_OK)
|
| | | return false;
|
| | |
| | | {
|
| | | get
|
| | | {
|
| | | return ((bool)QtVsToolsPackage.Instance.Dte
|
| | | .Properties["Debugging", "General"]
|
| | | .Item("BreakAllProcesses")
|
| | | .Value);
|
| | | return ThreadHelper.JoinableTaskFactory.Run(async () => {
|
| | | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
|
| | | return ((bool)QtVsToolsPackage.Instance.Dte
|
| | | .Properties["Debugging", "General"]
|
| | | .Item("BreakAllProcesses")
|
| | | .Value);
|
| | | });
|
| | | }
|
| | | set
|
| | | {
|
| | | QtVsToolsPackage.Instance.Dte
|
| | | .Properties["Debugging", "General"]
|
| | | .Item("BreakAllProcesses")
|
| | | .let_Value(value ? "True" : "False");
|
| | | ThreadHelper.JoinableTaskFactory.Run(async () =>
|
| | | {
|
| | | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
|
| | | QtVsToolsPackage.Instance.Dte
|
| | | .Properties["Debugging", "General"]
|
| | | .Item("BreakAllProcesses")
|
| | | .let_Value(value ? "True" : "False");
|
| | | });
|
| | | }
|
| | | }
|
| | |
|