Skip to content

Commit

Permalink
Merge pull request #1254 from microsoft/main
Browse files Browse the repository at this point in the history
Merge 'main' into 'release_mdd'
  • Loading branch information
gc46 authored Jan 5, 2022
2 parents d930c7a + 2586fe8 commit 4d31618
Show file tree
Hide file tree
Showing 21 changed files with 634 additions and 180 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
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
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
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
2 changes: 1 addition & 1 deletion src/MICore/CommandFactories/MICommandFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -423,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
11 changes: 9 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
2 changes: 1 addition & 1 deletion src/MICore/CommandFactories/lldb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public async override Task<StringBuilder> BuildBreakInsert(string condition, boo
if (condition != null)
{
cmd.Append("-c \"");
cmd.Append(condition);
cmd.Append(EscapeQuotes(condition));
cmd.Append("\" ");
}
if (!enabled)
Expand Down
4 changes: 2 additions & 2 deletions src/MIDebugEngine/Engine.Impl/DebuggedProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1189,9 +1189,9 @@ private async Task HandleBreakModeEvent(ResultEventArgs results, BreakRequest br
bplist.AddRange(bkpt);
_callback.OnBreakpoint(thread, bplist.AsReadOnly());
}
else if (ExceptionManager.TryGetExceptionBreakpoint(bkptno, out string exceptionName, out Guid exceptionCategoryGuid)) // exception breakpoint hit
else if (ExceptionManager.TryGetExceptionBreakpoint(bkptno, addr, frame, out string exceptionName, out string description, out Guid exceptionCategoryGuid)) // exception breakpoint hit
{
_callback.OnException(thread, exceptionName, "", 0, exceptionCategoryGuid, ExceptionBreakpointStates.BreakThrown);
_callback.OnException(thread, exceptionName, description, 0, exceptionCategoryGuid, ExceptionBreakpointStates.BreakThrown);
}
else if (!this.EntrypointHit)
{
Expand Down
24 changes: 22 additions & 2 deletions src/MIDebugEngine/Engine.Impl/ExceptionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,10 @@ public void SetAllExceptions(enum_EXCEPTION_STATE dwState)
}
}

public bool TryGetExceptionBreakpoint(string bkptno, out string exceptionName, out Guid exceptionCategoryGuid)
public bool TryGetExceptionBreakpoint(string bkptno, ulong address, TupleValue frame, out string exceptionName, out string exceptionDescription, out Guid exceptionCategoryGuid)
{
exceptionName = null;
exceptionName = string.Empty;
exceptionDescription = string.Empty;
exceptionCategoryGuid = Guid.Empty;
ExceptionCategorySettings categorySettings;
if (_categoryMap.TryGetValue(CppExceptionCategoryGuid, out categorySettings))
Expand All @@ -307,10 +308,29 @@ public bool TryGetExceptionBreakpoint(string bkptno, out string exceptionName, o
exceptionName = categorySettings.CurrentRules.FirstOrDefault(pair => pair.Value == breakpointNumber).Key;
if (exceptionName != null)
{
// The string to use when displaying which exception caused the breakpoint to hit.
// It is empty if it uses the category name
string displayException = string.Empty;

if (exceptionName.Length < 1 || exceptionName == "*") // if exceptionName is "*", the exceptions category is selected
{
exceptionName = categorySettings.CategoryName;
}
else
{
displayException = string.Format(CultureInfo.InvariantCulture, " '{0}'", exceptionName);
}

string functionName = frame?.TryFindString("func");
if (string.IsNullOrWhiteSpace(functionName))
{
exceptionDescription = string.Format(CultureInfo.CurrentCulture, ResourceStrings.Exception_Thrown, displayException, address);
}
else
{
exceptionDescription = string.Format(CultureInfo.CurrentCulture, ResourceStrings.Exception_Thrown_with_Source, displayException, address, functionName);
}

exceptionCategoryGuid = CppExceptionCategoryGuid;
return true;

Expand Down
18 changes: 18 additions & 0 deletions src/MIDebugEngine/ResourceStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/MIDebugEngine/ResourceStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,12 @@ See https://aka.ms/miengine-gdb-troubleshooting for details.</value>
<value>Warning: Exceptions are not supported in this scenario.
</value>
</data>
<data name="Exception_Thrown" xml:space="preserve">
<value>Exception{0} thrown at 0x{1:X}.</value>
<comment>0 = optional exception name, 1 = address</comment>
</data>
<data name="Exception_Thrown_with_Source" xml:space="preserve">
<value>Exception{0} thrown at 0x{1:X} in {2}.</value>
<comment>0 = optional exception name, 1 = address, 2 = exception file</comment>
</data>
</root>
Loading

0 comments on commit 4d31618

Please sign in to comment.