Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/workflows/Build-And-Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,10 @@ jobs:
which g++
which gdb
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
# TODO: Try to make core dumps work
# Related CoreDump Tests: https://github.com/microsoft/MIEngine/issues/1170
# echo 1 | sudo tee /proc/sys/kernel/core_uses_pid
# ulimit -S -c unlimited
# sudo sysctl -w kernel.core_pattern=${{ github.workspace }}/core.%e
# Enable core dumps: set pattern to "core" so dumps land in CWD (the debuggee output dir)
echo core | sudo tee /proc/sys/kernel/core_pattern
echo 0 | sudo tee /proc/sys/kernel/core_uses_pid
sudo systemctl disable apport.service 2>/dev/null || true

- run: |
${{ github.workspace }}/eng/Scripts/CI-Build.sh
Expand Down
25 changes: 25 additions & 0 deletions IL/Microsoft.Internal.VisualStudio.Shell.Embeddable.il
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89)
.ver 4:0:0:0
}
.assembly Microsoft.Internal.VisualStudio.Shell.Embeddable
{
.custom instance void [mscorlib]System.Runtime.InteropServices.ImportedFromTypeLibAttribute::.ctor(string) = { string('Microsoft.Internal.VisualStudio.Shell.Embeddable') }
.custom instance void [mscorlib]System.Runtime.InteropServices.GuidAttribute::.ctor(string) = { string('190F8999-290E-4111-AE15-1509B895B58C') }
.publickey = (00 24 00 00 04 80 00 00 94 00 00 00 06 02 00 00 00 24 00 00 52 53 41 31 00 04 00 00 01 00 01 00 07 D1 FA 57 C4 AE D9 F0 A3 2E 84 AA 0F AE FD 0D E9 E8 FD 6A EC 8F 87 FB 03 76 6C 83 4C 99 92 1E B2 3B E7 9A D9 D5 DC C1 DD 9A D2 36 13 21 02 90 0B 72 3C F9 80 95 7F C4 E1 77 10 8F C6 07 77 4F 29 E8 32 0E 92 EA 05 EC E4 E8 21 C0 A5 EF E8 F1 64 5C 4C 0C 93 C1 AB 99 28 5D 62 2C AA 65 2C 1D FA D6 3D 74 5D 6F 2D E5 F1 7E 5E AF 0F C4 96 3D 26 1C 8A 12 43 65 18 20 6D C0 93 34 4D 5A D2 93)
.hash algorithm 0x00008004
.ver 16:0:0:0
}
.namespace Microsoft.Internal.VisualStudio.Shell.Embeddable.Feedback
{
.class interface public abstract auto ansi import IFeedbackDiagnosticFileProvider
{
.custom instance void [mscorlib]System.Runtime.InteropServices.GuidAttribute::.ctor(string) = { string('5F67C426-4C63-4CDB-917B-45B400B96C31') }
.method public hidebysig newslot abstract virtual
instance class [mscorlib]System.Collections.Generic.IReadOnlyCollection`1<string>
GetFiles() cil managed
{
}
}
}
8 changes: 4 additions & 4 deletions build/version.settings.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<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.-->
<MajorVersion>17</MajorVersion>
<MinorVersion>12</MinorVersion>
<VersionZeroYear>2022</VersionZeroYear>
<MajorVersion>18</MajorVersion>
<MinorVersion>8</MinorVersion>
<VersionZeroYear>2025</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 -->
<AssemblyVersion Condition="'$(AssemblyVersion)'==''">14.0.0.0</AssemblyVersion>
Expand All @@ -31,4 +31,4 @@
<WriteLinesToFile Lines="$(BuildVersion)" File="$(IntermediateOutputPath)\..\NugetPackageVersion.txt" Overwrite="true"/>
</Target>

</Project>
</Project>
6 changes: 5 additions & 1 deletion eng/Scripts/CI-Test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ if [ ! -f "$RootDir/bin/DebugAdapterProtocolTests/Debug/CppTests/config.xml" ];
fi
fi

dotnet test "$RootDir"/bin/DebugAdapterProtocolTests/Debug/CppTests/CppTests.dll --logger "trx;LogFileName=$RootDir/bin/DebugAdapterProtocolTests/Debug/CppTests/results.trx"
# Run tests in a subshell with core dumps enabled (ulimit resets when subshell exits)
(
ulimit -c unlimited
dotnet test "$RootDir"/bin/DebugAdapterProtocolTests/Debug/CppTests/CppTests.dll --logger "trx;LogFileName=$RootDir/bin/DebugAdapterProtocolTests/Debug/CppTests/results.trx"
)
54 changes: 54 additions & 0 deletions loc/lci/OpenFolderSchema.json.lci
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,60 @@
<Cmt Name="LcxAdmin"><![CDATA[{Locked}]]></Cmt>
</Cmts>
</Item>
<Item ItemId=";debugExtensions.cppdbg.schema.definitions.cpp_schema.properties.debuginfod.description" ItemType="0" PsrId="306" InstFlg="true" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Controls GDB's debuginfod behavior for automatic downloading of debug symbols.]]></Val>
</Str>
<Disp Icon="Str" />
<Cmts>
<Cmt Name="LcxAdmin"><![CDATA[{Locked="GDB"} {Locked="debuginfod"}]]></Cmt>
</Cmts>
</Item>
<Item ItemId=";debugExtensions.cppdbg.schema.definitions.cpp_schema.properties.debuginfod.type" ItemType="0" PsrId="306" InstFlg="true" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[object]]></Val>
</Str>
<Disp Icon="Str" />
<Cmts>
<Cmt Name="LcxAdmin"><![CDATA[{Locked}]]></Cmt>
</Cmts>
</Item>
<Item ItemId=";debugExtensions.cppdbg.schema.definitions.cpp_schema.properties.debuginfod.properties.enabled.description" ItemType="0" PsrId="306" InstFlg="true" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[If true (default), GDB's debuginfod support is enabled. Set to false to disable debuginfod, which can prevent GDB from hanging when debuginfod servers are unavailable.]]></Val>
</Str>
<Disp Icon="Str" />
<Cmts>
<Cmt Name="LcxAdmin"><![CDATA[{Locked="GDB"} {Locked="debuginfod"}]]></Cmt>
</Cmts>
</Item>
<Item ItemId=";debugExtensions.cppdbg.schema.definitions.cpp_schema.properties.debuginfod.properties.enabled.type" ItemType="0" PsrId="306" InstFlg="true" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[boolean]]></Val>
</Str>
<Disp Icon="Str" />
<Cmts>
<Cmt Name="LcxAdmin"><![CDATA[{Locked}]]></Cmt>
</Cmts>
</Item>
<Item ItemId=";debugExtensions.cppdbg.schema.definitions.cpp_schema.properties.debuginfod.properties.timeout.description" ItemType="0" PsrId="306" InstFlg="true" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The timeout in seconds for debuginfod server requests. Default is 30. Set to 0 for no timeout override (GDB defaults apply). Applies to local, runInTerminal, and SSH attach transports. This setting is not applied for pipeTransport; set DEBUGINFOD_TIMEOUT and DEBUGINFOD_MAXTIME in the debugger's environment manually.]]></Val>
</Str>
<Disp Icon="Str" />
<Cmts>
<Cmt Name="LcxAdmin"><![CDATA[{Locked="debuginfod"} {Locked="GDB"} {Locked="DEBUGINFOD_TIMEOUT"} {Locked="DEBUGINFOD_MAXTIME"} {Locked="pipeTransport"} {Locked="runInTerminal"} {Locked="SSH"}]]></Cmt>
</Cmts>
</Item>
<Item ItemId=";debugExtensions.cppdbg.schema.definitions.cpp_schema.properties.debuginfod.properties.timeout.type" ItemType="0" PsrId="306" InstFlg="true" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[integer]]></Val>
</Str>
<Disp Icon="Str" />
<Cmts>
<Cmt Name="LcxAdmin"><![CDATA[{Locked}]]></Cmt>
</Cmts>
</Item>
<Item ItemId=";debugExtensions.cppdbg.schema.definitions.cpp_schema.properties.environment.description" ItemType="0" PsrId="306" InstFlg="true" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Environment variables to add to the environment for the program. ]A;Example: [ { "name": "squid", "value": "clam" } ]5D;.]]></Val>
Expand Down
17 changes: 17 additions & 0 deletions src/DebugEngineHost.Stub/DebugEngineHost.ref.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,23 @@ public static void Reset()
{
throw new NotImplementedException();
}

/// <summary>
/// Returns true if the feedback log is currently active
/// </summary>
public static bool IsFeedbackLogEnabled
{
get { throw new NotImplementedException(); }
}

/// <summary>
/// Writes a message to the feedback circular buffer and, if active, to the feedback log file.
/// </summary>
/// <param name="message">The message to write to the feedback log.</param>
public static void WriteFeedbackLog(string message)
{
throw new NotImplementedException();
}
}

/// <summary>
Expand Down
9 changes: 9 additions & 0 deletions src/DebugEngineHost.VSCode/HostLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,14 @@ public static void Reset()
s_engineLogChannel?.Close();
s_engineLogChannel = null;
}

public static bool IsFeedbackLogEnabled
{
get { return false; }
}

public static void WriteFeedbackLog(string message)
{
}
}
}
6 changes: 6 additions & 0 deletions src/DebugEngineHost/DebugEngineHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,19 @@

<ItemGroup Label="Assembly to Generate">
<GenerateAssembly Include="$(ILDir)Microsoft.Internal.VisualStudio.Interop.il" />
<GenerateAssembly Include="$(ILDir)Microsoft.Internal.VisualStudio.Shell.Embeddable.il" />
</ItemGroup>

<ItemGroup Label="References">
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="Microsoft.Internal.VisualStudio.Interop">
<HintPath>$(GeneratedAssembliesDir)Microsoft.Internal.VisualStudio.Interop.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Internal.VisualStudio.Shell.Embeddable">
<HintPath>$(GeneratedAssembliesDir)Microsoft.Internal.VisualStudio.Shell.Embeddable.dll</HintPath>
<EmbedInteropTypes>true</EmbedInteropTypes>
<Private>false</Private>
</Reference>
</ItemGroup>

<Import Project="..\..\build\miengine.targets" />
Expand Down
49 changes: 49 additions & 0 deletions src/DebugEngineHost/FeedbackDiagnosticFileProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// 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.Collections.Generic;
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
using Microsoft.Internal.VisualStudio.Shell.Embeddable.Feedback;

namespace Microsoft.DebugEngineHost
{
[Export(typeof(IFeedbackDiagnosticFileProvider))]
public class FeedbackDiagnosticFileProvider : IFeedbackDiagnosticFileProvider
{
public IReadOnlyCollection<string> GetFiles()
{
if (!HostLogger.HasFeedbackEntries)
{
return Array.Empty<string>();
}

string logFileName = HostLogger.GetFeedbackLogFilePath(Process.GetCurrentProcess().Id);

IReadOnlyCollection<string> entries = HostLogger.GetNewFeedbackEntries();
if (entries.Count > 0)
{
_ = Task.Run(() => WriteFeedbackEntries(logFileName, entries));
}

return new[] { logFileName };
}

private static void WriteFeedbackEntries(string logFileName, IReadOnlyCollection<string> entries)
{
try
{
using (StreamWriter logWriter = FeedbackLogBuffer.OpenLogFile(logFileName))
{
FeedbackLogBuffer.WriteEntries(logWriter, entries);
}
}
catch
{
}
}
}
}
108 changes: 108 additions & 0 deletions src/DebugEngineHost/FeedbackLogBuffer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// 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.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Microsoft.DebugEngineHost
{
/// <summary>
/// In-memory circular buffer that caches recent log messages for feedback reports.
/// </summary>
internal class FeedbackLogBuffer
{
private const int s_maxLogBufferSize = 256 * 1024;

private readonly LinkedList<string> _logBuffer = new LinkedList<string>();
private int _logLength;
private long _writeSequence;
private long _lastFlushSequence;
private readonly object _syncObj = new object();

/// <summary>
/// Returns true if any entries have ever been written to the buffer.
/// </summary>
internal bool HasEntries
{
get
{
lock (_syncObj)
{
return _writeSequence > 0;
}
}
}

internal void Write(string logLine)
{
lock (_syncObj)
{
if (logLine.Length > s_maxLogBufferSize)
{
logLine = logLine.Substring(0, s_maxLogBufferSize);
}

_logBuffer.AddLast(logLine);
_logLength += logLine.Length;
_writeSequence++;

while (_logLength > s_maxLogBufferSize)
{
string entry = _logBuffer.First();
_logLength -= entry.Length;
_logBuffer.RemoveFirst();
}
}
}

internal IReadOnlyCollection<string> FlushNewEntries()
{
lock (_syncObj)
{
long newEntryCount = System.Math.Min(_writeSequence - _lastFlushSequence, _logBuffer.Count);
_lastFlushSequence = _writeSequence;

if (newEntryCount <= 0)
{
return Array.Empty<string>();
}

int skipCount = _logBuffer.Count - (int)newEntryCount;
return _logBuffer.Skip(skipCount).ToList().AsReadOnly();
}
}

/// <summary>
/// Opens the feedback log file for appending with shared read/write access.
/// </summary>
internal static StreamWriter OpenLogFile(string logFileName)
{
var fs = new FileStream(logFileName, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
try
{
return new StreamWriter(fs, Encoding.UTF8);
}
catch
{
fs.Dispose();
throw;
}
}

/// <summary>
/// Writes a collection of log entries to the given writer.
/// </summary>
internal static void WriteEntries(StreamWriter writer, IEnumerable<string> entries)
{
foreach (string logLine in entries)
{
writer.WriteLine(logLine);
}

writer.Flush();
}
}
}
Loading
Loading