Ejemplo n.º 1
0
        private StackTraceElement GetStackTraceElement(ClrStackFrame frame)
        {
            if (frame == null || frame.Method == null)
            {
                return(null);
            }

            FileAndLineNumber info   = GetSourceLocation(frame);
            StackTraceElement result = new StackTraceElement()
            {
                MethodName     = frame.Method.Name,
                IsNativeMethod = frame.Method.IsInternal || frame.Method.IsPInvoke,
                LineNumber     = info.Line,
                FileName       = info.File,
                ClassName      = frame.Method.Type != null ? frame.Method.Type.Name : "Unknown"
            };

            return(result);
        }
Ejemplo n.º 2
0
        private List <StackTraceElement> GetStackTrace(ClrThread thread)
        {
            List <StackTraceElement> result = new List <StackTraceElement>();

            _logger?.LogTrace("Starting stack dump for thread");

            if (thread.IsAlive)
            {
                var stackTrace = thread.StackTrace;
                if (stackTrace != null)
                {
                    foreach (ClrStackFrame frame in stackTrace)
                    {
                        StackTraceElement element = GetStackTraceElement(frame);
                        if (element != null)
                        {
                            result.Add(element);
                        }
                    }
                }
            }

            return(result);
        }