using System; using System.Collections; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; using System.Threading; namespace System.Diagnostics { /// Represents a stack trace, which is an ordered collection of one or more stack frames. /// 2 // Token: 0x02000166 RID: 358 [MonoTODO("Serialized objects are not compatible with .NET")] [ComVisible(true)] [Serializable] public class StackTrace { /// Initializes a new instance of the class from the caller's frame. // Token: 0x06001169 RID: 4457 RVA: 0x00045658 File Offset: 0x00043858 public StackTrace() { this.init_frames(0, false); } /// Initializes a new instance of the class from the caller's frame, optionally capturing source information. /// true to capture the file name, line number, and column number; otherwise, false. // Token: 0x0600116A RID: 4458 RVA: 0x00045668 File Offset: 0x00043868 public StackTrace(bool fNeedFileInfo) { this.init_frames(0, fNeedFileInfo); } /// Initializes a new instance of the class from the caller's frame, skipping the specified number of frames. /// The number of frames up the stack from which to start the trace. /// The parameter is negative. // Token: 0x0600116B RID: 4459 RVA: 0x00045678 File Offset: 0x00043878 public StackTrace(int skipFrames) { this.init_frames(skipFrames, false); } /// Initializes a new instance of the class from the caller's frame, skipping the specified number of frames and optionally capturing source information. /// The number of frames up the stack from which to start the trace. /// true to capture the file name, line number, and column number; otherwise, false. /// The parameter is negative. // Token: 0x0600116C RID: 4460 RVA: 0x00045688 File Offset: 0x00043888 public StackTrace(int skipFrames, bool fNeedFileInfo) { this.init_frames(skipFrames, fNeedFileInfo); } /// Initializes a new instance of the class using the provided exception object. /// The exception object from which to construct the stack trace. /// The parameter is null. // Token: 0x0600116D RID: 4461 RVA: 0x00045698 File Offset: 0x00043898 public StackTrace(Exception e) : this(e, 0, false) { } /// Initializes a new instance of the class, using the provided exception object and optionally capturing source information. /// The exception object from which to construct the stack trace. /// true to capture the file name, line number, and column number; otherwise, false. /// The parameter is null. // Token: 0x0600116E RID: 4462 RVA: 0x000456A4 File Offset: 0x000438A4 public StackTrace(Exception e, bool fNeedFileInfo) : this(e, 0, fNeedFileInfo) { } /// Initializes a new instance of the class using the provided exception object and skipping the specified number of frames. /// The exception object from which to construct the stack trace. /// The number of frames up the stack from which to start the trace. /// The parameter is null. /// The parameter is negative. // Token: 0x0600116F RID: 4463 RVA: 0x000456B0 File Offset: 0x000438B0 public StackTrace(Exception e, int skipFrames) : this(e, skipFrames, false) { } /// Initializes a new instance of the class using the provided exception object, skipping the specified number of frames and optionally capturing source information. /// The exception object from which to construct the stack trace. /// The number of frames up the stack from which to start the trace. /// true to capture the file name, line number, and column number; otherwise, false. /// The parameter is null. /// The parameter is negative. // Token: 0x06001170 RID: 4464 RVA: 0x000456BC File Offset: 0x000438BC public StackTrace(Exception e, int skipFrames, bool fNeedFileInfo) : this(e, skipFrames, fNeedFileInfo, false) { } // Token: 0x06001171 RID: 4465 RVA: 0x000456C8 File Offset: 0x000438C8 internal StackTrace(Exception e, int skipFrames, bool fNeedFileInfo, bool returnNativeFrames) { if (e == null) { throw new ArgumentNullException("e"); } if (skipFrames < 0) { throw new ArgumentOutOfRangeException("< 0", "skipFrames"); } this.frames = StackTrace.get_trace(e, skipFrames, fNeedFileInfo); if (!returnNativeFrames) { bool flag = false; for (int i = 0; i < this.frames.Length; i++) { if (this.frames[i].GetMethod() == null) { flag = true; } } if (flag) { ArrayList arrayList = new ArrayList(); for (int j = 0; j < this.frames.Length; j++) { if (this.frames[j].GetMethod() != null) { arrayList.Add(this.frames[j]); } } this.frames = (StackFrame[])arrayList.ToArray(typeof(StackFrame)); } } } /// Initializes a new instance of the class that contains a single frame. /// The frame that the object should contain. // Token: 0x06001172 RID: 4466 RVA: 0x000457A8 File Offset: 0x000439A8 public StackTrace(StackFrame frame) { this.frames = new StackFrame[1]; this.frames[0] = frame; } /// Initializes a new instance of the class for a specific thread, optionally capturing source information. /// The thread whose stack trace is requested. /// true to capture the file name, line number, and column number; otherwise, false. /// The thread is not suspended. // Token: 0x06001173 RID: 4467 RVA: 0x000457C8 File Offset: 0x000439C8 [MonoTODO("Not possible to create StackTraces from other threads")] public StackTrace(Thread targetThread, bool needFileInfo) { throw new NotImplementedException(); } // Token: 0x06001174 RID: 4468 RVA: 0x000457D8 File Offset: 0x000439D8 private void init_frames(int skipFrames, bool fNeedFileInfo) { if (skipFrames < 0) { throw new ArgumentOutOfRangeException("< 0", "skipFrames"); } ArrayList arrayList = new ArrayList(); skipFrames += 2; StackFrame stackFrame; while ((stackFrame = new StackFrame(skipFrames, fNeedFileInfo)) != null && stackFrame.GetMethod() != null) { arrayList.Add(stackFrame); skipFrames++; } this.debug_info = fNeedFileInfo; this.frames = (StackFrame[])arrayList.ToArray(typeof(StackFrame)); } // Token: 0x06001175 RID: 4469 [MethodImpl(MethodImplOptions.InternalCall)] private static extern StackFrame[] get_trace(Exception e, int skipFrames, bool fNeedFileInfo); /// Gets the number of frames in the stack trace. /// The number of frames in the stack trace. /// 2 // Token: 0x170002FA RID: 762 // (get) Token: 0x06001176 RID: 4470 RVA: 0x00045854 File Offset: 0x00043A54 public virtual int FrameCount { get { return (this.frames != null) ? this.frames.Length : 0; } } /// Gets the specified stack frame. /// The specified stack frame. /// The index of the stack frame requested. /// 2 // Token: 0x06001177 RID: 4471 RVA: 0x00045870 File Offset: 0x00043A70 public virtual StackFrame GetFrame(int index) { if (index < 0 || index >= this.FrameCount) { return null; } return this.frames[index]; } /// Returns a copy of all stack frames in the current stack trace. /// An array of type representing the function calls in the stack trace. /// 2 // Token: 0x06001178 RID: 4472 RVA: 0x00045890 File Offset: 0x00043A90 [ComVisible(false)] public virtual StackFrame[] GetFrames() { return this.frames; } /// Builds a readable representation of the stack trace. /// A readable representation of the stack trace. /// 2 // Token: 0x06001179 RID: 4473 RVA: 0x00045898 File Offset: 0x00043A98 public override string ToString() { string text = string.Format("{0} {1} ", Environment.NewLine, Locale.GetText("at")); string text2 = Locale.GetText(""); string text3 = Locale.GetText(" in {0}:line {1}"); StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < this.FrameCount; i++) { StackFrame frame = this.GetFrame(i); if (i > 0) { stringBuilder.Append(text); } else { stringBuilder.AppendFormat(" {0} ", Locale.GetText("at")); } MethodBase method = frame.GetMethod(); if (method != null) { stringBuilder.AppendFormat("{0}.{1}", method.DeclaringType.FullName, method.Name); stringBuilder.Append("("); ParameterInfo[] parameters = method.GetParameters(); for (int j = 0; j < parameters.Length; j++) { if (j > 0) { stringBuilder.Append(", "); } Type type = parameters[j].ParameterType; bool isByRef = type.IsByRef; if (isByRef) { type = type.GetElementType(); } if (type.IsClass && type.Namespace != string.Empty) { stringBuilder.Append(type.Namespace); stringBuilder.Append("."); } stringBuilder.Append(type.Name); if (isByRef) { stringBuilder.Append(" ByRef"); } stringBuilder.AppendFormat(" {0}", parameters[j].Name); } stringBuilder.Append(")"); } else { stringBuilder.Append(text2); } if (this.debug_info) { string secureFileName = frame.GetSecureFileName(); if (secureFileName != "") { stringBuilder.AppendFormat(text3, secureFileName, frame.GetFileLineNumber()); } } } return stringBuilder.ToString(); } /// Defines the default for the number of methods to omit from the stack trace. This field is constant. /// 1 // Token: 0x0400045C RID: 1116 public const int METHODS_TO_SKIP = 0; // Token: 0x0400045D RID: 1117 private StackFrame[] frames; // Token: 0x0400045E RID: 1118 private bool debug_info; } }