diff --git a/.github/workflows/Build-And-Test.yml b/.github/workflows/Build-And-Test.yml index 73cfff4f4..9fe5827ac 100644 --- a/.github/workflows/Build-And-Test.yml +++ b/.github/workflows/Build-And-Test.yml @@ -22,20 +22,20 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Install .NET Core - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: - dotnet-version: 6.0.x + dotnet-version: 8.0.x - name: Setup MSBuild.exe - uses: microsoft/setup-msbuild@v1.1 + uses: microsoft/setup-msbuild@v2 - name: Setup NuGet.exe for use with actions - uses: NuGet/setup-nuget@v1 + uses: NuGet/setup-nuget@v2 - name: Build MIDebugEngine run: | @@ -44,7 +44,7 @@ jobs: Configuration: ${{ matrix.configuration }} - name: Setup VSTest.console.exe - uses: darenm/Setup-VSTest@v1.2 + uses: darenm/Setup-VSTest@v1.3 - name: Run VS Extension tests run: vstest.console.exe ${{ github.workspace }}\bin\${{ matrix.configuration }}\MICoreUnitTests.dll ${{ github.workspace }}\bin\${{ matrix.configuration }}\JDbgUnitTests.dll ${{ github.workspace }}\bin\${{ matrix.configuration }}\SSHDebugTests.dll ${{ github.workspace }}\bin\${{ matrix.configuration }}\MIDebugEngineUnitTests.dll @@ -54,20 +54,20 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Install .NET Core - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: - dotnet-version: 6.0.x + dotnet-version: 8.0.x - name: Setup MSBuild.exe - uses: microsoft/setup-msbuild@v1.1 + uses: microsoft/setup-msbuild@v2 - name: Setup NuGet.exe for use with actions - uses: NuGet/setup-nuget@v1 + uses: NuGet/setup-nuget@v2 - name: Build MIDebugEngine run: | @@ -102,7 +102,7 @@ jobs: dotnet test $CppTestsPath --logger "trx;LogFileName=$ResultsPath" - name: 'Upload Test Results' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: ${{ always() }} with: name: win_msys2_x64_results @@ -112,14 +112,14 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Install .NET Core - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: - dotnet-version: 6.0.x + dotnet-version: 8.0.x - name: Build run: dotnet build ${{ github.workspace }}/src/MIDebugEngine-Unix.sln @@ -143,24 +143,24 @@ jobs: ${{ github.workspace }}/eng/Scripts/CI-Test.sh - name: 'Upload Test Results' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: ${{ always() }} with: name: linux_x64_results path: ${{ github.workspace }}/bin/DebugAdapterProtocolTests/Debug/CppTests/results.trx osx_build: - runs-on: macos-latest + runs-on: macos-12 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Install .NET Core - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: - dotnet-version: 6.0.x + dotnet-version: 8.0.x - name: Build run: dotnet build ${{ github.workspace }}/src/MIDebugEngine-Unix.sln @@ -172,8 +172,8 @@ jobs: ${{ github.workspace }}/eng/Scripts/CI-Test.sh - name: 'Upload Test Results' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: ${{ always() }} with: name: osx_x64_results - path: ${{ github.workspace }}/bin/DebugAdapterProtocolTests/Debug/CppTests/results.trx \ No newline at end of file + path: ${{ github.workspace }}/bin/DebugAdapterProtocolTests/Debug/CppTests/results.trx diff --git a/MIEngine.UnixPortSupplier.nuspec b/MIEngine.UnixPortSupplier.nuspec index fae9ff2d3..3610c6d97 100644 --- a/MIEngine.UnixPortSupplier.nuspec +++ b/MIEngine.UnixPortSupplier.nuspec @@ -12,7 +12,7 @@ - - + + diff --git a/MIEngine.mdd.nuspec b/MIEngine.mdd.nuspec index 883cab2ad..051d4a5bf 100644 --- a/MIEngine.mdd.nuspec +++ b/MIEngine.mdd.nuspec @@ -12,10 +12,10 @@ - - - - - + + + + + diff --git a/build/package_versions.settings.targets b/build/package_versions.settings.targets index 470194d01..248548b8e 100644 --- a/build/package_versions.settings.targets +++ b/build/package_versions.settings.targets @@ -1,7 +1,7 @@ 1.0.1 - 17.8.37221 + 17.11.40262 13.0.3 17.2.60629.1 @@ -25,15 +25,19 @@ 17.5.33428.366 17.5.33428.366 17.5.33428.366 - 17.8.37221 - 17.8.37221 - 17.8.14 - 17.8.37221 + 17.11.40262 + 17.11.40262 + 17.11.20 + 17.11.40262 15.0.26932 15.0.392 15.0.392 - 17.8.37221 + 17.11.40262 17.3.2093 4.3.0 + + + 6.0.1 + 8.0.4 \ No newline at end of file diff --git a/build/version.settings.targets b/build/version.settings.targets index f606a565b..b4b4aca63 100644 --- a/build/version.settings.targets +++ b/build/version.settings.targets @@ -3,7 +3,7 @@ 17 - 8 + 12 2022 diff --git a/eng/pipelines/MIDebugEngine-CI.yml b/eng/pipelines/MIDebugEngine-CI.yml index 3f3bc40f4..5aa99c585 100644 --- a/eng/pipelines/MIDebugEngine-CI.yml +++ b/eng/pipelines/MIDebugEngine-CI.yml @@ -39,8 +39,10 @@ stages: - stage: CodeAnalysis dependsOn: [CI] + variables: + - group: VSEng sponsored APIScan jobs: - - template: ./jobs/MSHosted-Windows.job.yml + - template: ./jobs/VSEngSS-MicroBuild2022-1ES.job.yml parameters: DisplayName: 'CodeAnalysis' JobTemplate: diff --git a/eng/pipelines/VS-release.yml b/eng/pipelines/VS-release.yml index 6cf29c9fc..d86512dc1 100644 --- a/eng/pipelines/VS-release.yml +++ b/eng/pipelines/VS-release.yml @@ -1,7 +1,9 @@ --- name: $(Date:yyyMMdd).$(Rev:r) + variables: - - group: TSDTUSR +- name: TeamName + value: MDDDebugger resources: repositories: @@ -21,7 +23,7 @@ extends: name: VSEngSS-MicroBuild2022-1ES os: windows stages: - - stage: stage + - stage: BuildVSReleasePackage displayName: VS_Release jobs: - job: Phase_1 @@ -38,4 +40,34 @@ extends: enabled: true steps: - template: /eng/pipelines/templates/VS-release.template.yml@self + + - stage: VS_Insertion + dependsOn: [BuildVSReleasePackage] + jobs: + - job: + displayName: Insert package into VS + templateContext: + inputs: + - input: pipelineArtifact + artifactName: PackageVersion + targetPath: $(Build.ArtifactStagingDirectory)\PackageVersion + steps: + - checkout: none + + - powershell: | + $version= [IO.File]::ReadAllText("$(Build.ArtifactStagingDirectory)\PackageVersion\NugetPackageVersion.txt") + Write-Host "##vso[task.setvariable variable=MDDPackageVersion;]$version" + displayName: 'Set MDDPackage Version' + + - task: ms-vseng.MicroBuildShipTasks.55100717-a81d-45ea-a363-b8fe3ec375ad.MicroBuildInsertVsPayload@4 + displayName: 'Insert VS Payload' + inputs: + TargetBranch: $(TargetBranch) + TeamName: 'VS Debugger Platform' + TeamEmail: $(TEAMEMAIL) + DefaultConfigValues: 'VS.Redist.Debugger.MDD.MIEngine=$(MDDPackageVersion)' + RevisionTextFiles: 'src/SetupPackages/VC/IDE/MDD/core/revision.txt,src/SetupPackages/VC/IDE/MDD/res/revision.txt' + InsertionPayloadName: 'MIEngine $(MDDPackageVersion)' + InsertionDescription: 'Updating MIEngine to $(MDDPackageVersion). See $(Release.Artifacts.MIEngine_MDD.BuildURI)' + InsertionReviewers: $(InsertionReviewers) ... \ No newline at end of file diff --git a/eng/pipelines/VSCode-release.yml b/eng/pipelines/VSCode-release.yml index 0ba0e6711..65912d99a 100644 --- a/eng/pipelines/VSCode-release.yml +++ b/eng/pipelines/VSCode-release.yml @@ -1,7 +1,9 @@ --- name: $(Date:yyyMMdd).$(Rev:r) + variables: - - group: TSDTUSR +- name: TeamName + value: MDDDebugger resources: repositories: diff --git a/eng/pipelines/steps/APIScan.yml b/eng/pipelines/steps/APIScan.yml index 4aa947f75..5ae4b69ff 100644 --- a/eng/pipelines/steps/APIScan.yml +++ b/eng/pipelines/steps/APIScan.yml @@ -38,4 +38,4 @@ steps: isLargeApp: false continueOnError: true env: - AzureServicesAuthConnectionString: runAs=App;AppId=$(ApiScanClientId);TenantId=$(ApiScanTenant);AppKey=$(MIEngineApiScan) \ No newline at end of file + AzureServicesAuthConnectionString: runAs=App;AppId=$(ApiScanClientId) \ No newline at end of file diff --git a/eng/pipelines/steps/CopyAndPublishSymbols.yml b/eng/pipelines/steps/CopyAndPublishSymbols.yml index b61728414..1788f9695 100644 --- a/eng/pipelines/steps/CopyAndPublishSymbols.yml +++ b/eng/pipelines/steps/CopyAndPublishSymbols.yml @@ -7,33 +7,21 @@ steps: - template: ../tasks/CopyFiles.yml parameters: displayName: 'Collect build symbols' - SourceFolder: '$(Build.SourcesDirectory)' - Contents: '$(Build.SourcesDirectory)\bin\**\*.+(pdb|exe|dll)' + SourceFolder: '$(Build.StagingDirectory)\drop' + Contents: '$(Build.StagingDirectory)\drop\**\*.+(pdb|exe|dll)' TargetFolder: '$(Build.ArtifactStagingDirectory)/symbols' CleanTargetFolder: true -- task: PowerShell@2 - displayName: 'Set Variables for PublishSymbols' + +- task: ms-vseng.MicroBuildShipTasks.0ffdda1d-8c7b-40da-b8b1-061660eaeea3.MicroBuildArchiveSymbols@5 + displayName: 'Archive MIEngine_MDD on Symweb' inputs: - targetType: 'inline' - script: | - Write-Host "##vso[task.setvariable variable=ArtifactServices.Symbol.AccountName]microsoft" - Write-Host "##vso[task.setvariable variable=ArtifactServices.Symbol.PAT;issecret=true;]${env:ARTIFACTSERVICES_SYMBOL_PAT}" - Write-Host "##vso[task.setvariable variable=ArtifactServices.Symbol.UseAAD]false" - env: - ARTIFACTSERVICES_SYMBOL_PAT: $(all-org-SymbolsReadWrite) - -- template: ../tasks/PublishSymbols.yml - parameters: - IndexSources: false - SymbolsFolder: '$(Build.ArtifactStagingDirectory)/symbols' - SearchPattern: '**\*.pdb' - SymbolServerType: TeamServices - -- template: ../tasks/1ES/PublishPipelineArtifact.yml - parameters: - displayName: 'Publish Symbols' - targetPath: '$(Build.ArtifactStagingDirectory)/symbols' - artifactName: 'Symbols' - OneESPT: ${{ parameters.OneESPT }} + SymbolsFeatureName: MIEngine + SymbolsProject: VS + SymbolsAgentPath: '$(Build.ArtifactStagingDirectory)\Symbols\' + ExcludeAgentFolders: '$(Build.ArtifactStagingDirectory)\Symbols\Debug;$(Build.ArtifactStagingDirectory)\Symbols\Lab.Debug' + ${{ if parameters.OneESPT }}: + ExpirationInDays: 3650 # Expire in 10 years for release builds + ${{ else }}: + ExpirationInDays: 1 # Expire in 1 day if used for testing ... \ No newline at end of file diff --git a/eng/pipelines/steps/PackAndPublishVSPackages.yml b/eng/pipelines/steps/PublishVSPackages.yml similarity index 62% rename from eng/pipelines/steps/PackAndPublishVSPackages.yml rename to eng/pipelines/steps/PublishVSPackages.yml index fd95d189e..2308737b5 100644 --- a/eng/pipelines/steps/PackAndPublishVSPackages.yml +++ b/eng/pipelines/steps/PublishVSPackages.yml @@ -19,21 +19,20 @@ steps: artifactName: 'PackageVersion' OneESPT: true -- template: ../tasks/NuGetCommand.yml - parameters: - displayName: 'NuGet pack' - command: pack - searchPatternPack: '$(Build.SourcesDirectory)\MIEngine.mdd.nuspec;$(Build.SourcesDirectory)\MIEngine.UnixPortSupplier.nuspec' - configurationToPack: Release - buildProperties: 'version=$(NugetPackageVersion)' - basePath: ${{ parameters.BasePath }} +- task: CopyFiles@2 + inputs: + SourceFolder: $(Build.BinariesDirectory) + Contents: '**/*.nupkg' + TargetFolder: $(Build.SourcesDirectory)/NugetPackages + flattenFolders: true + OverWrite: true - task: 1ES.PublishNuget@1 displayName: Publish Nuget package condition: and(succeeded(), eq(variables['SignType'], 'real')) inputs: - packagesToPush: '$(Build.SourcesDirectory)\VS.Redist.Debugger.MDD.MIEngine.*.nupkg;$(Build.SourcesDirectory)\VS.Redist.Debugger.MDD.UnixPortSupplier.*.nupkg' - packageParentPath: '$(Build.SourcesDirectory)' + packagesToPush: '$(Build.SourcesDirectory)/NugetPackages/*.nupkg' + packageParentPath: '$(Build.SourcesDirectory)/NugetPackages' publishVstsFeed: '97a41293-2972-4f48-8c0e-05493ae82010' # VS nuGetFeedType: internal ... \ No newline at end of file diff --git a/eng/pipelines/tasks/UseDotNet.yml b/eng/pipelines/tasks/UseDotNet.yml index 7c13aa7a3..eb4589924 100644 --- a/eng/pipelines/tasks/UseDotNet.yml +++ b/eng/pipelines/tasks/UseDotNet.yml @@ -3,4 +3,4 @@ steps: displayName: 'Use .NET Core sdk' inputs: packageType: sdk - version: 6.x \ No newline at end of file + version: 8.x \ No newline at end of file diff --git a/eng/pipelines/templates/CodeAnalysis.template.yml b/eng/pipelines/templates/CodeAnalysis.template.yml index 84adf530a..7f2e0cee0 100644 --- a/eng/pipelines/templates/CodeAnalysis.template.yml +++ b/eng/pipelines/templates/CodeAnalysis.template.yml @@ -4,6 +4,12 @@ steps: - template: ../tasks/CredScan.yml +- template: ../steps/BuildSolution.yml + parameters: + Solution: '$(Build.SourcesDirectory)\test\CppTests\debuggees\sln\debuggees.sln' + Configuration: 'Debug' + OneESPT: false + - task: DownloadPipelineArtifact@2 displayName: Download Pipeline Artifact inputs: diff --git a/eng/pipelines/templates/VS-release.template.yml b/eng/pipelines/templates/VS-release.template.yml index 352fa49ae..9a5b1b972 100644 --- a/eng/pipelines/templates/VS-release.template.yml +++ b/eng/pipelines/templates/VS-release.template.yml @@ -6,9 +6,12 @@ steps: - template: ../tasks/NuGetToolInstaller.yml +- template: ../tasks/MicroBuildSigningPlugin.yml + - template: ../steps/BuildSolution.yml parameters: Configuration: 'Lab.Release' + BuildArguments: /p:NuGetPath=$(NuGetExeToolPath) /p:NuGetPrerelease=false OneESPT: true - template: ../steps/CollectAndPublishBinaries.yml @@ -25,7 +28,7 @@ steps: parameters: OneESPT: true -- template: ../steps/PackAndPublishVSPackages.yml +- template: ../steps/PublishVSPackages.yml parameters: BasePath: $(Build.StagingDirectory) diff --git a/src/DebugEngineHost/DebugEngineHost.csproj b/src/DebugEngineHost/DebugEngineHost.csproj index 03bd58c69..bed223019 100755 --- a/src/DebugEngineHost/DebugEngineHost.csproj +++ b/src/DebugEngineHost/DebugEngineHost.csproj @@ -88,6 +88,13 @@ compile all + + + all + + + all + diff --git a/src/DebugEngineHost/HostOutputWindow.cs b/src/DebugEngineHost/HostOutputWindow.cs index 1d2b63632..9dec6445a 100644 --- a/src/DebugEngineHost/HostOutputWindow.cs +++ b/src/DebugEngineHost/HostOutputWindow.cs @@ -117,7 +117,7 @@ public static void Write(string message, string pane = DefaultOutputPane) } // Output the text - outputPane.OutputString(message); + outputPane.OutputStringThreadSafe(message); } catch (Exception) { diff --git a/src/MICore/Debugger.cs b/src/MICore/Debugger.cs index c3367de6b..710d6d70c 100755 --- a/src/MICore/Debugger.cs +++ b/src/MICore/Debugger.cs @@ -161,6 +161,8 @@ internal bool IsRequestingInternalAsyncBreak // The key is the thread group, the value is the pid private Dictionary _debuggeePids; + private string _gdbVersion = string.Empty; + public Debugger(LaunchOptions launchOptions, Logger logger) { _launchOptions = launchOptions; @@ -938,6 +940,10 @@ void ITransportCallback.OnStdOutLine(string line) if (_initializationLog != null) { _initializationLog.AddLast(line); + if (string.IsNullOrEmpty(_gdbVersion)) + { + TryInitializeGdbVersion(line); + } } } } @@ -978,24 +984,16 @@ public void OnDebuggerProcessExit(/*OPTIONAL*/ string exitCode) if (_consoleDebuggerInitializeCompletionSource != null) { MIDebuggerInitializeFailedException exception; - string version = GdbVersionFromLog(); - - int majorVersion = -1; - if (!string.IsNullOrWhiteSpace(version)) - { - int.TryParse(version.Split('.').FirstOrDefault(), out majorVersion); - } - MICommandFactory.MajorVersion = majorVersion; - + // We can't use IsMinGW or IsCygwin because we never connected to the debugger bool isMinGWOrCygwin = _launchOptions is LocalLaunchOptions && PlatformUtilities.IsWindows() && this.MICommandFactory.Mode == MIMode.Gdb; - if (isMinGWOrCygwin && version != null && IsUnsupportedWindowsGdbVersion(version)) + if (isMinGWOrCygwin && IsUnsupportedWindowsGdbVersion(_gdbVersion)) { exception = new MIDebuggerInitializeFailedUnsupportedGdbException( - this.MICommandFactory.Name, _initialErrors.ToList().AsReadOnly(), _initializationLog.ToList().AsReadOnly(), version); - SendUnsupportedWindowsGdbEvent(version); + this.MICommandFactory.Name, _initialErrors.ToList().AsReadOnly(), _initializationLog.ToList().AsReadOnly(), _gdbVersion); + SendUnsupportedWindowsGdbEvent(_gdbVersion); } else { @@ -1037,21 +1035,25 @@ public void OnDebuggerProcessExit(/*OPTIONAL*/ string exitCode) } } - string GdbVersionFromLog() - { - foreach (string line in _initializationLog) + void TryInitializeGdbVersion(string line) + { + // Second set of parenthesis looks for a Cygwin-specific version number + // Cygwin example: GNU gdb (GDB) (Cygwin 7.11.1-2) 7.11.1 + // MinGW example: GNU gdb (GDB) 8.0.1 + // Intel GNU gdb example: GNU gdb (Intel(R) Distribution for GDB* 2024.1.0) 14.1 + Match match = Regex.Match(line, + @"GNU gdb(?: \(GDB\))?(?: \(Cygwin (\d+[\.\d-]*)\)| \(Intel\(R\) Distribution for GDB\* [\d.]+\))? ([\d.]+)"); + if (match.Success) { - // Second set of parenthesis looks for a Cygwin-specific version number - // Cygwin example: GNU gdb (GDB) (Cygwin 7.11.1-2) 7.11.1 - // MinGW example: GNU gdb (GDB) 8.0.1 - Match match = Regex.Match(line, "GNU gdb \\(GDB\\) (?:\\(Cygwin (\\d+[\\d\\.-]*)\\) )?(\\d+[\\d\\.-]*)"); - if (match.Success) - { - return match.Groups[1].Success ? match.Groups[1].Value : match.Groups[2].Value; - } + _gdbVersion = match.Groups[1].Success ? match.Groups[1].Value : match.Groups[2].Value; } - return null; + int majorVersion = 0; + if (!string.IsNullOrWhiteSpace(_gdbVersion)) + { + int.TryParse(_gdbVersion.Split('.').FirstOrDefault(), out majorVersion); + } + MICommandFactory.MajorVersion = majorVersion; } bool IsUnsupportedWindowsGdbVersion(string version) diff --git a/src/MIDebugEngine/Engine.Impl/BreakpointManager.cs b/src/MIDebugEngine/Engine.Impl/BreakpointManager.cs index c576c35fd..39090e1f0 100644 --- a/src/MIDebugEngine/Engine.Impl/BreakpointManager.cs +++ b/src/MIDebugEngine/Engine.Impl/BreakpointManager.cs @@ -58,20 +58,13 @@ public async Task BreakpointModified(object sender, EventArgs args) string bkptId = null; // // =breakpoint-modified, - // bkpt ={number="2",type="breakpoint",disp="keep",enabled="y",addr="",times="0",original-location="main.cpp:220"}, + // bkpt ={number="2",type="breakpoint",disp="keep",enabled="y",addr="",times="0",original-location="main.cpp:220"},locations=[ // { number="2.1",enabled="y",addr="0x9c2149a9",func="Foo::bar(int)",file="main.cpp",fullname="C:\\\\...\\\\main.cpp",line="220",thread-groups=["i1"]}, - // { number="2.2",enabled="y",addr="0x9c2149f2",func="Foo::bar(float)",file="main.cpp",fullname="C:\\\\...\\\\main.cpp",line="220",thread-groups=["i1"]} + // { number="2.2",enabled="y",addr="0x9c2149f2",func="Foo::bar(float)",file="main.cpp",fullname="C:\\\\...\\\\main.cpp",line="220",thread-groups=["i1"]}]} // note: the ".x" part of the breakpoint number never appears in stopping events, that is, when executing at one of these addresses // the stopping event delivered contains bkptno="2" - if (bkpt is MICore.ValueListValue) - { - MICore.ValueListValue list = bkpt as MICore.ValueListValue; - bkptId = list.Content[0].FindString("number"); // 0 is the "" entry - } - else - { - bkptId = bkpt.FindString("number"); - } + bkptId = bkpt.FindString("number"); + AD7PendingBreakpoint pending = CodeBreakpoints.FirstOrDefault((p) => { return p.BreakpointId == bkptId; }); if (pending == null) { diff --git a/src/MIDebugEngine/Engine.Impl/Breakpoints.cs b/src/MIDebugEngine/Engine.Impl/Breakpoints.cs index 356eb8efb..1f22ae702 100644 --- a/src/MIDebugEngine/Engine.Impl/Breakpoints.cs +++ b/src/MIDebugEngine/Engine.Impl/Breakpoints.cs @@ -146,12 +146,11 @@ private static async Task EvalBindResult(Results bindResult, AD7Pend if (b is TupleValue) { bkpt = b as TupleValue; - } - else if (b is ValueListValue) - { - // "" sometimes includes a list of bound breakpoints - list = b as ValueListValue; - bkpt = list.Content[0] as TupleValue; + // The locations field is present if the breakpoint has multiple locations. + if (b.TryFind("locations", out var locations) && locations is ValueListValue) + { + list = (ValueListValue) locations; + } } } else @@ -189,9 +188,9 @@ private static async Task EvalBindResult(Results bindResult, AD7Pend else // with list of addresses { BindResult res = new BindResult(bp); - for (int i = 1; i < list.Content.Length; ++i) + foreach (var t in list.Content) { - BoundBreakpoint bbp = await bp.GetBoundBreakpoint(list.Content[i] as TupleValue); + BoundBreakpoint bbp = await bp.GetBoundBreakpoint(t as TupleValue); res.BoundBreakpoints.Add(bbp); } return res; @@ -290,12 +289,13 @@ internal async Task> BindAddresses(ResultValue bkpt) return resultList; } BoundBreakpoint bbp = null; - if (bkpt is ValueListValue) + + // The locations field is present if the breakpoint has multiple locations. + if (bkpt.TryFind("locations", out var locations) && locations is ValueListValue list) { - var list = (ValueListValue)bkpt; - for (int i = 1; i < list.Content.Length; ++i) + foreach (var t in list.Content) { - bbp = await GetBoundBreakpoint(list.Content[i] as TupleValue); + bbp = await GetBoundBreakpoint(t as TupleValue); if (bbp != null) resultList.Add(bbp); } 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/MIDebugPackage.csproj b/src/MIDebugPackage/MIDebugPackage.csproj index fe7a3a4ad..8e136cb13 100755 --- a/src/MIDebugPackage/MIDebugPackage.csproj +++ b/src/MIDebugPackage/MIDebugPackage.csproj @@ -53,6 +53,13 @@ + + + all + + + all + @@ -214,6 +221,11 @@ + + + + + diff --git a/src/MIDebugPackage/MIDebugPackagePackage.cs b/src/MIDebugPackage/MIDebugPackagePackage.cs index be94cc4cd..1820a382a 100644 --- a/src/MIDebugPackage/MIDebugPackagePackage.cs +++ b/src/MIDebugPackage/MIDebugPackagePackage.cs @@ -405,29 +405,36 @@ private void EnableLogging(bool sendToOutputWindow, string logFile) ThreadHelper.ThrowIfNotOnUIThread(); IVsDebugger debugger = (IVsDebugger)GetService(typeof(IVsDebugger)); - DBGMODE[] mode = new DBGMODE[] { DBGMODE.DBGMODE_Design }; - int hr = debugger.GetMode(mode); - - if (hr == VSConstants.S_OK && mode[0] != DBGMODE.DBGMODE_Design) + if (debugger != null) { - throw new ArgumentException("Unable to update MIDebugLog while debugging."); - } + DBGMODE[] mode = new DBGMODE[] { DBGMODE.DBGMODE_Design }; + int hr = debugger.GetMode(mode); - try - { - MIDebugCommandDispatcher.EnableLogging(sendToOutputWindow, logFile); - } - catch (Exception e) - { - var commandWindow = (IVsCommandWindow)GetService(typeof(SVsCommandWindow)); - if (commandWindow != null) + if (hr == VSConstants.S_OK && mode[0] != DBGMODE.DBGMODE_Design) { - commandWindow.Print(string.Format(CultureInfo.CurrentCulture, "Error: {0}\r\n", e.Message)); + throw new ArgumentException("Unable to update MIDebugLog while debugging."); } - else + + try { - throw new InvalidOperationException("Why is IVsCommandWindow null?"); + MIDebugCommandDispatcher.EnableLogging(sendToOutputWindow, logFile); } + catch (Exception e) + { + var commandWindow = (IVsCommandWindow)GetService(typeof(SVsCommandWindow)); + if (commandWindow != null) + { + commandWindow.Print(string.Format(CultureInfo.CurrentCulture, "Error: {0}\r\n", e.Message)); + } + else + { + throw new InvalidOperationException("Why is IVsCommandWindow null?"); + } + } + } + else + { + throw new InvalidOperationException("Why is IVsDebugger null?"); } } 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/Microsoft.VisualStudio.Debugger.Interop.UnixPortSupplier/Microsoft.VisualStudio.Debugger.Interop.UnixPortSupplier.DesignTime.csproj b/src/Microsoft.VisualStudio.Debugger.Interop.UnixPortSupplier/Microsoft.VisualStudio.Debugger.Interop.UnixPortSupplier.DesignTime.csproj index 120f75c33..c781de505 100644 --- a/src/Microsoft.VisualStudio.Debugger.Interop.UnixPortSupplier/Microsoft.VisualStudio.Debugger.Interop.UnixPortSupplier.DesignTime.csproj +++ b/src/Microsoft.VisualStudio.Debugger.Interop.UnixPortSupplier/Microsoft.VisualStudio.Debugger.Interop.UnixPortSupplier.DesignTime.csproj @@ -35,6 +35,11 @@ + + + + + diff --git a/src/OpenDebugAD7/OpenDebugAD7.csproj b/src/OpenDebugAD7/OpenDebugAD7.csproj index 7f69b31be..2529b0c82 100644 --- a/src/OpenDebugAD7/OpenDebugAD7.csproj +++ b/src/OpenDebugAD7/OpenDebugAD7.csproj @@ -14,7 +14,7 @@ $(MIDefaultOutputPath)\vscode Exe vscode - net6.0 + net8.0