PLCrashReporter.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Author: Landon Fuller <landonf@plausiblelabs.com>
  3. *
  4. * Copyright (c) 2008-2009 Plausible Labs Cooperative, Inc.
  5. * All rights reserved.
  6. *
  7. * Permission is hereby granted, free of charge, to any person
  8. * obtaining a copy of this software and associated documentation
  9. * files (the "Software"), to deal in the Software without
  10. * restriction, including without limitation the rights to use,
  11. * copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the
  13. * Software is furnished to do so, subject to the following
  14. * conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be
  17. * included in all copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21. * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23. * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24. * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26. * OTHER DEALINGS IN THE SOFTWARE.
  27. */
  28. #import <Foundation/Foundation.h>
  29. /**
  30. * @ingroup functions
  31. *
  32. * Prototype of a callback function used to execute additional user code with signal information as provided
  33. * by PLCrashReporter. Called upon completion of crash handling, after the crash report has been written to disk.
  34. *
  35. * @param info The signal info.
  36. * @param uap The crash's threads context.
  37. * @param context The API client's supplied context value.
  38. *
  39. * @sa @ref async_safety
  40. * @sa PLCrashReporter::setPostCrashCallbacks:
  41. */
  42. typedef void (*UnityPLCrashReporterPostCrashSignalCallback)(siginfo_t *info, ucontext_t *uap, void *context);
  43. /**
  44. * @ingroup types
  45. *
  46. * This structure contains callbacks supported by PLCrashReporter to allow the host application to perform
  47. * additional tasks prior to program termination after a crash has occured.
  48. *
  49. * @sa @ref async_safety
  50. */
  51. typedef struct UnityPLCrashReporterCallbacks
  52. {
  53. /** The version number of this structure. If not one of the defined version numbers for this type, the behavior
  54. * is undefined. The current version of this structure is 0. */
  55. uint16_t version;
  56. /** An arbitrary user-supplied context value. This value may be NULL. */
  57. void *context;
  58. /** The callback used to report caught signal information. In version 0 of this structure, all crashes will be
  59. * reported via this function. */
  60. UnityPLCrashReporterPostCrashSignalCallback handleSignal;
  61. } UnityPLCrashReporterCallbacks;
  62. @interface UnityPLCrashReporter : NSObject
  63. {
  64. @private
  65. /** YES if the crash reporter has been enabled */
  66. BOOL _enabled;
  67. /** Application identifier */
  68. NSString *_applicationIdentifier;
  69. /** Application version */
  70. NSString *_applicationVersion;
  71. /** Path to the crash reporter internal data directory */
  72. NSString *_crashReportDirectory;
  73. }
  74. + (UnityPLCrashReporter *)sharedReporter;
  75. - (BOOL)hasPendingCrashReport;
  76. - (NSData *)loadPendingCrashReportData;
  77. - (NSData *)loadPendingCrashReportDataAndReturnError:(NSError **)outError;
  78. - (NSData *)generateLiveReport;
  79. - (NSData *)generateLiveReportAndReturnError:(NSError **)outError;
  80. - (BOOL)purgePendingCrashReport;
  81. - (BOOL)purgePendingCrashReportAndReturnError:(NSError **)outError;
  82. - (BOOL)enableCrashReporter;
  83. - (BOOL)enableCrashReporterAndReturnError:(NSError **)outError;
  84. - (void)setCrashCallbacks:(UnityPLCrashReporterCallbacks *)callbacks;
  85. @end