From a9acf7d91819ced6a78706db2d7eab29a6a5166f Mon Sep 17 00:00:00 2001 From: Rakesh Ganesh Date: Thu, 13 Apr 2023 17:11:11 +0200 Subject: [PATCH 1/7] MIEngine: ExecuteMICommand without serialization MI Commands are executed in a way that it always appends some result-class alongside some other format in the ToString override method. There should be an option to execute MI Commands using CmdAsync alone. Signed-off-by: intel-rganesh rakesh.ganesh@intel.com --- src/MIDebugEngine/MIDebugCommandDispatcher.cs | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/MIDebugEngine/MIDebugCommandDispatcher.cs b/src/MIDebugEngine/MIDebugCommandDispatcher.cs index 748d6904a..2405e43ff 100644 --- a/src/MIDebugEngine/MIDebugCommandDispatcher.cs +++ b/src/MIDebugEngine/MIDebugCommandDispatcher.cs @@ -15,6 +15,39 @@ public static class MIDebugCommandDispatcher { private readonly static List s_processes = new List(); + public static async Task ExecuteMICommandWithResultsObject(string command) + { + DebuggedProcess lastProcess; + lock (s_processes) + { + if (s_processes.Count == 0) + { + throw new InvalidOperationException(MICoreResources.Error_NoMIDebuggerProcess); + } + + lastProcess = s_processes[s_processes.Count - 1]; + } + + if (string.IsNullOrWhiteSpace(command)) + throw new ArgumentNullException(nameof(command)); + + if (lastProcess == null) + { + throw new InvalidOperationException(MICoreResources.Error_NoMIDebuggerProcess); + } + + command = command.Trim(); + + if (command[0] == '-') + { + return await lastProcess.CmdAsync(command, ResultClass.None); + } + else + { + return null; + } + } + public static Task ExecuteCommand(string command) { DebuggedProcess lastProcess; From 7fd78167b21b72412640055490d23911658eeac8 Mon Sep 17 00:00:00 2001 From: Rakesh Ganesh Date: Thu, 13 Apr 2023 18:48:46 +0200 Subject: [PATCH 2/7] MIEngine: VSIX for all user integration Correct VSIX file so IDE plugin integration is performed for ALL users. Signed-off-by: intel-rganesh rakesh.ganesh@intel.com --- src/MIDebugPackage/source.extension.vsixmanifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 - + From 5c5f097578dc56880ec113dcdf5e8c2d7dbb9e71 Mon Sep 17 00:00:00 2001 From: Rakesh Ganesh Date: Thu, 13 Apr 2023 18:55:57 +0200 Subject: [PATCH 3/7] MIEngine: Update .net framework for WindowsDebugLauncher By default VS does not have .net framework 4.6.2 installed, minimum we support is 4.7.2. Signed-off-by: intel-rganesh rakesh.ganesh@intel.com --- src/WindowsDebugLauncher/WindowsDebugLauncher.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From b9059d085fa8d3d9a47d6c3d6dfc79f5bd7b4d5e Mon Sep 17 00:00:00 2001 From: Rakesh Ganesh Date: Fri, 14 Apr 2023 15:14:11 +0200 Subject: [PATCH 4/7] MIEngine: Add GetProcessState method Add GetProcessState for querying the status of the debugger. Signed-off-by: intel-rganesh rakesh.ganesh@intel.com --- src/MIDebugEngine/MIDebugCommandDispatcher.cs | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/MIDebugEngine/MIDebugCommandDispatcher.cs b/src/MIDebugEngine/MIDebugCommandDispatcher.cs index 2405e43ff..ba4bed6fd 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 async Task ExecuteMICommandWithResultsObject(string command) + private static DebuggedProcess GetLastProcess() { DebuggedProcess lastProcess; lock (s_processes) @@ -28,19 +28,35 @@ public static async Task ExecuteMICommandWithResultsObject(string comma lastProcess = s_processes[s_processes.Count - 1]; } - if (string.IsNullOrWhiteSpace(command)) - throw new ArgumentNullException(nameof(command)); - if (lastProcess == null) { throw new InvalidOperationException(MICoreResources.Error_NoMIDebuggerProcess); } + return lastProcess; + } + + public static MICore.ProcessState GetProcessState() + { + return GetLastProcess().ProcessState; + } + + public static async Task SetSelectedThread(int threadId) + { + GetLastProcess().MICommandFactory.DefineCurrentThread(threadId); + return await Task.FromResult(new Results(ResultClass.done)); + } + + public static async Task ExecuteMICommandWithResultsObject(string command) + { + if (string.IsNullOrWhiteSpace(command)) + throw new ArgumentNullException(nameof(command)); + command = command.Trim(); if (command[0] == '-') { - return await lastProcess.CmdAsync(command, ResultClass.None); + return await GetLastProcess().CmdAsync(command, ResultClass.None); } else { @@ -50,17 +66,7 @@ public static async Task ExecuteMICommandWithResultsObject(string comma public static Task ExecuteCommand(string command) { - DebuggedProcess lastProcess; - lock (s_processes) - { - if (s_processes.Count == 0) - { - throw new InvalidOperationException(MICoreResources.Error_NoMIDebuggerProcess); - } - - lastProcess = s_processes[s_processes.Count - 1]; - } - return ExecuteCommand(command, lastProcess); + return ExecuteCommand(command, GetLastProcess()); } internal static Task ExecuteCommand(string command, DebuggedProcess process, bool ignoreFailures = false) From 782c97ded5747639a947e094f8e9d7d06c153cf4 Mon Sep 17 00:00:00 2001 From: Rakesh Ganesh Date: Fri, 14 Apr 2023 15:32:44 +0200 Subject: [PATCH 5/7] MIEngine: Check for null pointer in DebuggedThread.GetThreadContext In GetThreadContext do not proceed if the thread is null. Signed-off-by: intel-rganesh rakesh.ganesh@intel.com --- src/MIDebugEngine/Engine.Impl/DebuggedThread.cs | 3 +++ 1 file changed, 3 insertions(+) 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)) From 03c40403b6bcc28bb83f5add93ee1d6dae266a54 Mon Sep 17 00:00:00 2001 From: Rakesh Ganesh Date: Fri, 2 Feb 2024 16:46:03 +0000 Subject: [PATCH 6/7] MIEngine: Fix code review comments Use ArgumentOutOfRangeException instead of returning null when the command does not begin with "-". Signed-off-by: intel-rganesh rakesh.ganesh@intel.com --- src/MIDebugEngine/MIDebugCommandDispatcher.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MIDebugEngine/MIDebugCommandDispatcher.cs b/src/MIDebugEngine/MIDebugCommandDispatcher.cs index ba4bed6fd..af61a7170 100644 --- a/src/MIDebugEngine/MIDebugCommandDispatcher.cs +++ b/src/MIDebugEngine/MIDebugCommandDispatcher.cs @@ -41,7 +41,7 @@ public static MICore.ProcessState GetProcessState() return GetLastProcess().ProcessState; } - public static async Task SetSelectedThread(int threadId) + public static async Task ViewSelectedThreadInfo(int threadId) { GetLastProcess().MICommandFactory.DefineCurrentThread(threadId); return await Task.FromResult(new Results(ResultClass.done)); @@ -60,7 +60,7 @@ public static async Task ExecuteMICommandWithResultsObject(string comma } else { - return null; + throw new ArgumentOutOfRangeException(nameof(command)); } } From 35aac7af0d0b3cc33e2ae2dc4889d32fbfced3b6 Mon Sep 17 00:00:00 2001 From: Rakesh Ganesh Date: Wed, 28 Feb 2024 16:55:50 +0000 Subject: [PATCH 7/7] MIEngine: Remove ViewSelectedThreadInfo Removing ViewSelectedThreadInfo as part of review comments. Signed-off-by: intel-rganesh rakesh.ganesh@intel.com --- src/MIDebugEngine/MIDebugCommandDispatcher.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/MIDebugEngine/MIDebugCommandDispatcher.cs b/src/MIDebugEngine/MIDebugCommandDispatcher.cs index af61a7170..59219905e 100644 --- a/src/MIDebugEngine/MIDebugCommandDispatcher.cs +++ b/src/MIDebugEngine/MIDebugCommandDispatcher.cs @@ -41,12 +41,6 @@ public static MICore.ProcessState GetProcessState() return GetLastProcess().ProcessState; } - public static async Task ViewSelectedThreadInfo(int threadId) - { - GetLastProcess().MICommandFactory.DefineCurrentThread(threadId); - return await Task.FromResult(new Results(ResultClass.done)); - } - public static async Task ExecuteMICommandWithResultsObject(string command) { if (string.IsNullOrWhiteSpace(command))