public ThreadNode[] RefreshThreadList() { var foundThreads = new ThreadLookup(this, _AllThreadLists, true, StateThreadListCache).DiscoverAllThreads(); int generation = Interlocked.Increment(ref _ThreadListGeneration); foreach (var thr in foundThreads) { if (!_HeapQueried) { _HeapQueried = true; _ucHeap = Engine.Symbols.LookupVariable("ucHeap"); } if (!_CachedThreadNodes.TryGetValue(thr.Key, out var threadObject)) { string threadName = ReadThreadName(thr.Key, out var pTCB); _CachedThreadNodes[thr.Key] = threadObject = new ThreadNode(Engine, pTCB, threadName, _ucHeap); } threadObject.UpdateLastSeenState(thr.Value, generation); } foreach (var kv in _CachedThreadNodes.ToArray()) { kv.Value.MarkMissingIfNeeded(generation); if (kv.Value.IsMissingForLongerThan(1000)) { _CachedThreadNodes.Remove(kv.Key); //VisualGDB will dispose the node once it realizes it's no longer reported as a child. } } return(_CachedThreadNodes.Values.OrderBy(t => t.Name, StringComparer.InvariantCultureIgnoreCase).ToArray()); }
public IsRunningNode(ThreadNode threadNode) : base(threadNode.UniqueID + ".is_running") { _ThreadNode = threadNode; Name = "Currently Running"; SelectedFormatter = _ThreadNode._Engine.GetDefaultFormatter(ScalarVariableType.UInt8); }
public StackUsageNode(ThreadNode threadNode) : base(threadNode, ".stack") { Name = "Stack Usage"; SelectedFormatter = _ThreadNode._Engine.GetDefaultFormatter(ScalarVariableType.UInt32); Capabilities |= LiveWatchCapabilities.CanSetBreakpoint | LiveWatchCapabilities.CanPlotValue; _ThreadNode._Variables.pxTopOfStackLive.SuspendUpdating = false; }
public static void RemoveThread(ThreadNode node) { if (regThreads.Contains(node)) { lock (ThreadManager._padlock) { regThreads.Remove(node); } } }
public HighestStackUsageNode(ThreadNode threadNode) : base(threadNode, ".stack_highest") { Name = "Highest Stack Usage"; _UnusedStackFillPatern = threadNode._Engine.Settings.UnusedStackFillPattern; _MaxBorderVariableSize = threadNode._Engine.Settings.StackBorderWatchSize; SelectedFormatter = _ThreadNode._Engine.GetDefaultFormatter(ScalarVariableType.UInt32); Capabilities |= LiveWatchCapabilities.CanSetBreakpoint | LiveWatchCapabilities.CanPlotValue; }
public static ThreadNode CreateThread(ThreadStart method) { ThreadNode node = new ThreadNode() { ThreadId = TotalThreads, IsRunning = ThreadManager.MasterThread.IsRunning, nodeThread = new Thread(method) }; lock (ThreadManager._padlock) { regThreads.Add(node); } return(node); }
public void Accept(ThreadNode node) { var method = new HassiumMethod(module); methodStack.Push(method); method.Parent = classStack.Peek(); if (node.Body is CodeBlockNode) { node.Body.VisitChildren(this); } else { node.Body.Visit(this); } methodStack.Pop(); emit(node.SourceLocation, InstructionType.BuildThread, method); if (node.DoImmediately) { emit(node.SourceLocation, InstructionType.StartThread); } }
/// <summary> /// Manage thread sleep /// </summary> /// <param name="time">Amount of time to put thread to sleep in milliseconds</param> /// <param name="node">Node thread to sleep</param> public static void Sleep(int time, ThreadNode node) { // Set default sleep time int sleepTime = MaxSleepTime; // Make sure it evenly divides into time while (time % sleepTime != 0) { // Check if we are getting to fast on sleep time if (--sleepTime < MinSleepTime) { sleepTime = MinSleepTime; break; } // Endif } // End where time is evenly divided by sleepTime // Time to put thread to sleep int timeSlept = 0; do { Thread.Sleep(sleepTime); timeSlept += sleepTime; } while (timeSlept < time && node.IsRunning && _masterThread.IsRunning); // Check if master thread is closing down if (!_masterThread.IsRunning) { // Try and shut down all threads foreach (ThreadNode n in regThreads) { // Set all threads running state to closed n.IsRunning = false; } } // Endif masterThread is not running } // End method sleep
/// <summary> /// Function to be called from a TweenNode to add itself to this module dictionary. /// </summary> public void AddNode(ThreadNode p_node) { _listOfNodes.Add(p_node); }
protected StackUsageNodeBase(ThreadNode thread, string idSuffix) : base(thread.UniqueID + idSuffix) { _ThreadNode = thread; }