public WatsonExceptionReport(string eventType, Process process, Exception exception, ReportOptions reportOptions) : base(eventType, process)
        {
            this.exception     = exception;
            base.ReportOptions = reportOptions;
            IntPtr exceptionPointers = Marshal.GetExceptionPointers();

            if ((base.ReportOptions & ReportOptions.DoNotLogProcessAndThreadIds) == ReportOptions.None)
            {
                base.LogExtraData("Process ID=" + base.ProcessId);
                if (!base.TargetExternalProcess)
                {
                    base.LogExtraData(string.Concat(new object[]
                    {
                        "Managed Thread ID=",
                        Environment.CurrentManagedThreadId,
                        Environment.NewLine,
                        "Native Thread ID=",
                        DiagnosticsNativeMethods.GetCurrentThreadId()
                    }));
                }
            }
            if (exceptionPointers == IntPtr.Zero)
            {
                this.exceptionInfo = null;
                this.exceptionEIP  = IntPtr.Zero;
                return;
            }
            this.exceptionInfo = new DiagnosticsNativeMethods.WER_EXCEPTION_INFORMATION();
            this.exceptionInfo.exceptionPointers = exceptionPointers;
            this.exceptionInfo.clientPointers    = false;
            this.exceptionEIP = ((DiagnosticsNativeMethods.ExceptionRecord)Marshal.PtrToStructure(((DiagnosticsNativeMethods.ExceptionPointers)Marshal.PtrToStructure(exceptionPointers, typeof(DiagnosticsNativeMethods.ExceptionPointers))).ExceptionRecord, typeof(DiagnosticsNativeMethods.ExceptionRecord))).ExceptionAddress;
        }
예제 #2
0
 public MemoryTraceBuilder(int maximumEntries, int maximumBufferSize)
 {
     this.traceBuffer = new char[maximumBufferSize + 1];
     this.entries = new TraceEntry[maximumEntries + 1];
     this.bufferLength = maximumBufferSize + 1;
     this.entryArrayLength = maximumEntries + 1;
     this.nativeThreadId = DiagnosticsNativeMethods.GetCurrentThreadId();
 }
 public override void Send()
 {
     if (base.IsFlagSet(ReportOptions.DoNotFreezeThreads) || base.IsFlagSet(ReportOptions.DoNotCollectDumps))
     {
         base.Send();
         return;
     }
     lock (WatsonReport.HeapDumpReportLockObject)
     {
         if (!ExWatson.ReaperThreadAllowed)
         {
             base.Send();
         }
         else
         {
             Thread thread = null;
             try
             {
                 ManualResetEvent reaperThreadIsRunning = new ManualResetEvent(false);
                 thread = new Thread(delegate()
                 {
                     try
                     {
                         WatsonExceptionReport.nativeReaperThreadId = DiagnosticsNativeMethods.GetCurrentThreadId();
                         reaperThreadIsRunning.Set();
                         Thread.Sleep(ExWatson.CrashReportTimeout);
                         ExWatson.TerminateCurrentProcess();
                     }
                     catch
                     {
                     }
                 });
                 thread.Start();
                 reaperThreadIsRunning.WaitOne();
                 base.Send();
             }
             catch
             {
             }
             finally
             {
                 if (thread != null)
                 {
                     thread.Abort();
                     WatsonExceptionReport.nativeReaperThreadId = -1;
                 }
             }
         }
     }
 }
 protected override void WriteReportTypeSpecificSection(XmlWriter reportFile)
 {
     using (new SafeXmlTag(reportFile, "exception-report").WithAttribute("is-clr-terminating", base.IsFlagSet(ReportOptions.ReportTerminateAfterSend) ? "1" : "0"))
     {
         using (new SafeXmlTag(reportFile, "application").WithAttribute("name", base.AppName).WithAttribute("version", WatsonReport.ExchangeFormattedVersion(base.AppVersion)))
         {
         }
         using (new SafeXmlTag(reportFile, "assembly").WithAttribute("name", base.BucketingParameter <WatsonExceptionReport.BucketParamId>(WatsonExceptionReport.BucketParamId.AssemblyName)).WithAttribute("version", base.BucketingParameter <WatsonExceptionReport.BucketParamId>(WatsonExceptionReport.BucketParamId.AssemblyVer)))
         {
         }
         using (SafeXmlTag safeXmlTag4 = new SafeXmlTag(reportFile, "exception"))
         {
             safeXmlTag4.SetContent(WatsonReport.SanitizeException(this.exception.ToString()));
         }
         using (new SafeXmlTag(reportFile, "base-exception").WithAttribute("target-site", this.baseExceptionTargetSite).WithAttribute("assembly-name", this.baseExceptionAssemblyName).WithAttribute("method-name", this.baseExceptionMethodName))
         {
         }
         using (SafeXmlTag safeXmlTag6 = new SafeXmlTag(reportFile, "process").WithAttribute("eip", "0x" + ((IntPtr.Size == 4) ? this.exceptionEIP.ToString("x8") : this.exceptionEIP.ToString("x16"))).WithAttribute("bitness", (IntPtr.Size * 8).ToString()).WithAttribute("pid", base.ProcessId.ToString()))
         {
             if (base.ProcessId == DiagnosticsNativeMethods.GetCurrentProcessId())
             {
                 safeXmlTag6.WithAttribute("managed-tid", Environment.CurrentManagedThreadId.ToString()).WithAttribute("native-tid", DiagnosticsNativeMethods.GetCurrentThreadId().ToString());
             }
         }
         if (this.lids != null)
         {
             using (SafeXmlTag safeXmlTag7 = new SafeXmlTag(reportFile, "location-ids"))
             {
                 safeXmlTag7.SetContent(this.lids);
             }
         }
     }
 }