Ejemplo n.º 1
0
        static public bool Dump(string path, ThreadBlockGraph tbgraph, out string error)
        {
            error = null;
            BinaryWriter bw = null;

            try
            {
                bw = new BinaryWriter(File.Open(path, FileMode.Create));

                DGraph.Dump(bw, tbgraph.Graph, out error);
                bw.Write(tbgraph._graphThreadCount);
                var map = tbgraph._graphMap;
                if (map != null)
                {
                    bw.Write(map.Length);
                    for (int i = 0, icnt = map.Length; i < icnt; ++i)
                    {
                        bw.Write(map[i]);
                    }
                }
                else
                {
                    bw.Write((int)0);
                }
                var deadlock = tbgraph.Deadlock;
                if (deadlock != null && deadlock.Length > 0)
                {
                    bw.Write(deadlock.Length);
                    for (int i = 0, icnt = deadlock.Length; i < icnt; ++i)
                    {
                        var cycle = deadlock[i];
                        bw.Write(cycle.Length);
                        for (int j = 0, jcnt = cycle.Length; j < jcnt; ++j)
                        {
                            bw.Write(cycle[j]);
                        }
                    }
                }
                else
                {
                    bw.Write((int)0);
                }

                return(true);
            }
            catch (Exception ex)
            {
                error = Utils.GetExceptionErrorString(ex);
                return(false);
            }
            finally
            {
                bw?.Close();
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Just for testing.
 /// </summary>
 static public void Dump(StreamWriter sw, ThreadBlockGraph tbgraph)
 {
     sw.WriteLine("ThreadCount: " + tbgraph._graphThreadCount);
     DGraph.Dump(sw, tbgraph._graph);
     if (tbgraph._deadlock != null)
     {
         sw.WriteLine("Deadlock");
         for (int i = 0, icnt = tbgraph._deadlock.Length; i < icnt; ++i)
         {
             sw.Write(Utils.CountStringHeader(i));
             var dary = tbgraph._deadlock[i];
             for (int j = 0, jcnt = dary.Length; j < jcnt; ++j)
             {
                 sw.Write(dary[j] + " ");
             }
             sw.WriteLine();
         }
     }
     sw.WriteLine("Graph Map");
     for (int i = 0, icnt = tbgraph._graphMap.Length; i < icnt; ++i)
     {
         sw.WriteLine(Utils.CountStringHeader(i) + tbgraph._graphMap[i]);
     }
 }