Exemple #1
0
        public void LoadGraph(SEGraph graph)
        {
            if (graph == null)
            {
                Graph = new SEGraph();
            }
            else
            {
                foreach (var e in Graph.Edges.ToList())
                {
                    Graph.RemoveEdge(e);
                }
                foreach (var e in Graph.HiddenEdges.ToList())
                {
                    ((List <SEEdge>)Graph.HiddenEdges).Remove(e);
                }
                foreach (var v in Graph.Vertices.ToList())
                {
                    Graph.RemoveVertex(v);
                }
                foreach (var v in Graph.HiddenVertices.ToList())
                {
                    ((List <SENode>)Graph.HiddenVertices).Remove(v);
                }

                foreach (var v in graph.Vertices)
                {
                    Graph.AddVertex(v);
                }
                foreach (var e in graph.Edges)
                {
                    Graph.AddEdge(e);
                }
            }
        }
Exemple #2
0
 public void Initialize(IPexExplorationEngine host)
 {
     Graph                    = new SEGraph();
     Vertices                 = new Dictionary <int, SENode>();
     Edges                    = new Dictionary <int, Dictionary <int, SEEdge> >();
     EmittedTestResult        = new Dictionary <int, Tuple <bool, string> >();
     Z3CallLocations          = new List <string>();
     PrettyPathConditionTasks = new Dictionary <int, Task <string> >();
     ParentNodes              = new Dictionary <int, int>();
 }
Exemple #3
0
        private void LoadGraphFromTemp()
        {
            var result = MessageBox.Show("New SEViz graph is available. Do you want to load it?", "SEViz notification", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                var dialogFactory = ViewerWindowCommand.Instance.ServiceProvider.GetService(typeof(SVsThreadedWaitDialogFactory)) as IVsThreadedWaitDialogFactory;

                IVsThreadedWaitDialog2 dialog = null;
                if (dialogFactory != null)
                {
                    dialogFactory.CreateInstance(out dialog);
                }
                if (dialog != null)
                {
                    bw = new BackgroundWorker();
                    bw.WorkerSupportsCancellation = true;
                    bw.DoWork += (p1, p2) =>
                    {
                        dialog.StartWaitDialog("SEViz", "SEViz is loading", "Please wait while SEViz loads the graph...", null, "Waiting status bar text", 0, false, true);
                        while (true)
                        {
                            if (!bw.CancellationPending)
                            {
                                Thread.Sleep(500);
                            }
                            else
                            {
                                break;
                            }
                        }
                    };
                    bw.RunWorkerCompleted += (p1, p2) =>
                    {
                        int isCanceled = -1;
                        dialog.EndWaitDialog(out isCanceled);
                    };
                    bw.RunWorkerAsync();

                    // Loading the graph
                    LoadGraph(SEGraph.Deserialize(Path.GetTempPath() + "SEViz/" + "temp.graphml"));

                    // Setting the caption of the tool window
                    ViewerWindowCommand.Instance.FindToolWindow().Caption = Graph.Vertices.Where(v => !v.SourceCodeMappingString.Equals("")).FirstOrDefault().MethodName + " - SEViz";

                    // Showing the tool window
                    ViewerWindowCommand.Instance.ShowToolWindow(null, null);
                }
            }

            fsw.EnableRaisingEvents = true;
        }
Exemple #4
0
        public void AfterExploration(IPexExplorationComponent host, object data)
        {
            foreach (var vertex in Vertices.Values)
            {
                // Modifying shape based on Z3 calls
                if (Z3CallLocations.Contains(vertex.MethodName + ":" + vertex.ILOffset))
                {
                    vertex.Shape = SENode.NodeShape.Ellipse;
                }

                // Adding the path condition
                var t = PrettyPathConditionTasks[vertex.Id];
                t.Wait();
                vertex.PathCondition = t.Result;
            }

            foreach (var vertex in Vertices.Values)
            {
                // Adding the incremental path condition
                if (ParentNodes.ContainsKey(vertex.Id))
                {
                    vertex.IncrementalPathCondition = CalculateIncrementalPathCondition(vertex.PathCondition, Vertices[ParentNodes[vertex.Id]].PathCondition);
                }
                else
                {
                    // If the node is the first one (has no parents), then the incremental equals the full PC
                    vertex.IncrementalPathCondition = vertex.PathCondition;
                }
            }

            // Adding vertices and edges to the graph
            Graph.AddVertexRange(Vertices.Values);
            foreach (var edgeDictionary in Edges.Values)
            {
                Graph.AddEdgeRange(edgeDictionary.Values);
            }

            // Checking if temporary SEViz folder exists
            if (!Directory.Exists(Path.GetTempPath() + "SEViz"))
            {
                var dir = Directory.CreateDirectory(Path.GetTempPath() + "SEViz");
            }

            // Getting the temporary folder
            var tempDir = Path.GetTempPath() + "SEViz\\";

            // Serializing the graph into graphml
            SEGraph.Serialize(Graph, tempDir);
        }
Exemple #5
0
        public void LoadGraphFromUri(string fileUri)
        {
            // Loading the graph
            LoadGraph(SEGraph.Deserialize(fileUri));

            // Setting the caption of the tool window (making sure with the loop that the node has a method)
            for (int i = 0; i < 10; i++)
            {
                var methodName = Graph.Vertices.Where(v => v.Id == i).FirstOrDefault().MethodName;
                if (methodName != "")
                {
                    ViewerWindowCommand.Instance.FindToolWindow().Caption = methodName + " - SEViz";
                    break;
                }
            }
        }