提交 07622c78 编写于 作者: D dotnet-bot

Merge in 'release/6.0' changes

<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.NETCore.Runtime.ICU.Transport" Version="6.0.0-rtm.23218.5">
<Dependency Name="Microsoft.NETCore.Runtime.ICU.Transport" Version="6.0.0-rtm.23315.1">
<Uri>https://github.com/dotnet/icu</Uri>
<Sha>cff1c9ff20d271c6698d150e484e8327998595a4</Sha>
<Sha>18b103db239331f9b917e741b13c95eddf32f6df</Sha>
</Dependency>
<Dependency Name="System.Net.MsQuic.Transport" Version="6.0.0-servicing.22205.1">
<Uri>https://github.com/dotnet/msquic</Uri>
......@@ -102,49 +102,49 @@
<Uri>https://github.com/microsoft/vstest</Uri>
<Sha>140434f7109d357d0158ade9e5164a4861513965</Sha>
</Dependency>
<Dependency Name="System.ComponentModel.TypeConverter.TestData" Version="6.0.0-beta.23212.1">
<Dependency Name="System.ComponentModel.TypeConverter.TestData" Version="6.0.0-beta.23316.2">
<Uri>https://github.com/dotnet/runtime-assets</Uri>
<Sha>27b0291e9fb85b6664e4fc7c6bc10bcd059d8ab7</Sha>
<Sha>60b420e88cdd0ec0becb2115e14288adc1a1cb55</Sha>
</Dependency>
<Dependency Name="System.Data.Common.TestData" Version="6.0.0-beta.23212.1">
<Dependency Name="System.Data.Common.TestData" Version="6.0.0-beta.23316.2">
<Uri>https://github.com/dotnet/runtime-assets</Uri>
<Sha>27b0291e9fb85b6664e4fc7c6bc10bcd059d8ab7</Sha>
<Sha>60b420e88cdd0ec0becb2115e14288adc1a1cb55</Sha>
</Dependency>
<Dependency Name="System.Drawing.Common.TestData" Version="6.0.0-beta.23212.1">
<Dependency Name="System.Drawing.Common.TestData" Version="6.0.0-beta.23316.2">
<Uri>https://github.com/dotnet/runtime-assets</Uri>
<Sha>27b0291e9fb85b6664e4fc7c6bc10bcd059d8ab7</Sha>
<Sha>60b420e88cdd0ec0becb2115e14288adc1a1cb55</Sha>
</Dependency>
<Dependency Name="System.IO.Compression.TestData" Version="6.0.0-beta.23212.1">
<Dependency Name="System.IO.Compression.TestData" Version="6.0.0-beta.23316.2">
<Uri>https://github.com/dotnet/runtime-assets</Uri>
<Sha>27b0291e9fb85b6664e4fc7c6bc10bcd059d8ab7</Sha>
<Sha>60b420e88cdd0ec0becb2115e14288adc1a1cb55</Sha>
</Dependency>
<Dependency Name="System.IO.Packaging.TestData" Version="6.0.0-beta.23212.1">
<Dependency Name="System.IO.Packaging.TestData" Version="6.0.0-beta.23316.2">
<Uri>https://github.com/dotnet/runtime-assets</Uri>
<Sha>27b0291e9fb85b6664e4fc7c6bc10bcd059d8ab7</Sha>
<Sha>60b420e88cdd0ec0becb2115e14288adc1a1cb55</Sha>
</Dependency>
<Dependency Name="System.Net.TestData" Version="6.0.0-beta.23212.1">
<Dependency Name="System.Net.TestData" Version="6.0.0-beta.23316.2">
<Uri>https://github.com/dotnet/runtime-assets</Uri>
<Sha>27b0291e9fb85b6664e4fc7c6bc10bcd059d8ab7</Sha>
<Sha>60b420e88cdd0ec0becb2115e14288adc1a1cb55</Sha>
</Dependency>
<Dependency Name="System.Private.Runtime.UnicodeData" Version="6.0.0-beta.23212.1">
<Dependency Name="System.Private.Runtime.UnicodeData" Version="6.0.0-beta.23316.2">
<Uri>https://github.com/dotnet/runtime-assets</Uri>
<Sha>27b0291e9fb85b6664e4fc7c6bc10bcd059d8ab7</Sha>
<Sha>60b420e88cdd0ec0becb2115e14288adc1a1cb55</Sha>
</Dependency>
<Dependency Name="System.Runtime.TimeZoneData" Version="6.0.0-beta.23212.1">
<Dependency Name="System.Runtime.TimeZoneData" Version="6.0.0-beta.23316.2">
<Uri>https://github.com/dotnet/runtime-assets</Uri>
<Sha>27b0291e9fb85b6664e4fc7c6bc10bcd059d8ab7</Sha>
<Sha>60b420e88cdd0ec0becb2115e14288adc1a1cb55</Sha>
</Dependency>
<Dependency Name="System.Security.Cryptography.X509Certificates.TestData" Version="6.0.0-beta.23212.1">
<Dependency Name="System.Security.Cryptography.X509Certificates.TestData" Version="6.0.0-beta.23316.2">
<Uri>https://github.com/dotnet/runtime-assets</Uri>
<Sha>27b0291e9fb85b6664e4fc7c6bc10bcd059d8ab7</Sha>
<Sha>60b420e88cdd0ec0becb2115e14288adc1a1cb55</Sha>
</Dependency>
<Dependency Name="System.Windows.Extensions.TestData" Version="6.0.0-beta.23212.1">
<Dependency Name="System.Windows.Extensions.TestData" Version="6.0.0-beta.23316.2">
<Uri>https://github.com/dotnet/runtime-assets</Uri>
<Sha>27b0291e9fb85b6664e4fc7c6bc10bcd059d8ab7</Sha>
<Sha>60b420e88cdd0ec0becb2115e14288adc1a1cb55</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.CilStrip.Sources" Version="6.0.0-beta.23212.1">
<Dependency Name="Microsoft.DotNet.CilStrip.Sources" Version="6.0.0-beta.23316.2">
<Uri>https://github.com/dotnet/runtime-assets</Uri>
<Sha>27b0291e9fb85b6664e4fc7c6bc10bcd059d8ab7</Sha>
<Sha>60b420e88cdd0ec0becb2115e14288adc1a1cb55</Sha>
</Dependency>
<Dependency Name="runtime.linux-arm64.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk" Version="11.1.0-alpha.1.21416.1">
<Uri>https://github.com/dotnet/llvm-project</Uri>
......@@ -242,13 +242,13 @@
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-optimization</Uri>
<Sha>d50065944d8b41d804448a7056351481d583ad3d</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.HotReload.Utils.Generator.BuildTool" Version="6.0.0-alpha.0.23226.4">
<Dependency Name="Microsoft.DotNet.HotReload.Utils.Generator.BuildTool" Version="6.0.0-alpha.0.23316.3">
<Uri>https://github.com/dotnet/hotreload-utils</Uri>
<Sha>83c5bd71b65d9de362ae0ba2f2cdea94c002c8c7</Sha>
<Sha>2293d2ba069595f1c87f4e002c84cbab7201bfe7</Sha>
</Dependency>
<Dependency Name="System.Runtime.Numerics.TestData" Version="6.0.0-beta.23212.1">
<Dependency Name="System.Runtime.Numerics.TestData" Version="6.0.0-beta.23316.2">
<Uri>https://github.com/dotnet/runtime-assets</Uri>
<Sha>27b0291e9fb85b6664e4fc7c6bc10bcd059d8ab7</Sha>
<Sha>60b420e88cdd0ec0becb2115e14288adc1a1cb55</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0-rc1.21413.4">
<Uri>https://github.com/dotnet/roslyn-analyzers</Uri>
......
......@@ -108,18 +108,18 @@
<SystemValueTupleVersion>4.5.0</SystemValueTupleVersion>
<runtimenativeSystemIOPortsVersion>6.0.0-rc.1.21415.6</runtimenativeSystemIOPortsVersion>
<!-- Runtime-Assets dependencies -->
<SystemRuntimeNumericsTestDataVersion>6.0.0-beta.23212.1</SystemRuntimeNumericsTestDataVersion>
<SystemComponentModelTypeConverterTestDataVersion>6.0.0-beta.23212.1</SystemComponentModelTypeConverterTestDataVersion>
<SystemDataCommonTestDataVersion>6.0.0-beta.23212.1</SystemDataCommonTestDataVersion>
<SystemDrawingCommonTestDataVersion>6.0.0-beta.23212.1</SystemDrawingCommonTestDataVersion>
<SystemIOCompressionTestDataVersion>6.0.0-beta.23212.1</SystemIOCompressionTestDataVersion>
<SystemIOPackagingTestDataVersion>6.0.0-beta.23212.1</SystemIOPackagingTestDataVersion>
<SystemNetTestDataVersion>6.0.0-beta.23212.1</SystemNetTestDataVersion>
<SystemPrivateRuntimeUnicodeDataVersion>6.0.0-beta.23212.1</SystemPrivateRuntimeUnicodeDataVersion>
<SystemRuntimeTimeZoneDataVersion>6.0.0-beta.23212.1</SystemRuntimeTimeZoneDataVersion>
<SystemSecurityCryptographyX509CertificatesTestDataVersion>6.0.0-beta.23212.1</SystemSecurityCryptographyX509CertificatesTestDataVersion>
<SystemWindowsExtensionsTestDataVersion>6.0.0-beta.23212.1</SystemWindowsExtensionsTestDataVersion>
<MicrosoftDotNetCilStripSourcesVersion>6.0.0-beta.23212.1</MicrosoftDotNetCilStripSourcesVersion>
<SystemRuntimeNumericsTestDataVersion>6.0.0-beta.23316.2</SystemRuntimeNumericsTestDataVersion>
<SystemComponentModelTypeConverterTestDataVersion>6.0.0-beta.23316.2</SystemComponentModelTypeConverterTestDataVersion>
<SystemDataCommonTestDataVersion>6.0.0-beta.23316.2</SystemDataCommonTestDataVersion>
<SystemDrawingCommonTestDataVersion>6.0.0-beta.23316.2</SystemDrawingCommonTestDataVersion>
<SystemIOCompressionTestDataVersion>6.0.0-beta.23316.2</SystemIOCompressionTestDataVersion>
<SystemIOPackagingTestDataVersion>6.0.0-beta.23316.2</SystemIOPackagingTestDataVersion>
<SystemNetTestDataVersion>6.0.0-beta.23316.2</SystemNetTestDataVersion>
<SystemPrivateRuntimeUnicodeDataVersion>6.0.0-beta.23316.2</SystemPrivateRuntimeUnicodeDataVersion>
<SystemRuntimeTimeZoneDataVersion>6.0.0-beta.23316.2</SystemRuntimeTimeZoneDataVersion>
<SystemSecurityCryptographyX509CertificatesTestDataVersion>6.0.0-beta.23316.2</SystemSecurityCryptographyX509CertificatesTestDataVersion>
<SystemWindowsExtensionsTestDataVersion>6.0.0-beta.23316.2</SystemWindowsExtensionsTestDataVersion>
<MicrosoftDotNetCilStripSourcesVersion>6.0.0-beta.23316.2</MicrosoftDotNetCilStripSourcesVersion>
<!-- dotnet-optimization dependencies -->
<optimizationwindows_ntx64MIBCRuntimeVersion>1.0.0-prerelease.21416.5</optimizationwindows_ntx64MIBCRuntimeVersion>
<optimizationwindows_ntx86MIBCRuntimeVersion>1.0.0-prerelease.21416.5</optimizationwindows_ntx86MIBCRuntimeVersion>
......@@ -162,7 +162,7 @@
<MicrosoftNETILLinkTasksVersion>6.0.100-1.21459.1</MicrosoftNETILLinkTasksVersion>
<MicrosoftNETILLinkAnalyzerPackageVersion>$(MicrosoftNETILLinkTasksVersion)</MicrosoftNETILLinkAnalyzerPackageVersion>
<!-- ICU -->
<MicrosoftNETCoreRuntimeICUTransportVersion>6.0.0-rtm.23218.5</MicrosoftNETCoreRuntimeICUTransportVersion>
<MicrosoftNETCoreRuntimeICUTransportVersion>6.0.0-rtm.23315.1</MicrosoftNETCoreRuntimeICUTransportVersion>
<!-- MsQuic -->
<SystemNetMsQuicTransportVersion>6.0.0-servicing.22205.1</SystemNetMsQuicTransportVersion>
<!-- Mono LLVM -->
......
......@@ -719,5 +719,13 @@ static T[] AllocateNewUninitializedArray(int length, bool pinned)
return Unsafe.As<T[]>(AllocateNewArray(typeof(T[]).TypeHandle.Value, length, flags));
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern long _GetTotalPauseDuration();
public static TimeSpan GetTotalPauseDuration()
{
return new TimeSpan(_GetTotalPauseDuration());
}
}
}
......@@ -45045,6 +45045,11 @@ void GCHeap::GetMemoryInfo(uint64_t* highMemLoadThresholdBytes,
#endif //_DEBUG
}
int64_t GCHeap::GetTotalPauseDuration()
{
return (int64_t)(gc_heap::total_suspended_time * 10);
}
uint32_t GCHeap::GetMemoryLoad()
{
uint32_t memory_load = 0;
......@@ -180,7 +180,9 @@ public:
bool* isConcurrent,
uint64_t* genInfoRaw,
uint64_t* pauseInfoRaw,
int kind);;
int kind);
int64_t GetTotalPauseDuration();
uint32_t GetMemoryLoad();
......
......@@ -925,6 +925,9 @@ public:
IGCHeap() {}
virtual ~IGCHeap() {}
// Get the total paused duration
virtual int64_t GetTotalPauseDuration() = 0;
};
#ifdef WRITE_BARRIER_CHECK
......
......@@ -674,6 +674,16 @@ UINT64 GCInterface::m_remPressure[MEM_PRESSURE_COUNT] = {0, 0, 0, 0}; // his
// (m_iteration % MEM_PRESSURE_COUNT) is used as an index into m_addPressure and m_remPressure
UINT GCInterface::m_iteration = 0;
FCIMPL0(INT64, GCInterface::GetTotalPauseDuration)
{
FCALL_CONTRACT;
FC_GC_POLL_NOT_NEEDED();
return GCHeapUtilities::GetGCHeap()->GetTotalPauseDuration();
}
FCIMPLEND
FCIMPL2(void, GCInterface::GetMemoryInfo, Object* objUNSAFE, int kind)
{
FCALL_CONTRACT;
......
......@@ -143,6 +143,7 @@ public:
static FORCEINLINE UINT64 InterlockedAdd(UINT64 *pAugend, UINT64 addend);
static FORCEINLINE UINT64 InterlockedSub(UINT64 *pMinuend, UINT64 subtrahend);
static FCDECL0(INT64, GetTotalPauseDuration);
static FCDECL2(void, GetMemoryInfo, Object* objUNSAFE, int kind);
static FCDECL0(UINT32, GetMemoryLoad);
static FCDECL0(int, GetGcLatencyMode);
......
......@@ -706,6 +706,7 @@ FCFuncStart(gGCInterfaceFuncs)
FCFuncElement("_WaitForFullGCComplete", GCInterface::WaitForFullGCComplete)
FCFuncElement("_CollectionCount", GCInterface::CollectionCount)
FCFuncElement("GetMemoryInfo", GCInterface::GetMemoryInfo)
FCFuncElement("_GetTotalPauseDuration", GCInterface::GetTotalPauseDuration)
FCFuncElement("GetMemoryLoad", GCInterface::GetMemoryLoad)
QCFuncElement("_StartNoGCRegion", GCInterface::StartNoGCRegion)
QCFuncElement("_EndNoGCRegion", GCInterface::EndNoGCRegion)
......
......@@ -20,7 +20,7 @@
<!-- When building from source, ensure the RID we're building for is part of the RID graph -->
<AdditionalRuntimeIdentifiers Condition="'$(DotNetBuildFromSource)' == 'true'">$(AdditionalRuntimeIdentifiers);$(OutputRID)</AdditionalRuntimeIdentifiers>
<ServicingVersion>11</ServicingVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
......
......@@ -24,4 +24,5 @@ CannotMakeMemberAbstract : Member 'public System.Boolean System.IO.FileSystemInf
CannotMakeMemberAbstract : Member 'public System.String System.IO.FileSystemInfo.Name.get()' is abstract in the reference but is not abstract in the implementation.
# C# generates backing fields for fixed buffers as public.
TypesMustExist : Type 'System.IO.Enumeration.FileSystemEntry.<_fileNameBuffer>e__FixedBuffer' does not exist in the reference but it does exist in the implementation.
# This API only exists on servicing builds after the commit that introduce it
MembersMustExist : Member 'public System.TimeSpan System.GC.GetTotalPauseDuration()' does not exist in the reference but it does exist in the implementation.
\ No newline at end of file
......@@ -313,5 +313,10 @@ internal static int GetLastGCPercentTimeInGC()
{
return (int)EventPipeInternal.GetRuntimeCounterValue(EventPipeInternal.RuntimeCounters.GC_LAST_PERCENT_TIME_IN_GC);
}
public static TimeSpan GetTotalPauseDuration()
{
return TimeSpan.Zero;
}
}
}
......@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
......@@ -288,6 +289,7 @@ internal class ExecutionContext
public object AuxData { get; set; }
public PauseOnExceptionsKind PauseOnExceptions { get; set; }
internal bool Destroyed { get; set; }
public List<Frame> CallStack { get; set; }
......@@ -341,4 +343,70 @@ public PerScopeCache()
{
}
}
internal sealed class ConcurrentExecutionContextDictionary
{
private ConcurrentDictionary<SessionId, ConcurrentBag<ExecutionContext>> contexts = new ConcurrentDictionary<SessionId, ConcurrentBag<ExecutionContext>>();
public ExecutionContext GetCurrentContext(SessionId sessionId)
=> TryGetCurrentExecutionContextValue(sessionId, out ExecutionContext context)
? context
: throw new KeyNotFoundException($"No execution context found for session {sessionId}");
public bool TryGetCurrentExecutionContextValue(SessionId id, out ExecutionContext executionContext, bool ignoreDestroyedContext = true)
{
executionContext = null;
if (!contexts.TryGetValue(id, out ConcurrentBag<ExecutionContext> contextBag))
return false;
if (contextBag.IsEmpty)
return false;
IEnumerable<ExecutionContext> validContexts = null;
if (ignoreDestroyedContext)
validContexts = contextBag.Where(context => context.Destroyed == false);
else
validContexts = contextBag;
if (!validContexts.Any())
return false;
int maxId = validContexts.Max(context => context.Id);
executionContext = contextBag.FirstOrDefault(context => context.Id == maxId);
return executionContext != null;
}
public void OnDefaultContextUpdate(SessionId sessionId, ExecutionContext newContext)
{
if (TryGetAndAddContext(sessionId, newContext, out ExecutionContext previousContext))
{
foreach (KeyValuePair<string, BreakpointRequest> kvp in previousContext.BreakpointRequests)
{
newContext.BreakpointRequests[kvp.Key] = kvp.Value.Clone();
}
newContext.PauseOnExceptions = previousContext.PauseOnExceptions;
}
}
public bool TryGetAndAddContext(SessionId sessionId, ExecutionContext newExecutionContext, out ExecutionContext previousExecutionContext)
{
bool hasExisting = TryGetCurrentExecutionContextValue(sessionId, out previousExecutionContext, ignoreDestroyedContext: false);
ConcurrentBag<ExecutionContext> bag = contexts.GetOrAdd(sessionId, _ => new ConcurrentBag<ExecutionContext>());
bag.Add(newExecutionContext);
return hasExisting;
}
public void DestroyContext(SessionId sessionId, int id)
{
if (!contexts.TryGetValue(sessionId, out ConcurrentBag<ExecutionContext> contextBag))
return;
foreach (ExecutionContext context in contextBag.Where(x => x.Id == id).ToList())
context.Destroyed = true;
}
public void ClearContexts(SessionId sessionId)
{
if (!contexts.TryGetValue(sessionId, out ConcurrentBag<ExecutionContext> contextBag))
return;
foreach (ExecutionContext context in contextBag)
context.Destroyed = true;
}
public bool ContainsKey(SessionId sessionId) => contexts.ContainsKey(sessionId);
}
}
......@@ -22,7 +22,7 @@ internal class MonoProxy : DevToolsProxy
private IList<string> urlSymbolServerList;
private static HttpClient client = new HttpClient();
private HashSet<SessionId> sessions = new HashSet<SessionId>();
private Dictionary<SessionId, ExecutionContext> contexts = new Dictionary<SessionId, ExecutionContext>();
internal ConcurrentExecutionContextDictionary Contexts = new ConcurrentExecutionContextDictionary();
private const string sPauseOnUncaught = "pause_on_uncaught";
private const string sPauseOnCaught = "pause_on_caught";
......@@ -32,21 +32,6 @@ public MonoProxy(ILoggerFactory loggerFactory, IList<string> urlSymbolServerList
SdbHelper = new MonoSDBHelper(this, logger);
}
internal ExecutionContext GetContext(SessionId sessionId)
{
if (contexts.TryGetValue(sessionId, out ExecutionContext context))
return context;
throw new ArgumentException($"Invalid Session: \"{sessionId}\"", nameof(sessionId));
}
private bool UpdateContext(SessionId sessionId, ExecutionContext executionContext, out ExecutionContext previousExecutionContext)
{
bool previous = contexts.TryGetValue(sessionId, out previousExecutionContext);
contexts[sessionId] = executionContext;
return previous;
}
internal Task<Result> SendMonoCommand(SessionId id, MonoCommands cmd, CancellationToken token) => SendCommand(id, "Runtime.evaluate", JObject.FromObject(cmd), token);
protected override async Task<bool> AcceptEvent(SessionId sessionId, string method, JObject args, CancellationToken token)
......@@ -56,7 +41,7 @@ protected override async Task<bool> AcceptEvent(SessionId sessionId, string meth
case "Runtime.consoleAPICalled":
{
// Don't process events from sessions we aren't tracking
if (!contexts.TryGetValue(sessionId, out ExecutionContext context))
if (!Contexts.TryGetCurrentExecutionContextValue(sessionId, out ExecutionContext context))
return false;
string type = args["type"]?.ToString();
if (type == "debug")
......@@ -129,7 +114,7 @@ protected override async Task<bool> AcceptEvent(SessionId sessionId, string meth
case "Runtime.exceptionThrown":
{
// Don't process events from sessions we aren't tracking
if (!contexts.TryGetValue(sessionId, out ExecutionContext context))
if (!Contexts.TryGetCurrentExecutionContextValue(sessionId, out ExecutionContext context))
return false;
if (!context.IsRuntimeReady)
......@@ -141,10 +126,22 @@ protected override async Task<bool> AcceptEvent(SessionId sessionId, string meth
break;
}
case "Runtime.executionContextDestroyed":
{
Contexts.DestroyContext(sessionId, args["executionContextId"].Value<int>());
return false;
}
case "Runtime.executionContextsCleared":
{
Contexts.ClearContexts(sessionId);
return false;
}
case "Debugger.paused":
{
// Don't process events from sessions we aren't tracking
if (!contexts.TryGetValue(sessionId, out ExecutionContext context))
if (!Contexts.TryGetCurrentExecutionContextValue(sessionId, out ExecutionContext context))
return false;
if (args?["callFrames"]?.Value<JArray>()?.Count == 0)
......@@ -238,7 +235,7 @@ protected override async Task<bool> AcceptEvent(SessionId sessionId, string meth
private async Task<bool> IsRuntimeAlreadyReadyAlready(SessionId sessionId, CancellationToken token)
{
if (contexts.TryGetValue(sessionId, out ExecutionContext context) && context.IsRuntimeReady)
if (Contexts.TryGetCurrentExecutionContextValue(sessionId, out ExecutionContext context) && context.IsRuntimeReady)
return true;
Result res = await SendMonoCommand(sessionId, MonoCommands.IsRuntimeReady(), token);
......@@ -252,7 +249,7 @@ protected override async Task<bool> AcceptCommand(MessageId id, string method, J
if (id == SessionId.Null)
await AttachToTarget(id, token);
if (!contexts.TryGetValue(id, out ExecutionContext context))
if (!Contexts.TryGetCurrentExecutionContextValue(id, out ExecutionContext context))
{
// for Dotnetdebugger.* messages, treat them as handled, thus not passing them on to the browser
return method.StartsWith("DotnetDebugger.", StringComparison.OrdinalIgnoreCase);
......@@ -607,7 +604,7 @@ private async Task<bool> CallOnFunction(MessageId id, JObject args, Cancellation
private async Task<bool> OnSetVariableValue(MessageId id, int scopeId, string varName, JToken varValue, CancellationToken token)
{
ExecutionContext ctx = GetContext(id);
ExecutionContext ctx = Contexts.GetCurrentContext(id);
Frame scope = ctx.CallStack.FirstOrDefault(s => s.Id == scopeId);
if (scope == null)
return false;
......@@ -844,7 +841,7 @@ private async Task<bool> OnReceiveDebuggerAgentEvent(SessionId sessionId, JObjec
if (res.IsErr)
return false;
ExecutionContext context = GetContext(sessionId);
ExecutionContext context = Contexts.GetCurrentContext(sessionId);
byte[] newBytes = Convert.FromBase64String(res.Value?["result"]?["value"]?["value"]?.Value<string>());
var retDebuggerCmd = new MemoryStream(newBytes);
var retDebuggerCmdReader = new MonoBinaryReader(retDebuggerCmd);
......@@ -910,7 +907,7 @@ private async Task<bool> OnReceiveDebuggerAgentEvent(SessionId sessionId, JObjec
internal async Task<MethodInfo> LoadSymbolsOnDemand(AssemblyInfo asm, int method_token, SessionId sessionId, CancellationToken token)
{
ExecutionContext context = GetContext(sessionId);
ExecutionContext context = Contexts.GetCurrentContext(sessionId);
if (urlSymbolServerList.Count == 0)
return null;
if (asm.TriedToLoadSymbolsOnDemand)
......@@ -961,14 +958,7 @@ internal async Task<MethodInfo> LoadSymbolsOnDemand(AssemblyInfo asm, int method
private async Task OnDefaultContext(SessionId sessionId, ExecutionContext context, CancellationToken token)
{
Log("verbose", "Default context created, clearing state and sending events");
if (UpdateContext(sessionId, context, out ExecutionContext previousContext))
{
foreach (KeyValuePair<string, BreakpointRequest> kvp in previousContext.BreakpointRequests)
{
context.BreakpointRequests[kvp.Key] = kvp.Value.Clone();
}
context.PauseOnExceptions = previousContext.PauseOnExceptions;
}
Contexts.OnDefaultContextUpdate(sessionId, context);
if (await IsRuntimeAlreadyReadyAlready(sessionId, token))
await RuntimeReady(sessionId, token);
......@@ -976,7 +966,7 @@ private async Task OnDefaultContext(SessionId sessionId, ExecutionContext contex
private async Task OnResume(MessageId msg_id, CancellationToken token)
{
ExecutionContext ctx = GetContext(msg_id);
ExecutionContext ctx = Contexts.GetCurrentContext(msg_id);
if (ctx.CallStack != null)
{
// Stopped on managed code
......@@ -985,12 +975,12 @@ private async Task OnResume(MessageId msg_id, CancellationToken token)
//discard managed frames
SdbHelper.ClearCache();
GetContext(msg_id).ClearState();
Contexts.GetCurrentContext(msg_id).ClearState();
}
private async Task<bool> Step(MessageId msg_id, StepKind kind, CancellationToken token)
{
ExecutionContext context = GetContext(msg_id);
ExecutionContext context = Contexts.GetCurrentContext(msg_id);
if (context.CallStack == null)
return false;
......@@ -1061,7 +1051,7 @@ private async Task<bool> OnAssemblyLoadedJSEvent(SessionId sessionId, JObject ev
var assembly_data = Convert.FromBase64String(assembly_b64);
var pdb_data = string.IsNullOrEmpty(pdb_b64) ? null : Convert.FromBase64String(pdb_b64);
var context = GetContext(sessionId);
var context = Contexts.GetCurrentContext(sessionId);
foreach (var source in store.Add(sessionId, assembly_data, pdb_data))
{
await OnSourceFileAdded(sessionId, source, context, token);
......@@ -1080,7 +1070,7 @@ private async Task<bool> OnEvaluateOnCallFrame(MessageId msg_id, int scopeId, st
{
try
{
ExecutionContext context = GetContext(msg_id);
ExecutionContext context = Contexts.GetCurrentContext(msg_id);
if (context.CallStack == null)
return false;
......@@ -1121,7 +1111,7 @@ internal async Task<Result> GetScopeProperties(SessionId msg_id, int scopeId, Ca
{
try
{
ExecutionContext ctx = GetContext(msg_id);
ExecutionContext ctx = Contexts.GetCurrentContext(msg_id);
Frame scope = ctx.CallStack.FirstOrDefault(s => s.Id == scopeId);
if (scope == null)
return Result.Err(JObject.FromObject(new { message = $"Could not find scope with id #{scopeId}" }));
......@@ -1180,14 +1170,21 @@ private async Task OnSourceFileAdded(SessionId sessionId, SourceFile source, Exe
{
if (req.TryResolve(source))
{
await SetBreakpoint(sessionId, context.store, req, true, token);
try
{
await SetBreakpoint(sessionId, context.store, req, true, token);
}
catch (Exception e)
{
logger.LogDebug($"Unexpected error on OnSourceFileAdded {e}");
}
}
}
}
internal async Task<DebugStore> LoadStore(SessionId sessionId, CancellationToken token)
{
ExecutionContext context = GetContext(sessionId);
ExecutionContext context = Contexts.GetCurrentContext(sessionId);
if (Interlocked.CompareExchange(ref context.store, new DebugStore(logger), null) != null)
return await context.Source.Task;
......@@ -1239,7 +1236,7 @@ async Task<string[]> GetLoadedFiles(SessionId sessionId, ExecutionContext contex
private async Task<DebugStore> RuntimeReady(SessionId sessionId, CancellationToken token)
{
ExecutionContext context = GetContext(sessionId);
ExecutionContext context = Contexts.GetCurrentContext(sessionId);
if (Interlocked.CompareExchange(ref context.ready, new TaskCompletionSource<DebugStore>(), null) != null)
return await context.ready.Task;
......@@ -1263,7 +1260,7 @@ private async Task<DebugStore> RuntimeReady(SessionId sessionId, CancellationTok
private async Task ResetBreakpoint(SessionId msg_id, MethodInfo method, CancellationToken token)
{
ExecutionContext context = GetContext(msg_id);
ExecutionContext context = Contexts.GetCurrentContext(msg_id);
foreach (var req in context.BreakpointRequests.Values)
{
if (req.Method != null)
......@@ -1279,7 +1276,7 @@ private async Task RemoveBreakpoint(SessionId msg_id, JObject args, bool isEnCRe
{
string bpid = args?["breakpointId"]?.Value<string>();
ExecutionContext context = GetContext(msg_id);
ExecutionContext context = Contexts.GetCurrentContext(msg_id);
if (!context.BreakpointRequests.TryGetValue(bpid, out BreakpointRequest breakpointRequest))
return;
......@@ -1303,7 +1300,7 @@ private async Task RemoveBreakpoint(SessionId msg_id, JObject args, bool isEnCRe
private async Task SetBreakpoint(SessionId sessionId, DebugStore store, BreakpointRequest req, bool sendResolvedEvent, CancellationToken token)
{
ExecutionContext context = GetContext(sessionId);
ExecutionContext context = Contexts.GetCurrentContext(sessionId);
if (req.Locations.Any())
{
Log("debug", $"locations already loaded for {req.Id}");
......@@ -1319,7 +1316,7 @@ private async Task SetBreakpoint(SessionId sessionId, DebugStore store, Breakpoi
.OrderBy(l => l.Column)
.GroupBy(l => l.Id);
logger.LogDebug("BP request for '{req}' runtime ready {context.RuntimeReady}", req, GetContext(sessionId).IsRuntimeReady);
logger.LogDebug("BP request for '{req}' runtime ready {context.RuntimeReady}", req, Contexts.GetCurrentContext(sessionId).IsRuntimeReady);
var breakpoints = new List<Breakpoint>();
......@@ -1415,7 +1412,7 @@ private async Task AttachToTarget(SessionId sessionId, CancellationToken token)
//we only need this check if it's a non-vs debugging
if (sessionId == SessionId.Null)
{
if (!contexts.TryGetValue(sessionId, out ExecutionContext context) || context.PauseOnExceptions == PauseOnExceptionsKind.Unset)
if (!Contexts.TryGetCurrentExecutionContextValue(sessionId, out ExecutionContext context) || context.PauseOnExceptions == PauseOnExceptionsKind.Unset)
{
checkUncaughtExceptions = $"throw \"{sPauseOnUncaught}\";";
checkCaughtExceptions = $"try {{throw \"{sPauseOnCaught}\";}} catch {{}}";
......
......@@ -1408,7 +1408,7 @@ public async Task<string> GetValueFromDebuggerDisplayAttribute(SessionId session
var stringId = getCAttrsRetReader.ReadInt32();
var dispAttrStr = await GetStringValue(sessionId, stringId, token);
ExecutionContext context = proxy.GetContext(sessionId);
ExecutionContext context = proxy.Contexts.GetCurrentContext(sessionId);
JArray objectValues = await GetObjectValues(sessionId, objectId, GetObjectCommandOptions.WithProperties | GetObjectCommandOptions.ForDebuggerDisplayAttribute, token);
var thisObj = CreateJObject<string>(value: "", type: "object", description: "", writable: false, objectId: $"dotnet:object:{objectId}");
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Tests GC.GetTotalPauseDuration()
using System;
using System.Diagnostics;
using System.Reflection;
public class Test_Collect
{
public static int Main()
{
Stopwatch sw = Stopwatch.StartNew();
GC.Collect();
sw.Stop();
TimeSpan elapsed = sw.Elapsed;
TimeSpan totalPauseDuration = (TimeSpan)typeof(GC).GetMethod("GetTotalPauseDuration", BindingFlags.Public | BindingFlags.Static).Invoke(null, null);
GCMemoryInfo memoryInfo = GC.GetGCMemoryInfo();
TimeSpan lastGcDuration = memoryInfo.PauseDurations[0];
// These conditions assume the only GC in the process
// is the one we just triggered. This makes the test incompatible
// with any changes that might introduce extra GCs.
if (TimeSpan.Zero < totalPauseDuration &&
totalPauseDuration <= elapsed &&
lastGcDuration == totalPauseDuration)
{
return 100;
}
else
{
return 101;
}
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<!-- Consider enable it for Mono whenever the implementation is ready -->
<CLRTestTargetUnsupported Condition="'$(RuntimeFlavor)' != 'coreclr'">true</CLRTestTargetUnsupported>
<!-- Temporaily set to P0 so that it runs on CI for initial testing -->
<CLRTestPriority>0</CLRTestPriority>
</PropertyGroup>
<PropertyGroup>
<!-- Set to 'Full' if the Debug? column is marked in the spreadsheet. Leave blank otherwise. -->
<DebugType>PdbOnly</DebugType>
</PropertyGroup>
<ItemGroup>
<Compile Include="GetTotalPauseDuration.cs" />
</ItemGroup>
</Project>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册