Skip to content

Commit

Permalink
Merge pull request #1256 from microsoft/main
Browse files Browse the repository at this point in the history
Merge 'main' into 'release-cpptools'
  • Loading branch information
WardenGnaw authored Jan 7, 2022
2 parents ef5597b + 00a3aee commit 4325db0
Show file tree
Hide file tree
Showing 52 changed files with 1,849 additions and 402 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
name: Pull Request
name: Build and Test

on:
# Run a build on Pull Requests
pull_request:
branches: [ main ]

# Run this build every night
schedule:
- cron: "0 0 * * *"

# Run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
windows_vs_build:
strategy:
Expand Down Expand Up @@ -76,7 +84,67 @@ jobs:
update: true
install: >-
mingw-w64-x86_64-toolchain
# As of Nov 8, 2021, mingw-w64-x86_64-toolchain-11.1.x
# causes GDB to return "During startup program exited with code 0xc0000139"
# Downgrade to working toolchain (04-May-2021)
# TODO: Remove this task when there is a newer version of toolchain than 11.1.x
- shell: msys2 {0}
name: Downgrade toolchain to 10.x
run: |
# Download GDB
DOWNLOAD_DOWNGRADED_GDB_PATH='${{ github.workspace }}/mingw-w64-x86_64-gdb-10.2-2-any.pkg.tar.zst'
DOWNLOAD_DOWNGRADED_GDB_PATH=${DOWNLOAD_DOWNGRADED_GDB_PATH//\\//}
wget -O ${DOWNLOAD_DOWNGRADED_GDB_PATH} http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-gdb-10.2-2-any.pkg.tar.zst
# Download GCC
DOWNLOAD_DOWNGRADED_GCC_PATH='${{ github.workspace }}/mingw-w64-x86_64-gcc-10.3.0-8-any.pkg.tar.zst'
DOWNLOAD_DOWNGRADED_GCC_PATH=${DOWNLOAD_DOWNGRADED_GCC_PATH//\\//}
wget -O ${DOWNLOAD_DOWNGRADED_GCC_PATH} http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-gcc-10.3.0-8-any.pkg.tar.zst
# Download GCC Lib
DOWNLOAD_DOWNGRADED_GCCLIB_PATH='${{ github.workspace }}/mingw-w64-x86_64-gcc-libs-10.3.0-8-any.pkg.tar.zst'
DOWNLOAD_DOWNGRADED_GCCLIB_PATH=${DOWNLOAD_DOWNGRADED_GCCLIB_PATH//\\//}
wget -O ${DOWNLOAD_DOWNGRADED_GCCLIB_PATH} http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-gcc-libs-10.3.0-8-any.pkg.tar.zst
# Download GCC Ada
DOWNLOAD_DOWNGRADED_ADA_PATH='${{ github.workspace }}/mingw-w64-x86_64-gcc-ada-10.3.0-8-any.pkg.tar.zst'
DOWNLOAD_DOWNGRADED_ADA_PATH=${DOWNLOAD_DOWNGRADED_ADA_PATH//\\//}
wget -O ${DOWNLOAD_DOWNGRADED_ADA_PATH} http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-gcc-ada-10.3.0-8-any.pkg.tar.zst
# Download GCC Fortran
DOWNLOAD_DOWNGRADED_FORTRAN_PATH='${{ github.workspace }}/mingw-w64-x86_64-gcc-fortran-10.3.0-8-any.pkg.tar.zst'
DOWNLOAD_DOWNGRADED_FORTRAN_PATH=${DOWNLOAD_DOWNGRADED_FORTRAN_PATH//\\//}
wget -O ${DOWNLOAD_DOWNGRADED_FORTRAN_PATH} http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-gcc-fortran-10.3.0-8-any.pkg.tar.zst
# Download GCC Libfortran
DOWNLOAD_DOWNGRADED_LIBFORTRAN_PATH='${{ github.workspace }}/mingw-w64-x86_64-gcc-libgfortran-10.3.0-8-any.pkg.tar.zst'
DOWNLOAD_DOWNGRADED_LIBFORTRAN_PATH=${DOWNLOAD_DOWNGRADED_LIBFORTRAN_PATH//\\//}
wget -O ${DOWNLOAD_DOWNGRADED_LIBFORTRAN_PATH} http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-gcc-libgfortran-10.3.0-8-any.pkg.tar.zst
# Download GCC Obj-C
DOWNLOAD_DOWNGRADED_OBJC_PATH='${{ github.workspace }}/mingw-w64-x86_64-gcc-objc-10.3.0-8-any.pkg.tar.zst'
DOWNLOAD_DOWNGRADED_OBJC_PATH=${DOWNLOAD_DOWNGRADED_OBJC_PATH//\\//}
wget -O ${DOWNLOAD_DOWNGRADED_OBJC_PATH} http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-gcc-objc-10.3.0-8-any.pkg.tar.zst
# Download GCC libgccjit
DOWNLOAD_DOWNGRADED_LIBGCCJIT_PATH='${{ github.workspace }}/mingw-w64-x86_64-libgccjit-10.3.0-8-any.pkg.tar.zst'
DOWNLOAD_DOWNGRADED_LIBGCCJIT_PATH=${DOWNLOAD_DOWNGRADED_LIBGCCJIT_PATH//\\//}
wget -O ${DOWNLOAD_DOWNGRADED_LIBGCCJIT_PATH} http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-libgccjit-10.3.0-8-any.pkg.tar.zst
# Install
pacman -U --noconfirm $DOWNLOAD_DOWNGRADED_GDB_PATH $DOWNLOAD_DOWNGRADED_GCC_PATH $DOWNLOAD_DOWNGRADED_GCCLIB_PATH $DOWNLOAD_DOWNGRADED_ADA_PATH $DOWNLOAD_DOWNGRADED_FORTRAN_PATH $DOWNLOAD_DOWNGRADED_LIBFORTRAN_PATH $DOWNLOAD_DOWNGRADED_OBJC_PATH $DOWNLOAD_DOWNGRADED_LIBGCCJIT_PATH
- shell: msys2 {0}
name: Gather c++ toolchain paths
run: |
cygpath -w $(which g++)
g++ --version
cygpath -w $(which gdb)
gdb --version
- run: >
dotnet test ${{ github.workspace }}\bin\DebugAdapterProtocolTests\Debug\CppTests\CppTests.dll --logger "trx;LogFileName=${{ github.workspace }}\bin\DebugAdapterProtocolTests\Debug\CppTests\results.trx"
Expand Down
2 changes: 1 addition & 1 deletion build/package_versions.settings.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Microsoft_VisualStudio_Debugger_Interop_Portable_Version>1.0.1</Microsoft_VisualStudio_Debugger_Interop_Portable_Version>
<Microsoft_VisualStudio_Interop_Version>17.0.0-previews-1-31410-258</Microsoft_VisualStudio_Interop_Version>
<Newtonsoft_Json_Version>12.0.2</Newtonsoft_Json_Version>
<Microsoft_VisualStudio_Shared_VSCodeDebugProtocol_Version>16.9.50204.1</Microsoft_VisualStudio_Shared_VSCodeDebugProtocol_Version>
<Microsoft_VisualStudio_Shared_VSCodeDebugProtocol_Version>17.0.50801.1</Microsoft_VisualStudio_Shared_VSCodeDebugProtocol_Version>

<!-- Test Packages -->
<Microsoft_NET_Test_Sdk_Version>16.7.1</Microsoft_NET_Test_Sdk_Version>
Expand Down
4 changes: 2 additions & 2 deletions build/version.settings.targets
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!--SxS: These three properties should be changed at the start of a new version, VersionZeroYear should be the year
before the start of the project. When updating the version, also update MIEngine\metadata.json.-->
before the start of the project.-->
<MajorVersion>17</MajorVersion>
<MinorVersion>0</MinorVersion>
<MinorVersion>1</MinorVersion>
<VersionZeroYear>2020</VersionZeroYear>
<!-- Note: for compatibility, we leave the default assembly version of the repo at 14.0.
If we ever decide to change this, make sure that you notify partner teams such as C++ IOT -->
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/templates/VSCode-release.template.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
parameters:
rids: ["win-x86", "win10-arm64", "osx-x64", "linux-x64", "linux-arm", "linux-arm64", "linux-musl-x64" ]
rids: ["win-x86", "win10-arm64", "osx-x64", "linux-x64", "linux-arm", "linux-arm64", "linux-musl-x64", "linux-musl-arm64" ]

steps:
- checkout: self
Expand Down
20 changes: 19 additions & 1 deletion loc/lcl/CHS/Microsoft.SSHDebugPS.dll.lcl

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion loc/lcl/CHT/Microsoft.SSHDebugPS.dll.lcl

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion loc/lcl/CSY/Microsoft.SSHDebugPS.dll.lcl

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion loc/lcl/DEU/Microsoft.SSHDebugPS.dll.lcl

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion loc/lcl/ESN/Microsoft.SSHDebugPS.dll.lcl

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion loc/lcl/FRA/Microsoft.SSHDebugPS.dll.lcl

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion loc/lcl/ITA/Microsoft.SSHDebugPS.dll.lcl

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion loc/lcl/JPN/Microsoft.SSHDebugPS.dll.lcl

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion loc/lcl/KOR/Microsoft.SSHDebugPS.dll.lcl

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion loc/lcl/PLK/Microsoft.SSHDebugPS.dll.lcl

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion loc/lcl/PTB/Microsoft.SSHDebugPS.dll.lcl

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion loc/lcl/RUS/Microsoft.SSHDebugPS.dll.lcl

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion loc/lcl/TRK/Microsoft.SSHDebugPS.dll.lcl

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ public interface IDebugProgramDAP
/// <param name="pResult">Number of bits in a pointer.</param>
/// [PreserveSig]
int GetPointerSize([Out] out int pResult);

/// <summary>
/// Tries to complete a given command string.
/// </summary>
/// <param name="command">Partial command to complete</param>
/// <param name="stackFrame">Optional stack frame as context</param>
/// <param name="result">Completion List or null</param>
/// <returns></returns>
int AutoComplete([In] string command, [In] IDebugStackFrame2 stackFrame, [Out] out string[] result);
}

/// <summary>
Expand Down
24 changes: 15 additions & 9 deletions src/DebugEngineHost.VSCode/VSCode/ExceptionBreakpointFilter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.VisualStudio.Debugger.Interop;
using Newtonsoft.Json;
using System;
using System.Diagnostics;
Expand All @@ -13,9 +14,6 @@ namespace Microsoft.DebugEngineHost.VSCode
/// </summary>
sealed public class ExceptionBreakpointFilter
{
public const string Filter_All = "all";
public const string Filter_UserUnhandled = "user-unhandled";

private string _filter;

/// <summary>
Expand All @@ -25,7 +23,7 @@ sealed public class ExceptionBreakpointFilter
public string label { get; set; }

/// <summary>
/// The identifier for this filter. Currently this should be 'all' or 'user-unhandled'
/// The identifier for this filter.
/// </summary>
[JsonRequired]
public string filter
Expand All @@ -37,18 +35,26 @@ public string filter

set
{
if (value != Filter_All && value != Filter_UserUnhandled)
{
Debug.Fail("Invalid ExceptionBreakpointFilter");
throw new ArgumentOutOfRangeException("filter");
}
_filter = value;
}
}

[JsonRequired]
public bool supportsCondition { get; set; }

[JsonRequired]
public string conditionDescription { get; set; }

[JsonRequired]
public Guid categoryId { get; set; }

/// <summary>
/// The default state for the button
/// </summary>
public bool @default { get; set; }

[JsonIgnore]
public enum_EXCEPTION_STATE State { get; set; } = enum_EXCEPTION_STATE.EXCEPTION_STOP_SECOND_CHANCE | enum_EXCEPTION_STATE.EXCEPTION_STOP_FIRST_CHANCE | enum_EXCEPTION_STATE.EXCEPTION_STOP_USER_FIRST_CHANCE;

}
}
20 changes: 20 additions & 0 deletions src/DebugEngineHost.VSCode/VSCode/ExceptionSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.Linq;

namespace Microsoft.DebugEngineHost.VSCode
{
Expand Down Expand Up @@ -52,8 +55,25 @@ internal ExceptionSettings()
{
}

#if DEBUG
internal void ValidateExceptionFilters()
{
foreach (ExceptionBreakpointFilter filter in _exceptionFilters)
{
// Make sure that the category GUID was listed in the config file.
if (!_categories.Where(c => c.Id == filter.categoryId).Any())
{
Debug.Fail(string.Format(CultureInfo.InvariantCulture, "Missing category '{0}' from configuration file.", filter.categoryId));
}
}
}
#endif

internal void MakeReadOnly()
{
#if DEBUG
ValidateExceptionFilters();
#endif
_categories = new ReadOnlyCollection<CategoryConfiguration>(_categories);
_exceptionFilters = new ReadOnlyCollection<ExceptionBreakpointFilter>(_exceptionFilters);
}
Expand Down
28 changes: 25 additions & 3 deletions src/MICore/CommandFactories/MICommandFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public virtual Task<bool> SetStepFiltering(bool enabled)
// Calls to VarCreate will change the current debugger thread and frame selection to what is passed in. This is because it needs to be queried in the context of a thread/frame id.
public virtual async Task<Results> VarCreate(string expression, int threadId, uint frameLevel, enum_EVALFLAGS dwFlags, ResultClass resultClass = ResultClass.done)
{
string quoteEscapedExpression = EscapeQuotes(expression);
string quoteEscapedExpression = EscapeQuotes(HandleInvalidChars(expression));
string command = string.Format(CultureInfo.InvariantCulture, "-var-create - * \"{0}\"", quoteEscapedExpression);
Results results = await ThreadFrameCmdAsync(command, resultClass, threadId, frameLevel);

Expand Down Expand Up @@ -366,7 +366,8 @@ public async Task<Results> VarEvaluateExpression(string variableName, ResultClas

public virtual async Task<string> VarAssign(string variableName, string expression, int threadId, uint frameLevel)
{
string command = string.Format(CultureInfo.InvariantCulture, "-var-assign {0} \"{1}\"", variableName, expression);
string quoteEscapedExpression = EscapeQuotes(HandleInvalidChars(expression));
string command = string.Format(CultureInfo.InvariantCulture, "-var-assign {0} \"{1}\"", variableName, quoteEscapedExpression);
Results results = await _debugger.CmdAsync(command, ResultClass.done);
return results.FindString("value");
}
Expand Down Expand Up @@ -422,7 +423,7 @@ public virtual Task<StringBuilder> BuildBreakInsert(string condition, bool enabl
if (condition != null)
{
cmd.Append("-c \"");
cmd.Append(condition);
cmd.Append(EscapeQuotes(condition));
cmd.Append("\" ");
}
if (!enabled)
Expand Down Expand Up @@ -591,6 +592,15 @@ public virtual void DecodeExceptionReceivedProperties(Results miExceptionResult,

#endregion

#region Miscellaneous

public virtual Task<string[]> AutoComplete(string command, int threadId, uint frameLevel)
{
throw new NotImplementedException();
}

#endregion

#region Helpers

public abstract string GetTargetArchitectureCommand();
Expand All @@ -609,6 +619,18 @@ internal string EscapeQuotes(string str)
return str.Replace("\"", "\\\"");
}

internal string HandleInvalidChars(string str)
{
char[] invalidChars = { '\r', '\n' };
StringBuilder builder = new StringBuilder();
foreach (char c in str)
{

builder.Append(invalidChars.Contains(c) ? ' ' : c);
}
return builder.ToString();
}

#endregion

#region Other
Expand Down
85 changes: 83 additions & 2 deletions src/MICore/CommandFactories/gdb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,18 @@ public override async Task<List<ulong>> StartAddressesForLine(string file, uint
return addresses;
}

public override Task EnableTargetAsyncOption()
public override async Task EnableTargetAsyncOption()
{
// Linux attach TODO: GDB will fail this command when attaching. This is worked around
// by using signals for that case.
return _debugger.CmdAsync("-gdb-set target-async on", ResultClass.None);
Results result = await _debugger.CmdAsync("-gdb-set mi-async on", ResultClass.None);

// 'set mi-async on' will error on older versions of gdb (older than 11.x)
// Try enabling with the older 'target-async' keyword.
if (result.ResultClass == ResultClass.error)
{
await _debugger.CmdAsync("-gdb-set target-async on", ResultClass.None);
}
}

public override async Task Terminate()
Expand Down Expand Up @@ -278,5 +285,79 @@ public override async Task Catch(string name, bool onlyOnce = false, ResultClass
string command = onlyOnce ? "tcatch " : "catch ";
await _debugger.ConsoleCmdAsync(command + name, allowWhileRunning: false);
}

public override async Task<string[]> AutoComplete(string command, int threadId, uint frameLevel)
{
command = "-complete \"" + command + "\"";
Results res;
if (threadId == -1)
res = await _debugger.CmdAsync(command, ResultClass.done);
else
res = await ThreadFrameCmdAsync(command, ResultClass.done, threadId, frameLevel);

var matchlist = res.Find<ValueListValue>("matches");

if (int.Parse(res.FindString("max_completions_reached"), CultureInfo.InvariantCulture) != 0)
_debugger.Logger.WriteLine("We reached max-completions!");

return matchlist?.AsStrings;
}

public override IEnumerable<Guid> GetSupportedExceptionCategories()
{
const string CppExceptionCategoryString = "{3A12D0B7-C26C-11D0-B442-00A0244A1DD2}";
return new Guid[] { new Guid(CppExceptionCategoryString) };
}

public override async Task<IEnumerable<ulong>> SetExceptionBreakpoints(Guid exceptionCategory, IEnumerable<string> exceptionNames, ExceptionBreakpointStates exceptionBreakpointStates)
{
string command;
Results result;
List<ulong> breakpointNumbers = new List<ulong>();

if (exceptionNames == null) // set breakpoint for all exceptions in exceptionCategory
{
command = "-catch-throw";
result = await _debugger.CmdAsync(command, ResultClass.None);
switch (result.ResultClass)
{
case ResultClass.done:
var breakpointNumber = result.Find("bkpt").FindUint("number");
breakpointNumbers.Add(breakpointNumber);
break;
case ResultClass.error:
default:
throw new NotSupportedException();
}
}
else // set breakpoint for each exceptionName in exceptionNames
{
command = "-catch-throw -r \\b";
foreach (string exceptionName in exceptionNames)
{
result = await _debugger.CmdAsync(command + exceptionName + "\\b", ResultClass.None);
switch (result.ResultClass)
{
case ResultClass.done:
var breakpointNumber = result.Find("bkpt").FindUint("number");
breakpointNumbers.Add(breakpointNumber);
break;
case ResultClass.error:
default:
throw new NotSupportedException();
}
}
}

return breakpointNumbers;
}

public override async Task RemoveExceptionBreakpoint(Guid exceptionCategory, IEnumerable<ulong> exceptionBreakpoints)
{
foreach (ulong breakpointNumber in exceptionBreakpoints)
{
await BreakDelete(breakpointNumber.ToString(CultureInfo.InvariantCulture));
}
}
}
}
Loading

0 comments on commit 4325db0

Please sign in to comment.