Skip to content

Commit

Permalink
Merge pull request #1303 from microsoft/main
Browse files Browse the repository at this point in the history
Merge 'main' into 'release-cpptools'
  • Loading branch information
WardenGnaw authored Apr 5, 2022
2 parents 340124c + 452572f commit a05b8db
Show file tree
Hide file tree
Showing 27 changed files with 897 additions and 191 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/Build-And-Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ jobs:
gdb --version
- run: >
- run: |
set PATH="%PATH%;D:\a\_temp\msys64\mingw64\bin\"
dotnet test ${{ github.workspace }}\bin\DebugAdapterProtocolTests\Debug\CppTests\CppTests.dll --logger "trx;LogFileName=${{ github.workspace }}\bin\DebugAdapterProtocolTests\Debug\CppTests\results.trx"
- name: 'Upload Test Results'
Expand Down
60 changes: 60 additions & 0 deletions IL/Microsoft.Internal.VisualStudio.Interop.il
Original file line number Diff line number Diff line change
Expand Up @@ -918,4 +918,64 @@
.get instance class [mscorlib]System.Array Microsoft.Internal.VisualStudio.Shell.Interop.IVsTelemetryPropertyBag::get_AllPropertyNames()
}
}
.class public interface abstract import IVsExtensionManagerPrivate
{
.custom instance void [mscorlib]System.Runtime.InteropServices.GuidAttribute::.ctor(string) = { string('753E55C6-E779-4A7A-BCD1-FD87181D52C0') }
.custom instance void [mscorlib]System.Runtime.InteropServices.InterfaceTypeAttribute::.ctor(valuetype [mscorlib]System.Runtime.InteropServices.ComInterfaceType) = { int32(1) }
.method public virtual hidebysig newslot abstract
instance int32 GetEnabledExtensionContentLocations([in] string marshal(lpwstr) szContentTypeName, [in] uint32 cContentLocations, [out] string[] marshal(bstr[ + 1]) rgbstrContentLocations, [out] string[] marshal(bstr[ + 1]) rgbstrUniqueExtensionStrings, [out] uint32& pcContentLocations)
preservesig internalcall
{
.param [1]
.custom instance void [mscorlib]System.Runtime.InteropServices.ComAliasNameAttribute::.ctor(string) = { string('OLE.LPCWSTR') }
.param [2]
.custom instance void [mscorlib]System.Runtime.InteropServices.ComAliasNameAttribute::.ctor(string) = { string('OLE.ULONG') }
.param [5]
.custom instance void [mscorlib]System.Runtime.InteropServices.ComAliasNameAttribute::.ctor(string) = { string('OLE.ULONG') }
}
.method public virtual hidebysig newslot abstract
instance int32 GetEnabledExtensionContentLocationsWithNames([in] string marshal(lpwstr) szContentTypeName, [in] uint32 cContentLocations, [out] string[] marshal(bstr[ + 1]) rgbstrContentLocations, [out] string[] marshal(bstr[ + 1]) rgbstrUniqueExtensionStrings, [out] string[] marshal(bstr[ + 1]) rgbstrExtensionNames, [out] uint32& pcContentLocations)
preservesig internalcall
{
.param [1]
.custom instance void [mscorlib]System.Runtime.InteropServices.ComAliasNameAttribute::.ctor(string) = { string('OLE.LPCWSTR') }
.param [2]
.custom instance void [mscorlib]System.Runtime.InteropServices.ComAliasNameAttribute::.ctor(string) = { string('OLE.ULONG') }
.param [6]
.custom instance void [mscorlib]System.Runtime.InteropServices.ComAliasNameAttribute::.ctor(string) = { string('OLE.ULONG') }
}
.method public virtual hidebysig newslot abstract
instance int32 GetDisabledExtensionContentLocations([in] string marshal(lpwstr) szContentTypeName, [in] uint32 cContentLocations, [out] string[] marshal(bstr[ + 1]) rgbstrContentLocations, [out] string[] marshal(bstr[ + 1]) rgbstrUniqueExtensionStrings, [out] uint32& pcContentLocations)
preservesig internalcall
{
.param [1]
.custom instance void [mscorlib]System.Runtime.InteropServices.ComAliasNameAttribute::.ctor(string) = { string('OLE.LPCWSTR') }
.param [2]
.custom instance void [mscorlib]System.Runtime.InteropServices.ComAliasNameAttribute::.ctor(string) = { string('OLE.ULONG') }
.param [5]
.custom instance void [mscorlib]System.Runtime.InteropServices.ComAliasNameAttribute::.ctor(string) = { string('OLE.ULONG') }
}
.method public virtual hidebysig newslot abstract
instance int32 GetLastConfigurationChange([out] valuetype [mscorlib]System.DateTime[] marshal([]) pTimestamp)
preservesig internalcall
{
}
.method public virtual hidebysig newslot abstract
instance int32 LogAllInstalledExtensions()
preservesig internalcall
{
}
.method public virtual hidebysig newslot abstract
instance int32 GetUniqueExtensionString([in] string marshal(lpwstr) szExtensionIdentifier, [out] string& marshal(bstr) pbstrUniqueString)
preservesig internalcall
{
.param [1]
.custom instance void [mscorlib]System.Runtime.InteropServices.ComAliasNameAttribute::.ctor(string) = { string('OLE.LPCWSTR') }
}
}
.class public interface abstract import SVsExtensionManager
{
.custom instance void [mscorlib]System.Runtime.InteropServices.GuidAttribute::.ctor(string) = { string('316F4DE6-3CA4-4F0D-B003-962D28F65238') }
.custom instance void [mscorlib]System.Runtime.InteropServices.InterfaceTypeAttribute::.ctor(valuetype [mscorlib]System.Runtime.InteropServices.ComInterfaceType) = { int32(1) }
}
}
4 changes: 2 additions & 2 deletions src/DebugEngineHost.Stub/DebugEngineHost.ref.cs
Original file line number Diff line number Diff line change
Expand Up @@ -385,11 +385,11 @@ public static class HostNatvisProject
public delegate void NatvisLoader(string path);

/// <summary>
/// Searches the solution for natvis files, invoking the loader on any which are found.
/// Searches the solution and VSIXs for natvis files, invoking the loader on any which are found.
/// </summary>
/// <param name="loader">Natvis loader method to invoke</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Natvis")]
public static void FindNatvisInSolution(NatvisLoader loader)
public static void FindNatvis(NatvisLoader loader)
{
throw new NotImplementedException();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// // Copyright (c) Microsoft. All rights reserved.
// // Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Runtime.InteropServices;

namespace Microsoft.VisualStudio.Debugger.Interop.MI
{
/// <summary>
/// IDebugProperty for MIEngine
/// </summary>
[ComImport()]
[ComVisible(true)]
[Guid("27F5EFAF-9DBA-4AC0-A456-1F97E50F3CDA")]
[InterfaceType(1)]
public interface IDebugMIEngineProperty
{
/// <summary>
/// Get the expression context for the property
/// </summary>
[PreserveSig]
int GetExpressionContext([Out, MarshalAs(UnmanagedType.Interface)] out IDebugExpressionContext2 ppExpressionContext);
}
}
1 change: 1 addition & 0 deletions src/DebugEngineHost.VSCode/DebugEngineHost.VSCode.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

<ItemGroup Label="Compile Shared Interfaces">
<Compile Include="$(MIEngineRoot)\src\DebugEngineHost.Stub\Shared\Microsoft.VisualStudio.Debugger.Interop.DAP.cs" />
<Compile Include="..\DebugEngineHost.Stub\Shared\Microsoft.VisualStudio.Debugger.Interop.MI.cs" Link="Microsoft.VisualStudio.Debugger.Interop.MI.cs" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/DebugEngineHost.VSCode/HostNatvisProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public static class HostNatvisProject
{
public delegate void NatvisLoader(string path);

public static void FindNatvisInSolution(NatvisLoader loader)
public static void FindNatvis(NatvisLoader loader)
{
// In-solution natvis is not supported for VS Code now, so do nothing.
}
Expand Down
1 change: 1 addition & 0 deletions src/DebugEngineHost/DebugEngineHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

<ItemGroup Label="Compile Shared Interfaces">
<Compile Include="$(MIEngineRoot)\src\DebugEngineHost.Stub\Shared\Microsoft.VisualStudio.Debugger.Interop.DAP.cs" />
<Compile Include="$(MIEngineRoot)\src\DebugEngineHost.Stub\Shared\Microsoft.VisualStudio.Debugger.Interop.MI.cs" />
</ItemGroup>

<ItemGroup>
Expand Down
40 changes: 35 additions & 5 deletions src/DebugEngineHost/HostNatvisProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Internal.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.Shell.Interop;
Expand All @@ -29,17 +30,18 @@ public static class HostNatvisProject
public delegate void NatvisLoader(string path);

/// <summary>
/// Searches the solution for natvis files, invoking the loader on any which are found.
/// Searches the solution and VSIXs for natvis files, invoking the loader on any which are found.
/// </summary>
/// <param name="loader">Natvis loader method to invoke</param>
public static void FindNatvisInSolution(NatvisLoader loader)
public static void FindNatvis(NatvisLoader loader)
{
List<string> paths = new List<string>();
try
{
ThreadHelper.JoinableTaskFactory.Run(async () =>
await Internal.FindNatvisInSolutionImplAsync(paths)
);
ThreadHelper.JoinableTaskFactory.Run(async () => {
await Internal.FindNatvisInSolutionImplAsync(paths);
Internal.FindNatvisInVSIXImpl(paths);
});
}
catch (Exception)
{
Expand Down Expand Up @@ -193,6 +195,17 @@ public async static System.Threading.Tasks.Task FindNatvisInSolutionImplAsync(Li
}
}

public static void FindNatvisInVSIXImpl(List<string> paths)
{
var extManager = (IVsExtensionManagerPrivate)Package.GetGlobalService(typeof(SVsExtensionManager));
if (extManager == null)
{
return; // failed to find the extension manager
}

BuildEnvironmentPath("NativeCrossPlatformVisualizer", extManager, paths);
}

public static string FindSolutionRootImpl()
{
string root = null;
Expand All @@ -207,6 +220,23 @@ public static string FindSolutionRootImpl()
return root;
}

private static void BuildEnvironmentPath(string name, IVsExtensionManagerPrivate pem, List<string> paths)
{
pem.GetEnabledExtensionContentLocations(name, 0, null, null, out var contentLocations);
if (contentLocations > 0)
{
var rgStrings = new string[contentLocations];
var rgbstrContentLocations = new string[contentLocations];
var rgbstrUniqueStrings = new string[contentLocations];

var hr = pem.GetEnabledExtensionContentLocations(name, contentLocations, rgbstrContentLocations, rgbstrUniqueStrings, out var actualContentLocations);
if (hr == VSConstants.S_OK && actualContentLocations > 0)
{
paths.AddRange(rgbstrContentLocations);
}
}
}

private static void LoadNatvisFromProject(IVsHierarchy hier, List<string> paths, bool solutionLevel)
{
IVsProject4 proj = hier as IVsProject4;
Expand Down
3 changes: 2 additions & 1 deletion src/MICore/Debugger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1253,10 +1253,10 @@ public void ProcessStdOutLine(string line)
{
WaitingOperationDescriptor waitingOperation;
if (_waitingOperations.TryGetValue(id, out waitingOperation) &&
!waitingOperation.EchoReceived &&
line == waitingOperation.Command)
{
// This is just the echo. Ignore.
// Sometimes with lldb we are seeing 2 command echos
waitingOperation.EchoReceived = true;
return;
}
Expand All @@ -1267,6 +1267,7 @@ public void ProcessStdOutLine(string line)
switch (c)
{
case '~':
case '@':
OnDebuggeeOutput(noprefix); // Console stream
break;
case '^':
Expand Down
17 changes: 15 additions & 2 deletions src/MICore/Transports/PipeTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ private void KillPipeProcessAndChildren(Process p)

public override void Close()
{
if (_process != null)
{
_process.EnableRaisingEvents = false;
_process.Exited -= OnProcessExit;
}

if (_writer != null)
{
try
Expand All @@ -168,6 +174,15 @@ public override void Close()
{
// Ignore errors if logout couldn't be written
}

try
{
_writer?.Close();
}
catch (IOException)
{
// There are IO Issues with the writer, ignore since its shutting down.
}
}

base.Close();
Expand All @@ -181,8 +196,6 @@ public override void Close()

if (_process != null)
{
_process.EnableRaisingEvents = false;
_process.Exited -= OnProcessExit;
if (_killOnClose && !_process.HasExited)
{
try
Expand Down
25 changes: 9 additions & 16 deletions src/MIDebugEngine/AD7.Impl/AD7PendingBreakpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,24 +321,8 @@ private int BindWithTimeout()
this.SetError(new AD7ErrorBreakpoint(this, ResourceStrings.LongBind, enum_BP_ERROR_TYPE.BPET_SEV_LOW | enum_BP_ERROR_TYPE.BPET_TYPE_WARNING), true);
return Constants.S_FALSE;
}
else if (this._BPError != null)
{
// Ran into some sort of error
return Constants.E_FAIL;
}
else
{
if ((enum_BP_LOCATION_TYPE)_bpRequestInfo.bpLocation.bpLocationType == enum_BP_LOCATION_TYPE.BPLT_DATA_STRING)
{
lock (_engine.DebuggedProcess.DataBreakpointVariables)
{
string addressName = HostMarshal.GetDataBreakpointStringForIntPtr(_bpRequestInfo.bpLocation.unionmember3);
if (!_engine.DebuggedProcess.DataBreakpointVariables.Contains(addressName)) // might need to expand condition
{
_engine.DebuggedProcess.DataBreakpointVariables.Add(addressName);
}
}
}
return Constants.S_OK;
}
}
Expand Down Expand Up @@ -372,6 +356,15 @@ internal async Task BindAsync()
try
{
bindResult = await PendingBreakpoint.Bind(_address, _size, _engine.DebuggedProcess, _condition, this);

lock (_engine.DebuggedProcess.DataBreakpointVariables)
{
string address = AddressId ?? _address;
if (!_engine.DebuggedProcess.DataBreakpointVariables.Contains(address)) // might need to expand condition
{
_engine.DebuggedProcess.DataBreakpointVariables.Add(address);
}
}
}
catch (ArgumentException ex)
{
Expand Down
Loading

0 comments on commit a05b8db

Please sign in to comment.