From: Grisha Kotler Date: Tue, 2 May 2023 22:49:57 +0000 (+0300) Subject: dotnet-stack: Fix parsing of thread names (#3860) X-Git-Tag: accepted/tizen/unified/riscv/20231226.055542~39^2^2~69 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f8d156b65ee81b87bd996b4b48db9e637634b3a0;p=platform%2Fcore%2Fdotnet%2Fdiagnostics.git dotnet-stack: Fix parsing of thread names (#3860) --- diff --git a/src/Tools/dotnet-stack/ReportCommand.cs b/src/Tools/dotnet-stack/ReportCommand.cs index 324c29953..76ca818ea 100644 --- a/src/Tools/dotnet-stack/ReportCommand.cs +++ b/src/Tools/dotnet-stack/ReportCommand.cs @@ -121,7 +121,11 @@ namespace Microsoft.Diagnostics.Tools.Stack // Thread id is in the frame name as "Thread ()" string template = "Thread ("; string threadFrame = stackSource.GetFrameName(stackSource.GetFrameIndex(stackIndex), false); - int threadId = int.Parse(threadFrame.Substring(template.Length, threadFrame.Length - (template.Length + 1))); + + // we are looking for the first index of ) because + // we need to handle a thread name like: Thread (4008) (.NET IO ThreadPool Worker) + int firstIndex = threadFrame.IndexOf(')'); + int threadId = int.Parse(threadFrame.AsSpan(template.Length, firstIndex - template.Length)); if (samplesForThread.TryGetValue(threadId, out List samples)) {