Пример #1
0
        /*
         * If the Mono 4.8 APIs are unavailable, we must overwrite the signal handlers for certain signals.
         */
        private void OverwriteSignalHandlers()
        {
            /* Allocate space to store the Mono handlers */
            var sigbus  = Marshal.AllocHGlobal(512);
            var sigsegv = Marshal.AllocHGlobal(512);
            var sigfpe  = Marshal.AllocHGlobal(512);

            /* Store Mono's SIGSEGV, SIGBUS, and SIGFPE handlers */
            sigaction(Signal.SIGBUS, IntPtr.Zero, sigbus);
            sigaction(Signal.SIGSEGV, IntPtr.Zero, sigsegv);
            sigaction(Signal.SIGFPE, IntPtr.Zero, sigfpe);

            /* Enable native SDK crash reporting library */
            MSWrapperExceptionManager.StartCrashReportingFromWrapperSdk();

            /* Restore Mono SIGSEGV, SIGBUS, and SIGFPE handlers */
            sigaction(Signal.SIGBUS, sigbus, IntPtr.Zero);
            sigaction(Signal.SIGSEGV, sigsegv, IntPtr.Zero);
            sigaction(Signal.SIGFPE, sigfpe, IntPtr.Zero);

            /* Release previously allocated space */
            Marshal.FreeHGlobal(sigbus);
            Marshal.FreeHGlobal(sigsegv);
            Marshal.FreeHGlobal(sigfpe);
        }
Пример #2
0
        internal ErrorReport(MSErrorReport msReport)
        {
            // If Id is not null we have loaded the report from the cache
            if (Id != null)
            {
                return;
            }

            Id           = msReport.IncidentIdentifier;
            AppStartTime = NSDateToDateTimeOffset(msReport.AppStartTime);
            AppErrorTime = NSDateToDateTimeOffset(msReport.AppErrorTime);
            Device       = msReport.Device == null ? null : new Device(msReport.Device);

            AndroidDetails = null;

            iOSDetails = new iOSErrorDetails(msReport.ReporterKey,
                                             msReport.Signal,
                                             msReport.ExceptionName,
                                             msReport.ExceptionReason,
                                             (uint)msReport.AppProcessIdentifier);

            MSWrapperException wrapperException = MSWrapperExceptionManager.LoadWrapperExceptionWithUUID(msReport.IncidentIdentifier);

            if (wrapperException != null && wrapperException.ExceptionData != null)
            {
                Exception = CrashesUtils.DeserializeException(wrapperException.ExceptionData.ToArray());
            }
        }
Пример #3
0
        /*
         * In Mono 4.8, it is possible to chain the mono signal handlers to the PLCrashReporter signal handlers, so
         * if the APIs for this are available, it is preferable to use them. If the APIs are unavailable, return
         * false.
         */
        private bool TryChainingSignalHandlers()
        {
            var type = Type.GetType("Mono.Runtime");
            var installSignalHandlers = type?.GetMethod("InstallSignalHandlers", BindingFlags.Public | BindingFlags.Static);
            var removeSignalHandlers  = type?.GetMethod("RemoveSignalHandlers", BindingFlags.Public | BindingFlags.Static);

            if (installSignalHandlers == null || removeSignalHandlers == null)
            {
                return(false);
            }

            try
            {
            }
            finally
            {
                removeSignalHandlers.Invoke(null, null);
                try
                {
                    MSWrapperExceptionManager.StartCrashReportingFromWrapperSdk();
                }
                finally
                {
                    installSignalHandlers.Invoke(null, null);
                }
            }

            return(true);
        }
        private static void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            Exception   systemException = e.ExceptionObject as Exception;
            MSException exception       = GenerateiOSException(systemException);

            MSWrapperExceptionManager.SetWrapperException(exception);

            byte[] exceptionBytes       = CrashesUtils.SerializeException(systemException);
            NSData wrapperExceptionData = NSData.FromArray(exceptionBytes);

            MSWrapperExceptionManager.SetWrapperExceptionData(wrapperExceptionData);
        }
Пример #5
0
        static void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            Exception   systemException = e.ExceptionObject as Exception;
            MSException exception       = GenerateiOSException(systemException, true);

            byte[] exceptionBytes       = CrashesUtils.SerializeException(systemException);
            NSData wrapperExceptionData = NSData.FromArray(exceptionBytes);

            MSWrapperException wrapperException = new MSWrapperException
            {
                Exception     = exception,
                ExceptionData = wrapperExceptionData,
                ProcessId     = new NSNumber(Process.GetCurrentProcess().Id)
            };

            MSWrapperExceptionManager.SaveWrapperException(wrapperException);
        }
Пример #6
0
        static void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            Exception systemException = e.ExceptionObject as Exception;

            AppCenterLog.Error(LogTag, "Unhandled Exception:", systemException);
            MSException exception = GenerateiOSException(systemException, true);

            byte[]             exceptionBytes       = CrashesUtils.SerializeException(systemException) ?? new byte[0];
            NSData             wrapperExceptionData = NSData.FromArray(exceptionBytes);
            MSWrapperException wrapperException     = new MSWrapperException
            {
                Exception     = exception,
                ExceptionData = wrapperExceptionData,
                ProcessId     = new NSNumber(Process.GetCurrentProcess().Id)
            };

            AppCenterLog.Info(LogTag, "Saving wrapper exception...");
            MSWrapperExceptionManager.SaveWrapperException(wrapperException);
            AppCenterLog.Info(LogTag, "Saved wrapper exception.");
        }
        //public override void TrackException(Exception exception)
        //{
        //	throw new NotImplementedException();
        //}

        static PlatformCrashes()
        {
            /* Peform custom setup around the native SDK's for setting signal handlers */
            MSWrapperExceptionManager.SetDelegate(new CrashesInitializationDelegate());
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
        }