Example #1
0
        public void CreateStackItem(int nodeID, FunctionCall call, long startTick, bool isMethod, bool ThreadlineEnabled)
        {
            Pos++;

            Handle = Thread.CurrentThread; // not sure if id can stay the same while handle object changes if thread id resurrected

            if (Pos >= XRay.MaxStack)
                return;

            var newItem = new StackItem()
            {
                NodeID = nodeID,
                Call = call,
                StartTick = startTick,
                Depth = Pos
            };

            if (isMethod)
                Stack[Pos] = newItem;
            else
            {
                newItem.EndTick = startTick;
                Pos--;
            }

            if (!ThreadlineEnabled)
                return;

            AddStackItem(newItem);
        }
Example #2
0
        public void AddStackItem(StackItem newItem)
        {
            ThreadlinePos++;
            if (ThreadlinePos >= Threadline.Length)
                ThreadlinePos = 0;

            Threadline[ThreadlinePos] = newItem;

            if (XRay.Remote != null && !XRay.RemoteViewer)
                foreach (var client in XRay.Remote.SyncClients)
                    if (client.NewStackItems.ContainsKey(ThreadID))
                        client.NewStackItems[ThreadID]++;
                    else
                        client.NewStackItems[ThreadID] = 0;
        }
        private bool AddToTimeline(ThreadFlow flow, StackItem item)
        {
            // do stuff with item
            Threadline timeline;
            if (!Threadlines.TryGetValue(flow.ThreadID, out timeline))
            {
                timeline = new Threadline(flow, ThreadOrder++);
                Threadlines[flow.ThreadID] = timeline;
            }

            timeline.IsAlive = flow.IsAlive; // update

            var node = NodeModels[item.NodeID];

            if (node.Show &&
                (CenterMap.Contains(node.ID) ||
                 (ShowOutside && !node.XNode.External) ||
                 (ShowExternal && node.XNode.External)))
            {
                timeline.Sequence.Add(item);

                if (item.Depth > timeline.Deepest)
                    timeline.Deepest = item.Depth;

                timeline.DepthSet.Add(item.Depth);

                return true;
            }
            else
                return false;
        }
Example #4
0
        private static StackItem GetStackItem(Tuple<int, int> itemPos)
        {
            int id = itemPos.Item1;
            int pos = itemPos.Item2;

            FunctionCall call = null;
            int nodeID = 0;

            if (pos == 0)
            {
                nodeID = id;
            }
            else
            {
                if (!CallMap.TryGetValue(id, out call))
                    Debug.Assert(false, "Thread call not found on sync");

                nodeID = call.Destination;
            }

            var newItem = new StackItem()
            {
                NodeID = nodeID,
                Call = call,
                StartTick = XRay.Watch.ElapsedTicks,
                Depth = pos
            };
            return newItem;
        }
Example #5
0
        public void AddStackItem(int nodeID, FunctionCall call, long startTick, bool isMethod, bool ThreadlineEnabled)
        {
            Pos++;

            Handle = Thread.CurrentThread;

            if (Pos >= XRay.MaxStack)
                return;

            var newItem = new StackItem()
            {
                NodeID = nodeID,
                Call = call,
                StartTick = startTick,
                Depth = Pos
            };

            if (isMethod)
                Stack[Pos] = newItem;
            else
            {
                newItem.EndTick = startTick;
                Pos--;
            }

            if (!ThreadlineEnabled)
                return;

            // dont over write items in timeline that haven't ended yet
            while (true)
            {
                ThreadlinePos++;
                if (ThreadlinePos >= Threadline.Length)
                    ThreadlinePos = 0;

                var overwrite = Threadline[ThreadlinePos];

                if (overwrite == null || overwrite.EndTick != 0)
                {
                    Threadline[ThreadlinePos] = newItem;
                    break;
                }
            }
        }