Skip to content

Commit 6bfb02e

Browse files
committed
Add debug
1 parent 783a2fe commit 6bfb02e

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/VisualStudio/Core/Def/Implementation/Remote/ServiceHubRemoteHostClient.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ private void OnUnexpectedExceptionThrown(Exception unexpectedException)
6666

6767
public static async Task<RemoteHostClient> CreateAsync(HostWorkspaceServices services, CancellationToken cancellationToken)
6868
{
69+
var shouldBreak = !Environment.GetEnvironmentVariable("RoslynServiceHubCoreDebug").IsNullOrWhiteSpace();
70+
if (shouldBreak)
71+
{
72+
if (!System.Diagnostics.Debugger.IsAttached)
73+
System.Diagnostics.Debugger.Launch();
74+
75+
System.Diagnostics.Debugger.Break();
76+
}
77+
6978
using (Logger.LogBlock(FunctionId.ServiceHubRemoteHostClient_CreateAsync, KeyValueLogMessage.NoProperty, cancellationToken))
7079
{
7180
Logger.Log(FunctionId.RemoteHost_Bitness, KeyValueLogMessage.Create(LogType.Trace, m => m["64bit"] = RemoteHostOptions.IsServiceHubProcess64Bit(services)));

src/Workspaces/Remote/ServiceHub/Services/RemoteHostService.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
using Microsoft.CodeAnalysis.Text;
2525
using Microsoft.VisualStudio.LanguageServices.Telemetry;
2626
using Microsoft.VisualStudio.Telemetry;
27+
using Microsoft.VisualStudio.Utilities.Internal;
2728
using Roslyn.Utilities;
2829
using RoslynLogger = Microsoft.CodeAnalysis.Internal.Log.Logger;
2930

@@ -70,6 +71,15 @@ public RemoteHostService(Stream stream, IServiceProvider serviceProvider)
7071
/// </summary>
7172
public void InitializeGlobalState(string host, int uiCultureLCID, int cultureLCID, string? serializedSession, CancellationToken cancellationToken)
7273
{
74+
var shouldBreak = !Environment.GetEnvironmentVariable("RoslynServiceHubCoreDebug").IsNullOrWhiteSpace();
75+
if (shouldBreak)
76+
{
77+
if (!Debugger.IsAttached)
78+
Debugger.Launch();
79+
80+
Debugger.Break();
81+
}
82+
7383
RunService(() =>
7484
{
7585
// initialize global asset storage

0 commit comments

Comments
 (0)