Inheritance: GcHeapXmlReader
コード例 #1
0
ファイル: GcTypeHeap.cs プロジェクト: barsgroup/QuickGraph
        /// <summary>
        /// Loads the specified heap XML file name.
        /// </summary>
        /// <param name="heapXmlFileName">Name of the heap XML file.</param>
        /// <param name="dumpFileName">Name of the dump file.</param>
        /// <returns></returns>
        public static GcTypeHeap Load(string heapXmlFileName, string eeHeapFileName)
        {
            if (String.IsNullOrEmpty(heapXmlFileName))
            {
                throw new ArgumentNullException("heapXmlFileName");
            }
            if (!File.Exists(heapXmlFileName))
            {
                throw new FileNotFoundException("could not find heap file", heapXmlFileName);
            }

            int retryCount = 0;

retry:
            if (retryCount > 1)
            {
                throw new Exception("failed to load gcheap");
            }

            GcTypeGraphReader greader = new GcTypeGraphReader();

            if (!String.IsNullOrEmpty(eeHeapFileName))
            {
                Console.WriteLine("loading {0}", eeHeapFileName);
                if (!File.Exists(eeHeapFileName))
                {
                    throw new FileNotFoundException("could not find eeheap file", eeHeapFileName);
                }
                // parse gc heap structure
                greader.ParseEEHeap(File.ReadAllText(eeHeapFileName));
            }

            Console.WriteLine("loading {0}", heapXmlFileName);
            try
            {
                using (XmlReader reader = XmlReader.Create(heapXmlFileName))
                    greader.Read(reader);
            }
            catch (XmlException)
            {
                Console.WriteLine("fixing up xml file (incorrect xml with generics)");
                // fix the xml and save back to disk.
                File.WriteAllText(
                    heapXmlFileName,
                    regex.Replace(
                        File.ReadAllText(heapXmlFileName),
                        EscapeXmlAttribute)
                    );
                // try again
                retryCount++;
                goto retry;
            }

            var heap = new GcTypeHeap(greader.Graph).RemoveDefault();;

            Console.WriteLine("heap: {0}", heap);
            return(heap);
        }
コード例 #2
0
ファイル: GcTypeHeap.cs プロジェクト: eosfor/quickgraph-peli
        /// <summary>
        /// Loads the specified heap XML file name.
        /// </summary>
        /// <param name="heapXmlFileName">Name of the heap XML file.</param>
        /// <param name="dumpFileName">Name of the dump file.</param>
        /// <returns></returns>
        public static GcTypeHeap Load(string heapXmlFileName, string dumpFileName)
        {
            if (String.IsNullOrEmpty(heapXmlFileName))
            {
                throw new ArgumentNullException("heapXmlFileName");
            }
            if (!File.Exists(heapXmlFileName))
            {
                throw new FileNotFoundException("could not find heap file", heapXmlFileName);
            }

            Console.WriteLine("loading {0}", heapXmlFileName);
            GcTypeGraphReader greader = new GcTypeGraphReader();

            try
            {
                using (XmlReader reader = XmlReader.Create(heapXmlFileName))
                    greader.Read(reader);
            }
            catch (XmlException)
            {
                Console.WriteLine("fixing up xml file (incorrect xml with generics)");
                // fix the xml and save back to disk.
                File.WriteAllText(
                    heapXmlFileName,
                    regex.Replace(
                        File.ReadAllText(heapXmlFileName),
                        EscapeXmlAttribute)
                    );
                // try again
                greader = new GcTypeGraphReader();
                using (XmlReader reader = XmlReader.Create(heapXmlFileName))
                    greader.Read(reader);
            }

            if (!String.IsNullOrEmpty(dumpFileName))
            {
                if (!File.Exists(dumpFileName))
                {
                    throw new FileNotFoundException("could not find dump file", dumpFileName);
                }
                using (StreamReader reader = new StreamReader(File.OpenRead(dumpFileName)))
                    greader.ParseDump(reader);
            }

            GcTypeHeap heap = new GcTypeHeap(greader.Graph).RemoveDefault();;

            Console.WriteLine("heap: {0}", heap);
            return(heap);
        }
コード例 #3
0
ファイル: GcTypeHeap.cs プロジェクト: buptkang/QuickGraph
        /// <summary>
        /// Loads the specified heap XML file name.
        /// </summary>
        /// <param name="heapXmlFileName">Name of the heap XML file.</param>
        /// <param name="dumpFileName">Name of the dump file.</param>
        /// <returns></returns>
        public static GcTypeHeap Load(string heapXmlFileName, string dumpFileName)
        {
            if (String.IsNullOrEmpty(heapXmlFileName))
                throw new ArgumentNullException("heapXmlFileName");
            if (!File.Exists(heapXmlFileName))
                throw new FileNotFoundException("could not find heap file", heapXmlFileName);

            Console.WriteLine("loading {0}", heapXmlFileName);
            GcTypeGraphReader greader = new GcTypeGraphReader();

            try
            {
                using (XmlReader reader = XmlReader.Create(heapXmlFileName))
                    greader.Read(reader);
            }
            catch (XmlException)
            {
                Console.WriteLine("fixing up xml file (incorrect xml with generics)");
                // fix the xml and save back to disk.
                File.WriteAllText(
                    heapXmlFileName,
                    regex.Replace(
                        File.ReadAllText(heapXmlFileName),
                        EscapeXmlAttribute)
                    );
                // try again
                greader = new GcTypeGraphReader();
                using (XmlReader reader = XmlReader.Create(heapXmlFileName))
                    greader.Read(reader);
            }

            if (!String.IsNullOrEmpty(dumpFileName))
            {
                if (!File.Exists(dumpFileName))
                    throw new FileNotFoundException("could not find dump file", dumpFileName);
                using (StreamReader reader = new StreamReader(File.OpenRead(dumpFileName)))
                    greader.ParseDump(reader);
            }

            GcTypeHeap heap = new GcTypeHeap(greader.Graph).RemoveDefault(); ;
            Console.WriteLine("heap: {0}", heap);
            return heap;
        }
コード例 #4
0
ファイル: GcTypeHeap.cs プロジェクト: buptkang/QuickGraph
        /// <summary>
        /// Loads the specified heap XML file name.
        /// </summary>
        /// <param name="heapXmlFileName">Name of the heap XML file.</param>
        /// <param name="dumpFileName">Name of the dump file.</param>
        /// <returns></returns>
        public static GcTypeHeap Load(string heapXmlFileName, string eeHeapFileName)
        {
            if (String.IsNullOrEmpty(heapXmlFileName))
                throw new ArgumentNullException("heapXmlFileName");
            if (!File.Exists(heapXmlFileName))
                throw new FileNotFoundException("could not find heap file", heapXmlFileName);

            int retryCount = 0;
retry:
            if (retryCount > 1)
                throw new Exception("failed to load gcheap");
            
            GcTypeGraphReader greader = new GcTypeGraphReader();
            if (!String.IsNullOrEmpty(eeHeapFileName))
            {
                Console.WriteLine("loading {0}", eeHeapFileName);
                if (!File.Exists(eeHeapFileName))
                    throw new FileNotFoundException("could not find eeheap file", eeHeapFileName);
                // parse gc heap structure
                greader.ParseEEHeap(File.ReadAllText(eeHeapFileName));
            }

            Console.WriteLine("loading {0}", heapXmlFileName);
            try
            {
                using (XmlReader reader = XmlReader.Create(heapXmlFileName))
                    greader.Read(reader);
            }
            catch (XmlException)
            {
                Console.WriteLine("fixing up xml file (incorrect xml with generics)");
                // fix the xml and save back to disk.
                File.WriteAllText(
                    heapXmlFileName,
                    regex.Replace(
                        File.ReadAllText(heapXmlFileName),
                        EscapeXmlAttribute)
                    );
                // try again
                retryCount++;
                goto retry;
            }

            var heap = new GcTypeHeap(greader.Graph).RemoveDefault(); ;
            Console.WriteLine("heap: {0}", heap);
            return heap;
        }