Skip to content
Merged
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,13 @@ public int ResolveName(string? pszName, uint dwFlags, out IVsEnumDebugName? ppNa
return VSConstants.S_FALSE;
}

// NOTE(cyrusn): We have to wait here because the debuggers' ResolveName
// call is synchronous. In the future it would be nice to make it async.
ppNames = this.ThreadingContext.JoinableTaskFactory.Run(async () =>
{
// We're in a blocking jtf run. So CA(true) all calls to ensure we're coming bac
// and using the blocked thread whenever possible.

using (Logger.LogBlock(FunctionId.Debugging_VsLanguageDebugInfo_ResolveName, CancellationToken.None))
{
using var waitContext = _uiThreadOperationExecutor.BeginExecute(
Expand All @@ -192,12 +197,10 @@ public int ResolveName(string? pszName, uint dwFlags, out IVsEnumDebugName? ppNa
{
var solution = _languageService.Workspace.CurrentSolution;

// NOTE(cyrusn): We have to wait here because the debuggers' ResolveName
// call is synchronous. In the future it would be nice to make it async.
if (_breakpointService != null)
{
var breakpoints = await _breakpointService.ResolveBreakpointsAsync(
solution, pszName, cancellationToken).ConfigureAwait(false);
solution, pszName, cancellationToken).ConfigureAwait(true);
var debugNames = await breakpoints.SelectAsArrayAsync(
bp => CreateDebugNameAsync(bp, cancellationToken)).ConfigureAwait(true);

Expand All @@ -210,23 +213,26 @@ public int ResolveName(string? pszName, uint dwFlags, out IVsEnumDebugName? ppNa
});

return ppNames != null ? VSConstants.S_OK : VSConstants.E_NOTIMPL;
}

private async ValueTask<IVsDebugName> CreateDebugNameAsync(
BreakpointResolutionResult breakpoint, CancellationToken cancellationToken)
{
var document = breakpoint.Document;
var filePath = _languageService.Workspace.GetFilePath(document.Id);
var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
var span = text.GetVsTextSpanForSpan(breakpoint.TextSpan);
// If we're inside an Venus code nugget, we need to map the span to the surface buffer.
// Otherwise, we'll just use the original span.
var mappedSpan = await span.MapSpanFromSecondaryBufferToPrimaryBufferAsync(
this.ThreadingContext, document.Id, cancellationToken).ConfigureAwait(true);
if (mappedSpan != null)
span = mappedSpan.Value;

return new VsDebugName(breakpoint.LocationNameOpt, filePath!, span);
async ValueTask<IVsDebugName> CreateDebugNameAsync(
BreakpointResolutionResult breakpoint, CancellationToken cancellationToken)
{
// We're in a blocking jtf run. So CA(true) all calls to ensure we're coming bac
// and using the blocked thread whenever possible.

var document = breakpoint.Document;
var filePath = _languageService.Workspace.GetFilePath(document.Id);
var text = document.GetTextSynchronously(cancellationToken);
var span = text.GetVsTextSpanForSpan(breakpoint.TextSpan);
// If we're inside an Venus code nugget, we need to map the span to the surface buffer.
// Otherwise, we'll just use the original span.
var mappedSpan = await span.MapSpanFromSecondaryBufferToPrimaryBufferAsync(
this.ThreadingContext, document.Id, cancellationToken).ConfigureAwait(true);
if (mappedSpan != null)
span = mappedSpan.Value;

return new VsDebugName(breakpoint.LocationNameOpt, filePath!, span);
}
}

public int ValidateBreakpointLocation(IVsTextBuffer pBuffer, int iLine, int iCol, VsTextSpan[] pCodeSpan)
Expand Down