List <IVirtualThread> GetThreadsFromList(IGlobalExpressionEvaluator e, string listName, UInt64?pxCurrentTCB, ref int currentThread) { List <IVirtualThread> threads = new List <IVirtualThread>(); // Find how many tasks are there in this list int?threadsInListCount = (int?)e.EvaluateIntegralExpression(listName + ".uxNumberOfItems"); // If none, abort early; also, it's possible that a given list doesn't exist -- // for instance if INCLUDE_vTaskSuspend is 0 if (!threadsInListCount.HasValue || threadsInListCount == 0) { return(threads); } // Get the first list item in that list, and the corresponding task control block UInt64 currentListItem = (UInt64)e.EvaluateIntegralExpression(listName + ".xListEnd.pxNext"); UInt64 currentTCB = (UInt64)e.EvaluateIntegralExpression(string.Format("((ListItem_t*)0x{0:x})->pvOwner", currentListItem)); for (int j = 0; j < threadsInListCount.Value; j++) { // Get stack pointer UInt64 savedSP = (UInt64)e.EvaluateIntegralExpression(string.Format("((TCB_t*)0x{0:x})->pxTopOfStack", currentTCB)); // Get task name string name = e.EvaluateRawExpression(string.Format("((TCB_t*)0x{0:x})->pcTaskName", currentTCB)); // Trim null characters (\000) and quotes from the name Regex rgx = new Regex("\\\"(.*)\\\"(.*)"); name = name.Replace("\\000", ""); name = rgx.Replace(name, "$1"); // Add this thread to the list threads.Add(new VirtualThread(CPUType, // CPU type name, // task name savedSP, // stack pointer currentThread++, // index pxCurrentTCB == currentTCB, // is currently running? (yes if equality holds) e)); // evaluator // Iterate to next list item and TCB currentListItem = (UInt64)e.EvaluateIntegralExpression(string.Format("((ListItem_t*)0x{0:x})->pxNext", currentListItem)); currentTCB = (UInt64)e.EvaluateIntegralExpression(string.Format("((ListItem_t*)0x{0:x})->pvOwner", currentListItem)); } return(threads); }