Пример #1
0
        private void FindSinglePathImpl(GCRoot gcroot)
        {
            ClrHeap heap = gcroot.Heap;

            GetKnownSourceAndTarget(heap, out ulong source, out ulong target);

            LinkedList <ClrObject> path = gcroot.FindSinglePath(source, target, CancellationToken.None);

            AssertPathIsCorrect(heap, path.ToImmutableArray(), source, target);
        }
Пример #2
0
        public void FindSinglePath()
        {
            using DataTarget dataTarget = TestTargets.GCRoot.LoadFullDump();
            using ClrRuntime runtime    = dataTarget.ClrVersions.Single().CreateRuntime();
            ClrHeap heap   = runtime.Heap;
            GCRoot  gcroot = new GCRoot(heap);

            GetKnownSourceAndTarget(heap, out ulong source, out ulong target);

            LinkedList <ClrObject> path = gcroot.FindSinglePath(source, target, CancellationToken.None);

            AssertPathIsCorrect(heap, path.ToImmutableArray(), source, target);
        }
Пример #3
0
        public void FindSinglePathCancel()
        {
            using DataTarget dataTarget = TestTargets.GCRoot.LoadFullDump();
            using ClrRuntime runtime    = dataTarget.ClrVersions.Single().CreateRuntime();
            ClrHeap heap   = runtime.Heap;
            GCRoot  gcroot = new GCRoot(heap);

            CancellationTokenSource cancelSource = new CancellationTokenSource();

            cancelSource.Cancel();

            GetKnownSourceAndTarget(runtime.Heap, out ulong source, out ulong target);
            Assert.Throws <OperationCanceledException>(() => gcroot.FindSinglePath(source, target, cancelSource.Token));
        }
Пример #4
0
        public void FindSinglePathCancel()
        {
            using DataTarget dataTarget = TestTargets.GCRoot.LoadFullDump();
            using ClrRuntime runtime    = dataTarget.ClrVersions.Single().CreateRuntime();
            ClrHeap heap   = runtime.Heap;
            GCRoot  gcroot = new GCRoot(runtime.Heap);

            CancellationTokenSource cancelSource = new CancellationTokenSource();

            cancelSource.Cancel();

            GetKnownSourceAndTarget(runtime.Heap, out ulong source, out ulong target);
            try
            {
                gcroot.FindSinglePath(source, target, cancelSource.Token);
                Assert.True(false, "Should have been cancelled!");
            }
            catch (OperationCanceledException)
            {
            }
        }
Пример #5
0
 /// <summary>
 ///     Returns the path from the start object to the end object (or null if no such path exists).
 /// </summary>
 /// <param name="source">The initial object to start the search from.</param>
 /// <param name="target">The object we are searching for.</param>
 /// <param name="cancelToken">A cancellation token to stop searching.</param>
 /// <returns>A path from 'source' to 'target' if one exists, null if one does not.</returns>
 /// <inheritdoc />
 public IList <IClrObject> FindSinglePath(ulong source, ulong target, CancellationToken cancelToken) =>
 Root.FindSinglePath(source, target, cancelToken).Select(Converter.Convert).ToList();