diff --git a/src/MIDebugEngine/Engine.Impl/DebuggedThread.cs b/src/MIDebugEngine/Engine.Impl/DebuggedThread.cs index ff739b61e..614ef61a9 100644 --- a/src/MIDebugEngine/Engine.Impl/DebuggedThread.cs +++ b/src/MIDebugEngine/Engine.Impl/DebuggedThread.cs @@ -150,6 +150,9 @@ internal async Task> StackFrames(DebuggedThread thread) internal async Task GetThreadContext(DebuggedThread thread) { + if (thread == null) + return null; + lock (_threadList) { if (_topContext.ContainsKey(thread.Id)) diff --git a/src/MIDebugEngine/MIDebugCommandDispatcher.cs b/src/MIDebugEngine/MIDebugCommandDispatcher.cs index 748d6904a..59219905e 100644 --- a/src/MIDebugEngine/MIDebugCommandDispatcher.cs +++ b/src/MIDebugEngine/MIDebugCommandDispatcher.cs @@ -15,7 +15,7 @@ public static class MIDebugCommandDispatcher { private readonly static List s_processes = new List(); - public static Task ExecuteCommand(string command) + private static DebuggedProcess GetLastProcess() { DebuggedProcess lastProcess; lock (s_processes) @@ -27,7 +27,40 @@ public static Task ExecuteCommand(string command) lastProcess = s_processes[s_processes.Count - 1]; } - return ExecuteCommand(command, lastProcess); + + if (lastProcess == null) + { + throw new InvalidOperationException(MICoreResources.Error_NoMIDebuggerProcess); + } + + return lastProcess; + } + + public static MICore.ProcessState GetProcessState() + { + return GetLastProcess().ProcessState; + } + + public static async Task ExecuteMICommandWithResultsObject(string command) + { + if (string.IsNullOrWhiteSpace(command)) + throw new ArgumentNullException(nameof(command)); + + command = command.Trim(); + + if (command[0] == '-') + { + return await GetLastProcess().CmdAsync(command, ResultClass.None); + } + else + { + throw new ArgumentOutOfRangeException(nameof(command)); + } + } + + public static Task ExecuteCommand(string command) + { + return ExecuteCommand(command, GetLastProcess()); } internal static Task ExecuteCommand(string command, DebuggedProcess process, bool ignoreFailures = false) diff --git a/src/MIDebugPackage/source.extension.vsixmanifest b/src/MIDebugPackage/source.extension.vsixmanifest index 3847c9975..b9a1df549 100644 --- a/src/MIDebugPackage/source.extension.vsixmanifest +++ b/src/MIDebugPackage/source.extension.vsixmanifest @@ -5,7 +5,7 @@ Microsoft MI-based Debugger Provides support for connecting Visual Studio to MI compatible debuggers - + diff --git a/src/WindowsDebugLauncher/WindowsDebugLauncher.csproj b/src/WindowsDebugLauncher/WindowsDebugLauncher.csproj index a260ee1fd..7e2e90306 100644 --- a/src/WindowsDebugLauncher/WindowsDebugLauncher.csproj +++ b/src/WindowsDebugLauncher/WindowsDebugLauncher.csproj @@ -13,7 +13,7 @@ Program $(MIDefaultOutputPath)\vscode vscode - net462 + net472 Exe true