Exemple #1
0
 public ClrtAppDomain(ClrAppDomain appDomain, StringIdAsyncDct dct)
 {
     Address             = appDomain.Address;
     Id                  = appDomain.Id;
     NameId              = dct.JustGetId(appDomain.Name);
     ConfigurationFileId = dct.JustGetId(appDomain.ConfigurationFile);
     ApplicationBaseId   = dct.JustGetId(appDomain.ApplicationBase);
 }
Exemple #2
0
        public void GenerateNamespaceOrdering(StringIdAsyncDct ids)
        {
            SortedDictionary <int, List <KeyValuePair <int, int> > > dct = new SortedDictionary <int, List <KeyValuePair <int, int> > >();

            string[] splitter = new[] { Constants.NamespaceSepPadded };
            int      nameId, nsId;

            for (int i = 0, icnt = ReversedNames.Length; i < icnt; ++i)
            {
                string[] items = ReversedNames[i].Split(splitter, StringSplitOptions.None);
                if (items.Length == 2)
                {
                    nameId = ids.JustGetId(items[0]);
                    nsId   = ids.JustGetId(items[1]);
                }
                else
                {
                    nameId = ids.JustGetId(items[0]);
                    nsId   = ids.JustGetId(string.Empty);
                }
                List <KeyValuePair <int, int> > lst;
                if (dct.TryGetValue(nsId, out lst))
                {
                    lst.Add(new KeyValuePair <int, int>(nameId, ReversedNamesMap[i]));
                }
                else
                {
                    dct.Add(nsId, new List <KeyValuePair <int, int> >()
                    {
                        new KeyValuePair <int, int>(nameId, ReversedNamesMap[i])
                    });
                }
            }

            KeyValuePair <int, KeyValuePair <int, int>[]>[] ns = new KeyValuePair <int, KeyValuePair <int, int>[]> [dct.Count];
            int ndx = 0;
            var cmp = new Utils.KVIntIntCmp();

            foreach (var kv in dct)
            {
                kv.Value.Sort(cmp);
                var ary = kv.Value.ToArray();
                ns[ndx++] = new KeyValuePair <int, KeyValuePair <int, int>[]>(
                    kv.Key,
                    ary
                    );
            }
            _namespaces = ns;
        }
Exemple #3
0
        // TODO JRD -- delete later
        public static ClrtRoots GetRoots(ClrHeap heap, ulong[] instances, int[] types, StringIdAsyncDct idDct)
        {
            var rootDct            = new SortedDictionary <ulong, List <ClrtRoot> >();
            var finalizeQue        = new List <ulong>(1024 * 1024);
            var finalizeQueInstIds = new List <int>(1024 * 1024);

            List <ClrRoot>  lstNotFoundObject = new List <ClrRoot>();
            List <ClrtRoot> lstRoots          = new List <ClrtRoot>(1024 * 64);

            foreach (var root in heap.EnumerateRoots())
            {
                var rootObj = root.Object;
                if (root.Kind == GCRootKind.Finalizer)
                {
                    finalizeQue.Add(rootObj);
                    var obj = Array.BinarySearch(instances, rootObj);
                    if (obj < 0)
                    {
                        obj = Constants.InvalidIndex;
                    }
                    finalizeQueInstIds.Add(obj);
                    continue;
                }
                var             rootAddr = root.Address;
                List <ClrtRoot> lst;
                if (rootDct.TryGetValue(rootAddr, out lst))
                {
                    int i     = 0;
                    int icnt  = lst.Count;
                    var rkind = root.Kind;
                    for (; i < icnt; ++i)
                    {
                        if (rootObj == lst[i].Object && rkind == ClrtRoot.GetGCRootKind(lst[i].RootKind))
                        {
                            break;
                        }
                    }
                    if (i == icnt)
                    {
                        var rname   = root.Name ?? Constants.NullName;
                        var rnameId = idDct.JustGetId(rname);
                        var obj     = Array.BinarySearch(instances, rootObj);
                        if (obj < 0)
                        {
                            lstNotFoundObject.Add(root);
                        }
                        var typeId   = obj < 0 ? Constants.InvalidIndex : types[obj];
                        var clrtRoot = new ClrtRoot(root, typeId, rnameId, Constants.InvalidIndex, Constants.InvalidThreadId, Constants.InvalidIndex);
                        lst.Add(clrtRoot);
                        lstRoots.Add(clrtRoot);
                    }
                }
                else
                {
                    var rname   = root.Name ?? Constants.NullName;
                    var rnameId = idDct.JustGetId(rname);
                    var obj     = Array.BinarySearch(instances, rootObj);
                    if (obj < 0)
                    {
                        lstNotFoundObject.Add(root);
                    }
                    var typeId   = obj < 0 ? Constants.InvalidIndex : types[obj];
                    var clrtRoot = new ClrtRoot(root, typeId, rnameId, Constants.InvalidIndex, Constants.InvalidThreadId, Constants.InvalidIndex);
                    rootDct.Add(rootAddr, new List <ClrtRoot>()
                    {
                        clrtRoot
                    });
                    lstRoots.Add(clrtRoot);
                }
            }

            var rootAry = lstRoots.ToArray();

            lstRoots.Clear();
            lstRoots = null;
            ulong[] sortedObjs;
            int[]   kindOffsets;
            int[]   objMap;
            ulong[] sortedAddrs;
            int[]   addrMap;
            SortRoots(rootAry, out kindOffsets, out sortedAddrs, out addrMap, out sortedObjs, out objMap);

            var finQueAry        = finalizeQue.ToArray();
            var finQueInstIdsAry = finalizeQueInstIds.ToArray();

            Array.Sort(finQueAry, finQueInstIdsAry);

            return(new ClrtRoots(rootAry, kindOffsets, sortedAddrs, addrMap, sortedObjs, objMap, finQueAry, finQueInstIdsAry));
        }