Exemplo n.º 1
0
        public static StringStats GetStringStats(SortedDictionary <string, KeyValuePair <uint, List <ulong> > > infoDct, string strFilePath, string dataFilePath, out string error)
        {
            error = null;
            var stats = new StringStats(infoDct);

            DumpStringsInfo(strFilePath, dataFilePath, infoDct, stats._totalCount, stats._totalSize, stats._totalUniqueSize, out error);

            return(stats);
        }
Exemplo n.º 2
0
        ///// <summary>
        ///// We are persisting string statistics (System.String) when they are asked for,
        ///// so second request might be served faster.
        ///// </summary>
        ///// <param name="runtimeIndex">Mostly we have just one runtime [0].</param>
        ///// <param name="dumpPath">Process dump file.</param>
        ///// <returns>True if we have files with string information.</returns>
        //public static bool StringStatsFilesExist(int runtimeIndex, string dumpPath)
        //{
        //	var strDatPath = DumpFileMoniker.GetRuntimeFilePath(runtimeIndex, dumpPath, Constants.MapDumpStringsInfoPostfix);
        //	if (!File.Exists(strDatPath)) return false;
        //	return true;
        //}


        public static StringStats GetStringsInfoFromFiles(int runtimeIndex, string dumpPath, out string error)
        {
            error = null;
            string[]     strings  = null;
            StringStats  strStats = null;
            BinaryReader br       = null;

            try
            {
                string dataPath = DumpFileMoniker.GetRuntimeFilePath(runtimeIndex, dumpPath, Constants.MapDumpStringsInfoPostfix);
                br = new BinaryReader(File.Open(dataPath, FileMode.Open));
                int  totalStringCount = br.ReadInt32();
                long totalStringSize  = br.ReadInt64();
                long totalUniqueSize  = br.ReadInt64();
                long strOffsetOffset  = br.ReadInt64();
                int  uniqueStrCount   = br.ReadInt32();

                uint[]    sizes      = new uint[uniqueStrCount];
                int[]     counts     = new int[uniqueStrCount];
                ulong[][] adddresses = new ulong[uniqueStrCount][];

                for (int i = 0; i < uniqueStrCount; ++i)
                {
                    int  strInstCount = br.ReadInt32();
                    uint strSize      = br.ReadUInt32();
                    counts[i]     = strInstCount;
                    sizes[i]      = strSize;
                    adddresses[i] = new ulong[strInstCount];
                    for (int j = 0; j < strInstCount; ++j)
                    {
                        adddresses[i][j] = br.ReadUInt64();
                    }
                }
                strings = new string[uniqueStrCount];
                long[] addroffs = new long[uniqueStrCount];
                for (int i = 0; i < uniqueStrCount; ++i)
                {
                    addroffs[i] = br.ReadInt64();
                    strings[i]  = br.ReadString();
                }
                br.Close();
                br = null;

                strStats = new StringStats()
                {
                    _strings         = strings,
                    _sizes           = sizes,
                    _counts          = counts,
                    _adddresses      = adddresses,
                    _totalSize       = totalStringSize,
                    _totalUniqueSize = totalUniqueSize,
                    _totalCount      = totalStringCount
                };
            }
            catch (Exception ex)
            {
                error = Utils.GetExceptionErrorString(ex);
                return(null);
            }
            finally
            {
                br?.Close();
            }

            return(strStats);
        }