public static bool Write(SafeHandle fileHandle, Option options, ExceptionInfo exceptionInfo = ExceptionInfo.None) { Process currentProcess = Process.GetCurrentProcess(); IntPtr currentProcessHandle = currentProcess.Handle; var currentProcessId = (uint)currentProcess.Id; MiniDumpExceptionInformation exp; exp.ThreadId = GetCurrentThreadId(); exp.ClientPointers = false; exp.ExceptionPointers = IntPtr.Zero; if (exceptionInfo == ExceptionInfo.Present) { exp.ExceptionPointers = Marshal.GetExceptionPointers(); } var result = false; if (exp.ExceptionPointers == IntPtr.Zero) { result = MiniDumpWriteDump(currentProcessHandle, currentProcessId, fileHandle, (uint)options, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); } else { result = MiniDumpWriteDump(currentProcessHandle, currentProcessId, fileHandle, (uint)options, ref exp, IntPtr.Zero, IntPtr.Zero); } return result; }
private static XElement FormatExceptionInfoElement(ExceptionInfo exceptionInfo) { if (exceptionInfo == null) return null; return FormatExceptionInfoElement(exceptionInfo, false); }
internal static void FormatException(ExceptionInfo exceptionInfo, StringBuilder builder) { if (exceptionInfo == null) { return; } if (builder.Length > 0) { builder.AppendLine("--------------------------------"); } builder.AppendFormat("{0}: {1}", FormatValue(exceptionInfo.GetType().ToString()), FormatValue(exceptionInfo.Message)); builder.AppendLine(); //if (!String.IsNullOrEmpty(exceptionInfo.Source)) //{ // builder.AppendFormat(" Source: {0}", FormatValue(exceptionInfo.Source)); // builder.AppendLine(); //} if (!String.IsNullOrEmpty(exceptionInfo.StackTrace)) { builder.AppendFormat(" Stack: {0}", FormatValue(exceptionInfo.StackTrace)); builder.AppendLine(); } if (exceptionInfo.InnerException != null) { FormatException(exceptionInfo.InnerException, builder); } }
/// <summary> /// Writes dump file with the specified options and exception info. /// </summary> /// <param name="options">The options.</param> /// <param name="exceptionInfo">The exception information.</param> /// <returns></returns> public static bool Write(Option options, ExceptionInfo exceptionInfo) { Process currentProcess = Process.GetCurrentProcess(); IntPtr currentProcessHandle = currentProcess.Handle; uint currentProcessId = (uint) currentProcess.Id; MiniDumpExceptionInformation exp; exp.ThreadId = GetCurrentThreadId(); exp.ClientPointers = false; exp.ExceptionPointers = IntPtr.Zero; if (exceptionInfo == ExceptionInfo.Present) { exp.ExceptionPointers = System.Runtime.InteropServices.Marshal.GetExceptionPointers(); } bool bRet = false; using (var fs = new FileStream(GenerateDumpFilename(), FileMode.Create, FileAccess.ReadWrite, FileShare.Write)) { if (exp.ExceptionPointers == IntPtr.Zero) { bRet = MiniDumpWriteDump(currentProcessHandle, currentProcessId, fs.SafeFileHandle, (uint) options, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); } else { bRet = MiniDumpWriteDump(currentProcessHandle, currentProcessId, fs.SafeFileHandle, (uint) options, ref exp, IntPtr.Zero, IntPtr.Zero); } } return bRet; }
public ExceptionInfo[] GetExceptionInfos() { if (_exceptionInfo == null) { ILGenerator ilgen = _method.GetILGenerator(); var n = (int)s_fiExceptionCount.GetValue(ilgen); if (n > 0) { var exceptions = (Array)s_fiExceptions.GetValue(ilgen); _exceptionInfo = new ExceptionInfo[n]; for (var i = 0; i < n; i++) { _exceptionInfo[i] = new ExceptionInfo(exceptions.GetValue(i)); } } else { _exceptionInfo = Array.Empty<ExceptionInfo>(); } } return _exceptionInfo; }
public ExceptionInfo(Exception ex) { Source = ex.Source; StackTrace = ex.StackTrace; if (ex.TargetSite != null) TargetSite = ex.TargetSite.Name; HelpLink = ex.HelpLink; if (ex.InnerException != null) InnerException = new ExceptionInfo(ex.InnerException); }
public ExceptionInfo(Exception ex) { Message = ex.Message; HResult = ex.HResult; Type = ex.GetType().FullName; Source = ex.Source; StackTrace = ex.StackTrace; if (ex.InnerException != null) InnerException = new ExceptionInfo(ex.InnerException); }
public BugInfo(Exception ex) { Subject = ex.Message; var exceptionInfo = new ExceptionInfo(ex); string json = JSON.FromObject(exceptionInfo); Message = json; Timestamp = DateTime.UtcNow; }
public ExceptionInfoDocument(ExceptionInfo exceptionInfo) { ExceptionType = exceptionInfo.ExceptionType; Message = exceptionInfo.Message; Source = exceptionInfo.Source; StackTrace = exceptionInfo.StackTrace; if (exceptionInfo.InnerException != null) InnerException = new ExceptionInfoDocument(exceptionInfo.InnerException); }
public ActivityExceptionImpl(string activityName, HostInfo host, Guid executionId, DateTime timestamp, TimeSpan elapsed, ExceptionInfo exceptionInfo) { ExecutionId = executionId; Timestamp = timestamp; Elapsed = elapsed; Name = activityName; Host = host; ExceptionInfo = exceptionInfo; }
public RoutingSlipActivityFaultedMessage(HostInfo host, Guid trackingNumber, string activityName, Guid activityTrackingNumber, DateTime timestamp, TimeSpan duration, ExceptionInfo exceptionInfo, IDictionary<string, object> variables, IDictionary<string, object> arguments) { Host = host; TrackingNumber = trackingNumber; Timestamp = timestamp; Duration = duration; ActivityTrackingNumber = activityTrackingNumber; ActivityName = activityName; Variables = variables; Arguments = arguments; ExceptionInfo = exceptionInfo; }
private static XElement FormatExceptionInfoElement(ExceptionInfo exceptionInfo, bool isInnerException) { if (exceptionInfo == null) return null; string elementName = "exceptionInfo"; if (isInnerException) elementName = "innerExceptionInfo"; return new XElement(elementName , new XElement("message", exceptionInfo.Message) , new XElement("stackTrace", exceptionInfo.StackTrace) , FormatExceptionInfoElement(exceptionInfo.InnerException, true) ); }
protected override void Before_all_tests() { base.Before_all_tests(); try { throw new Exception("Hello"); } catch (Exception ex2) { exception = ex2; } beforeExceptionInfo = new ExceptionInfo(exception); afterExceptionInfo = beforeExceptionInfo.Serialize().Deserialize<ExceptionInfo>(); }
public CompensationFailed(HostInfo host, Guid trackingNumber, string activityName, Guid executionId, DateTime timestamp, TimeSpan duration, DateTime failureTimestamp, TimeSpan routingSlipDuration, ExceptionInfo exceptionInfo, IDictionary<string, object> variables, IDictionary<string, object> data) { _failureTimestamp = failureTimestamp; _routingSlipDuration = routingSlipDuration; Host = host; _duration = duration; _timestamp = timestamp; TrackingNumber = trackingNumber; ExecutionId = executionId; ActivityName = activityName; Data = data; Variables = variables; ExceptionInfo = exceptionInfo; }
protected override void Before_all_tests() { base.Before_all_tests(); try { throw new Exception("Expected:<1>. Actual:<2>."); } catch (Exception ex2) { exception = ex2; } beforeExceptionInfo = new ExceptionInfo(exception); afterExceptionInfo = beforeExceptionInfo.Serialize().Deserialize<ExceptionInfo>(); }
public RichILStringToTextWriter(TextWriter writer, ExceptionInfo[] exceptions) : base(writer) { foreach (var e in exceptions) { var startCount = 0; if (!_startCounts.TryGetValue(e.StartAddress, out startCount)) { _startCounts.Add(e.StartAddress, startCount); } _startCounts[e.StartAddress] += e.Handlers.Length; foreach (var c in e.Handlers) { if (c.Kind == HandlerKind.Finally) { _startFinally.Add(c.StartAddress); } else if (c.Kind == HandlerKind.Fault) { _startFault.Add(c.StartAddress); } else if (c.Kind == HandlerKind.Filter) { _startFilter.Add(c.StartAddress); } else { _startCatch.Add(c.StartAddress, c.Type); } var endCount = 0; if (!_endCounts.TryGetValue(c.EndAddress, out endCount)) { _endCounts.Add(c.EndAddress, endCount); } _endCounts[c.EndAddress]++; } } }
public static bool Write(SafeHandle fileHandle, Option options, ExceptionInfo exceptionInfo) { Process currentProcess = Process.GetCurrentProcess(); IntPtr currentProcessHandle = currentProcess.Handle; uint currentProcessId = (uint)currentProcess.Id; MiniDumpExceptionInformation exp; exp.ThreadId = GetCurrentThreadId(); exp.ClientPointers = false; exp.ExceptionPointers = IntPtr.Zero; if (exceptionInfo == ExceptionInfo.Present) { exp.ExceptionPointers = System.Runtime.InteropServices.Marshal.GetExceptionPointers(); } bool bRet = false; if (exp.ExceptionPointers == IntPtr.Zero) { bRet = MiniDumpWriteDump(currentProcessHandle, currentProcessId, fileHandle, (uint)options, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); } else { bRet = MiniDumpWriteDump(currentProcessHandle, currentProcessId, fileHandle, (uint)options, ref exp, IntPtr.Zero, IntPtr.Zero); } return bRet; }
public void Add(ExceptionInfoKey key) { ExceptionInfo info; if (exceptions.TryGetValue(key, out info)) return; info = new ExceptionInfo(key, true); exceptions.Add(key, info); if (Changed != null) Changed(this, new ExceptionManagerEventArgs(ExceptionManagerEventType.Added, info)); }
void WriteBreakOnFirstChance(ExceptionInfo info, bool breakOnFirstChance) { if (info.BreakOnFirstChance == breakOnFirstChance) return; info.BreakOnFirstChance = breakOnFirstChance; BreakOnFirstChanceChanged(info); }
internal void BreakOnFirstChanceChanged(ExceptionInfo info) { ExceptionInfo info2; bool b = exceptions.TryGetValue(info.Key, out info2) && ReferenceEquals(info, info2); Debug.Assert(b); if (!b) return; if (Changed != null) Changed(this, new ExceptionManagerEventArgs(ExceptionManagerEventType.ExceptionInfoPropertyChanged, info)); }
internal void AddOrUpdate(ExceptionInfoKey key, bool breakOnFirstChance, bool isOtherExceptions) { if (isOtherExceptions) { int index = (int)key.ExceptionType; if ((uint)index < (uint)otherExceptions.Length) WriteBreakOnFirstChance(otherExceptions[index], breakOnFirstChance); } else { ExceptionInfo info; if (exceptions.TryGetValue(key, out info)) WriteBreakOnFirstChance(info, breakOnFirstChance); else { exceptions[key] = info = new ExceptionInfo(key, breakOnFirstChance); if (Changed != null) Changed(this, new ExceptionManagerEventArgs(ExceptionManagerEventType.Added, info)); } } }
public void Add(ExceptionInfoKey key) { ExceptionInfo info; if (exceptions.TryGetValue(key, out info)) return; info = new ExceptionInfo(key, true); exceptions.Add(key, info); Changed?.Invoke(this, new ExceptionServiceEventArgs(ExceptionServiceEventType.Added, info)); }
public bool CanRemove(ExceptionInfo info) => !info.IsOtherExceptions;
public void BreakOnFirstChanceChanged(ExceptionInfo info) { ExceptionInfo info2; bool b = exceptions.TryGetValue(info.Key, out info2) && ReferenceEquals(info, info2); Debug.Assert(b); if (!b) return; Changed?.Invoke(this, new ExceptionServiceEventArgs(ExceptionServiceEventType.ExceptionInfoPropertyChanged, info)); }
public override bool Generate(CommandExecutionContext context) { var target = context.NativeDbgEngTarget; var lastEvent = target.GetLastEventInformation(); if (lastEvent == null) return false; var stackTraces = new UnifiedStackTraces(target.DebuggerInterface, context); var threadWithException = stackTraces.Threads.SingleOrDefault(t => t.OSThreadId == lastEvent.OSThreadId); if (threadWithException == null) return false; Exception = new ExceptionInfo { ExceptionCode = lastEvent.ExceptionRecord?.ExceptionCode ?? 0 }; if (Exception.ExceptionCode== 0) return false; OSThreadId = threadWithException.OSThreadId; ManagedThreadId = threadWithException.ManagedThread?.ManagedThreadId ?? 0; // Note that we want the thread's stack from the exception context, // and not from wherever it is right now. Exception.StackFrames = stackTraces.GetStackTraceFromStoredEvent() .Where(f => f.Type != UnifiedStackFrameType.Special) .Select(f => f.DisplayString) .ToList(); // Note that we might have an exception, but if it wasn't managed // then the Thread.CurrentException field will be null. var exception = threadWithException.ManagedThread?.CurrentException; if (exception == null) return true; Exception.ExceptionType = exception.Type.Name; Exception.ExceptionMessage = exception.Message; exception = exception.Inner; var exceptionInfo = Exception; while (exception != null) { exceptionInfo.InnerException = new ExceptionInfo(); exceptionInfo = exceptionInfo.InnerException; exceptionInfo.ExceptionType = exception.Type.Name; exceptionInfo.ExceptionMessage = exception.Message; exceptionInfo.StackFrames = exception.StackTrace.Select(f => f.DisplayString).ToList(); exception = exception.Inner; } if (Exception != null) Recommendations.Add(new UnhandledExceptionOccurred { Exception = Exception }); return true; }
public bool CanRemove(ExceptionInfo info) { return !info.IsOtherExceptions; }
private static ExceptionInfo GetExceptionInfo(Exception exception) { var exceptionInfo = new ExceptionInfo { StackTrace = exception.StackTrace, ExceptionType = exception.GetType().FullName, Message = exception.Message, Source = exception.Source, Data = GetExceptionData(exception), }; MethodBase method = exception.TargetSite; if (method != null) { exceptionInfo.MethodName = string.Format("{0}.{1}", method.DeclaringType == null ? "Unknown" : method.DeclaringType.FullName, method.Name); } if (exception.InnerException != null) { exceptionInfo.InnerExceptionInfo = GetExceptionInfo(exception.InnerException); } return exceptionInfo; }
static int CompareExceptionInfos(ExceptionInfo a, ExceptionInfo b) { int res = a.ExceptionType.CompareTo(b.ExceptionType); if (res != 0) return res; if (a.IsOtherExceptions != b.IsOtherExceptions) return a.IsOtherExceptions ? -1 : 1; return StringComparer.CurrentCultureIgnoreCase.Compare(a.Name, b.Name); }
/// <summary> /// Set current exception info /// </summary> public void SetException(Exception err) { Exception = new ExceptionInfo(err); }
void Add(ExceptionInfo info) { var vm = new ExceptionVM(info, exceptionContext); int i; for (i = 0; i + 1 < Collection.Count; i++) { int res = CompareExceptionInfos(vm.ExceptionInfo, Collection[i].ExceptionInfo); if (res <= 0) break; } Collection.Insert(i, vm); }